From 51dabac0961165cd38cdd0ba227aaf014190091c Mon Sep 17 00:00:00 2001 From: Dave Hylands Date: Mon, 17 Feb 2014 17:57:13 -0800 Subject: Add pin mapping code. This commit also introduces board directories and moves board specific config into the appropriate board directory. boards/stm32f4xx-af.csv was extracted from the STM32F4xx datasheet and hand-tweaked. make-pins.py takes boards/stm32f4xx-af.csv, boards/stm32f4xx-prefix.c, and boards/BOARD-NAME/pins.csv as input and generates the file build/pins_BOARD_NAME.c The generated pin file for PYBOARD4 looks like this: https://gist.github.com/dhylands/9063231 The generated pins file includes all of the supported alternate functions, and includes upsupported alternate functions as comments. See the commnet block at the top of stm/pin_map.c for details on how to use the pin mapper. I also went ahead and modified stm/gpio.c to use the pin mapper. --- stm/boards/stm32f4xx-prefix.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 stm/boards/stm32f4xx-prefix.c (limited to 'stm/boards/stm32f4xx-prefix.c') diff --git a/stm/boards/stm32f4xx-prefix.c b/stm/boards/stm32f4xx-prefix.c new file mode 100644 index 000000000..e68de4cf4 --- /dev/null +++ b/stm/boards/stm32f4xx-prefix.c @@ -0,0 +1,34 @@ +// stm32fxx-prefix.c becomes the initial portion of the generated pins file. + +#include +#include +#include + +#include "misc.h" +#include "mpconfig.h" +#include "qstr.h" +#include "obj.h" + +#include "pin.h" + +#define AF(af_idx, af_fn, af_unit, af_type, af_ptr) \ +{ \ + { &pin_af_obj_type }, \ + .idx = (af_idx), \ + .fn = AF_FN_ ## af_fn, \ + .unit = (af_unit), \ + .type = AF_PIN_TYPE_ ## af_fn ## _ ## af_type, \ + .af_fn = (af_ptr) \ +} + +#define PIN(p_port, p_pin, p_num_af, p_af) \ +{ \ + { &pin_obj_type }, \ + .name = #p_port #p_pin, \ + .port = PORT_ ## p_port, \ + .pin = (p_pin), \ + .num_af = (p_num_af), \ + .pin_mask = (1 << ((p_pin) & 0x0f)), \ + .gpio = GPIO ## p_port, \ + .af = p_af, \ +} -- cgit v1.2.3