<commit_before>#include "shared-bindings/microcontroller/Pin.h"

#include "samd21_pins.h"

#define SERCOM(p_sercom, p_pad) \
{ \
  .sercom = p_sercom, \
  .pad = p_pad \
}

#define NO_SERCOM SERCOM(0, 0)

#define TCC(p_tcc, p_channel, p_wave_output) \
{ \
  .tcc = p_tcc, \
  .is_tc = false, \
  .channel = p_channel, \
  .wave_output = p_wave_output \
}

#define TC(p_tc, p_channel, p_wave_output) \
{ \
  .tc = p_tc, \
  .is_tc = true, \
  .channel = p_channel, \
  .wave_output = p_wave_output \
}

#define NO_TIMER TCC(0, 0, 0)

#define TOUCH(y_line) \
    .has_touch = true, \
    .touch_y_line = y_line,

#define NO_TOUCH \
    .has_touch = false,

#define EXTINT_CHANNEL(channel) \
    .has_extint = true, \
    .extint_channel = channel,

#define NO_EXTINT \
    .has_extint = false,

#define ADC_INPUT(input) \
    .has_adc = true, \
    .adc_input = input,

#define NO_ADC \
    .has_adc = false,

// This macro is used to simplify pin definition in boards/<board>/pins.c
#define PIN(p_name, p_adc, p_extint, p_touch, p_primary_timer,  \
            p_secondary_timer, p_primary_sercom, p_secondary_sercom) \
const mcu_pin_obj_t pin_## p_name = { \
    { &mcu_pin_type }, \
    .name = MP_QSTR_ ## p_name, \
    .pin = (PIN_## p_name), \
    p_extint \
    p_adc \
    p_touch \
    .primary_timer = p_primary_timer, \
    .secondary_timer =  p_secondary_timer, \
    .sercom = {p_primary_sercom, p_secondary_sercom}, \
}

#define NO_ADC_INPUT (0)

// Pins in datasheet order.
// NOTE(tannewt): TC wave out 0 is commented out because the first channel is
// used to vary the 16 bit timer's frequency.
#ifdef PIN_PA00
PIN(PA00, EXTINT_CHANNEL(0), NO_ADC, NO_TOUCH,
    TCC(TCC2, 0, 0),
    NO_TIMER,
    NO_SERCOM,
    SERCOM(SERCOM1, 0));
#endif
#ifdef PIN_PA01
PIN(PA01, EXTINT_CHANNEL(1), NO_ADC, NO_TOUCH,
    TCC(TCC2, 1, 1),
    NO_TIMER,
    NO_SERCOM,
    SERCOM(SERCOM1, 1));
#endif
#ifdef PIN_PA02
PIN(PA02, EXTINT_CHANNEL(2), ADC_INPUT(ADC_POSITIVE_INPUT_PIN0), TOUCH(0),
    NO_TIMER,
    NO_TIMER,
    NO_SERCOM,
    NO_SERCOM);
#endif
#ifdef PIN_PA03
PIN(PA03, EXTINT_CHANNEL(3), ADC_INPUT(ADC_POSITIVE_INPUT_PIN1), TOUCH(1),
    NO_TIMER,
    NO_TIMER,
    NO_SERCOM,
    NO_SERCOM);
#endif
#ifdef PIN_PB04
PIN(PB04, EXTINT_CHANNEL(4), ADC_INPUT(ADC_POSITIVE_INPUT_PIN12), TOUCH(10),
    NO_TIMER,
    NO_TIMER,
    NO_SERCOM,
    NO_SERCOM);
#endif
#ifdef PIN_PB05
PIN(PB05, EXTINT_CHANNEL(5), ADC_INPUT(ADC_POSITIVE_INPUT_PIN13), TOUCH(11),
    NO_TIMER,
    NO_TIMER,
    NO_SERCOM,
    NO_SERCOM);
#endif
#ifdef PIN_PB06
PIN(PB06, EXTINT_CHANNEL(6), ADC_INPUT(ADC_POSITIVE_INPUT_PIN14), TOUCH(12),
    NO_TIMER,
    NO_TIMER,
    NO_SERCOM,
    NO_SERCOM);
