2020-08-21 10:03:21 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "py/obj.h"
|
|
|
|
#include "py/mphal.h"
|
|
|
|
#include "pin.h"
|
|
|
|
|
2021-08-01 05:20:39 -04:00
|
|
|
#define PIN_AF(_name, _af_mode, _input_daisy, _instance, _input_register, _pad_config) \
|
2020-08-21 10:03:21 -04:00
|
|
|
{ \
|
|
|
|
.base = { &machine_pin_af_type }, \
|
|
|
|
.name = MP_QSTR_##_name, \
|
|
|
|
.af_mode = (uint32_t)(_af_mode), \
|
2021-08-01 05:20:39 -04:00
|
|
|
.input_daisy = (uint8_t)(_input_daisy), \
|
2020-08-21 10:03:21 -04:00
|
|
|
.instance = (void *)(_instance), \
|
2021-08-01 05:20:39 -04:00
|
|
|
.input_register = (uint32_t)(_input_register), \
|
2020-08-21 10:03:21 -04:00
|
|
|
.pad_config = (uint32_t)(_pad_config), \
|
|
|
|
} \
|
|
|
|
|
2021-04-24 15:34:07 -04:00
|
|
|
#define PIN_ADC(_instance, _channel) \
|
|
|
|
{ \
|
|
|
|
.instance = (_instance), \
|
|
|
|
.channel = (_channel) \
|
|
|
|
} \
|
|
|
|
|
|
|
|
#define PIN(_name, _gpio, _pin, _af_list, _adc_list_len, _adc_list) \
|
2020-08-21 10:03:21 -04:00
|
|
|
{ \
|
|
|
|
.base = { &machine_pin_type }, \
|
|
|
|
.name = MP_QSTR_##_name, \
|
|
|
|
.gpio = (_gpio), \
|
|
|
|
.pin = (uint32_t)(_pin), \
|
|
|
|
.muxRegister = (uint32_t)&(IOMUXC->SW_MUX_CTL_PAD[kIOMUXC_SW_MUX_CTL_PAD_##_name]), \
|
|
|
|
.configRegister = (uint32_t)&(IOMUXC->SW_PAD_CTL_PAD[kIOMUXC_SW_PAD_CTL_PAD_##_name]), \
|
2021-04-24 15:34:07 -04:00
|
|
|
.af_list_len = (uint8_t)(sizeof((_af_list)) / sizeof(machine_pin_af_obj_t)), \
|
|
|
|
.adc_list_len = (_adc_list_len), \
|
2020-08-21 10:03:21 -04:00
|
|
|
.af_list = (_af_list), \
|
2021-04-24 15:34:07 -04:00
|
|
|
.adc_list = (_adc_list), \
|
2020-08-21 10:03:21 -04:00
|
|
|
} \
|
2021-08-01 05:20:39 -04:00
|
|
|
|
2021-10-20 15:24:20 -04:00
|
|
|
#define PIN_LPSR(_name, _gpio, _pin, _af_list, _adc_list_len, _adc_list) \
|
|
|
|
{ \
|
|
|
|
.base = { &machine_pin_type }, \
|
|
|
|
.name = MP_QSTR_##_name, \
|
|
|
|
.gpio = (_gpio), \
|
|
|
|
.pin = (uint32_t)(_pin), \
|
|
|
|
.muxRegister = (uint32_t)&(IOMUXC_LPSR->SW_MUX_CTL_PAD[kIOMUXC_LPSR_SW_MUX_CTL_PAD_##_name]), \
|
|
|
|
.configRegister = (uint32_t)&(IOMUXC_LPSR->SW_PAD_CTL_PAD[kIOMUXC_LPSR_SW_PAD_CTL_PAD_##_name]), \
|
|
|
|
.af_list_len = (uint8_t)(sizeof((_af_list)) / sizeof(machine_pin_af_obj_t)), \
|
|
|
|
.adc_list_len = (_adc_list_len), \
|
|
|
|
.af_list = (_af_list), \
|
|
|
|
.adc_list = (_adc_list), \
|
|
|
|
} \
|
|
|
|
|