c214c9e648
This commit adds support for generating named pin mappings for all pins including CPU, board-defined, LED and externally controlled pins. CPU pins are mapped to `pin_GPIO<n>`, externally-controlled pins are mapped to `pin_EXT_GPIO<n>`, and defined conditionally (up to 10 pins, and can be expanded in the future), and they are non-const to allow `machine-pin.c` to write the pin object fields. Both CPU and externally controlled pins are generated even if there's no board CSV file; if one exists it will just be added to board pins.
37 lines
1.5 KiB
C
37 lines
1.5 KiB
C
#include <stdint.h>
|
|
#include "py/obj.h"
|
|
#include "py/mphal.h"
|
|
#include "machine_pin.h"
|
|
|
|
#define AF(af_idx, af_fn, af_unit) \
|
|
{ \
|
|
.base = { &machine_pin_af_type }, \
|
|
.name = MP_QSTR_##af_fn, \
|
|
.idx = (af_idx), \
|
|
.fn = GPIO_FUNC_##af_fn, \
|
|
.unit = (af_unit), \
|
|
}
|
|
|
|
#if MICROPY_HW_PIN_EXT_COUNT
|
|
#define PIN(_id, _name, _is_ext, _af_num, _af_list) \
|
|
{ \
|
|
.base = { &machine_pin_type }, \
|
|
.name = MP_QSTR_##_name, \
|
|
.id = (uint8_t)(_id), \
|
|
.is_ext = (_is_ext), \
|
|
.is_output = false, \
|
|
.last_output_value = 0, \
|
|
.af_num = (_af_num), \
|
|
.af = (_af_list), \
|
|
}
|
|
#else
|
|
#define PIN(_id, _name, _is_ext, _af_num, _af_list) \
|
|
{ \
|
|
.base = { &machine_pin_type }, \
|
|
.name = MP_QSTR_##_name, \
|
|
.id = (uint8_t)(_id), \
|
|
.af_num = (_af_num), \
|
|
.af = (_af_list), \
|
|
}
|
|
#endif
|