summaryrefslogtreecommitdiffstatshomepage
path: root/stm/boards/stm32f4xx-prefix.c
diff options
context:
space:
mode:
authorDave Hylands <dhylands@gmail.com>2014-02-17 17:57:13 -0800
committerDave Hylands <dhylands@gmail.com>2014-02-17 21:20:38 -0800
commit51dabac0961165cd38cdd0ba227aaf014190091c (patch)
tree48b8d13742ed402b9e37f8b42bc19b4dffa32da9 /stm/boards/stm32f4xx-prefix.c
parent46239413d033a25662700ba39a97b07737b820fc (diff)
downloadmicropython-51dabac0961165cd38cdd0ba227aaf014190091c.tar.gz
micropython-51dabac0961165cd38cdd0ba227aaf014190091c.zip
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.
Diffstat (limited to 'stm/boards/stm32f4xx-prefix.c')
-rw-r--r--stm/boards/stm32f4xx-prefix.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/stm/boards/stm32f4xx-prefix.c b/stm/boards/stm32f4xx-prefix.c
new file mode 100644
index 0000000000..e68de4cf4e
--- /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 <stdio.h>
+#include <stdint.h>
+#include <stm32f4xx.h>
+
+#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, \
+}