#endif
#ifdef PIN_PB07
PIN(PB07, EXTINT_CHANNEL(7), TOUCH(ADC_POSITIVE_INPUT_PIN15), TOUCH(13),
    NO_TIMER,
    NO_TIMER,<commit_msg>Fix ADC input def for PB07. (#195)<commit_after>#include "shared-bindings/microcontroller/Pin.h"

#include "samd21_pins.h"

#define SERCOM(p_sercom, p_pad) \
{ \
  .sercom = p_sercom, \
  .pad = p_pad \
}

#define NO_SERCOM SERCOM(0, 0)

#define TCC(p_tcc, p_channel, p_wave_output) \
{ \
  .tcc = p_tcc, \
  .is_tc = false, \
  .channel = p_channel, \
  .wave_output = p_wave_output \
}

#define TC(p_tc, p_channel, p_wave_output) \
{ \
  .tc = p_tc, \
  .is_tc = true, \
  .channel = p_channel, \
  .wave_output = p_wave_output \
}

#define NO_TIMER TCC(0, 0, 0)

#define TOUCH(y_line) \
    .has_touch = true, \
    .touch_y_line = y_line,

#define NO_TOUCH \
    .has_touch = false,

#define EXTINT_CHANNEL(channel) \
    .has_extint = true, \
    .extint_channel = channel,

#define NO_EXTINT \
    .has_extint = false,

#define ADC_INPUT(input) \
    .has_adc = true, \
    .adc_input = input,

#define NO_ADC \
    .has_adc = false,

// This macro is used to simplify pin definition in boards/<board>/pins.c
#define PIN(p_name, p_adc, p_extint, p_touch, p_primary_timer,  \
            p_secondary_timer, p_primary_sercom, p_secondary_sercom) \
const mcu_pin_obj_t pin_## p_name = { \
    { &mcu_pin_type }, \
    .name = MP_QSTR_ ## p_name, \
    .pin = (PIN_## p_name), \
    p_extint \
    p_adc \
    p_touch \
    .primary_timer = p_primary_timer, \
    .secondary_timer =  p_secondary_timer, \
    .sercom = {p_primary_sercom, p_secondary_sercom}, \
}

#define NO_ADC_INPUT (0)

// Pins in datasheet order.
// NOTE(tannewt): TC wave out 0 is commented out because the first channel is
// used to vary the 16 bit timer's frequency.
#ifdef PIN_PA00
PIN(PA00, EXTINT_CHANNEL(0), NO_ADC, NO_TOUCH,
    TCC(TCC2, 0, 0),
    NO_TIMER,
    NO_SERCOM,
    SERCOM(SERCOM1, 0));
#endif
#ifdef PIN_PA01
PIN(PA01, EXTINT_CHANNEL(1), NO_ADC, NO_TOUCH,
    TCC(TCC2, 1, 1),
    NO_TIMER,
    NO_SERCOM,
    SERCOM(SERCOM1, 1));
#endif
#ifdef PIN_PA02
PIN(PA02, EXTINT_CHANNEL(2), ADC_INPUT(ADC_POSITIVE_INPUT_PIN0), TOUCH(0),
    NO_TIMER,
    NO_TIMER,
    NO_SERCOM,
    NO_SERCOM);
#endif
#ifdef PIN_PA03
PIN(PA03, EXTINT_CHANNEL(3), ADC_INPUT(ADC_POSITIVE_INPUT_PIN1), TOUCH(1),
    NO_TIMER,
    NO_TIMER,
    NO_SERCOM,
    NO_SERCOM);
#endif
#ifdef PIN_PB04
PIN(PB04, EXTINT_CHANNEL(4), ADC_INPUT(ADC_POSITIVE_INPUT_PIN12), TOUCH(10),
    NO_TIMER,
    NO_TIMER,
    NO_SERCOM,
    NO_SERCOM);
#endif
#ifdef PIN_PB05
PIN(PB05, EXTINT_CHANNEL(5), ADC_INPUT(ADC_POSITIVE_INPUT_PIN13), TOUCH(11),
    NO_TIMER,
    NO_TIMER,
    NO_SERCOM,
    NO_SERCOM);
#endif
#ifdef PIN_PB06
PIN(PB06, EXTINT_CHANNEL(6), ADC_INPUT(ADC_POSITIVE_INPUT_PIN14), TOUCH(12),
    NO_TIMER,
    NO_TIMER,
    NO_SERCOM,
    NO_SERCOM);
#endif
#ifdef PIN_PB07
PIN(PB07, EXTINT_CHANNEL(7), ADC_INPUT(ADC_POSITIVE_INPUT_PIN15), TOUCH(13),
    NO_TIMER,
    NO_TIMER,
{'fraction_non_alphanumeric': 0.12674315975286848, 'fraction_numerical': 0.029479258605472198, 'mean_word_length': 3.4755134281200633, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '322204', 'n_tokens_mistral': 2614, 'n_tokens_neox': 2519, 'n_words': 471}