Fork of Smoothie to port to mbed non-LPC targets.
Fork of Smoothie by
libs/Targets/TARGET_NUCLEO_F103RB/Target.cpp@3:f151d08d335c, 2014-03-02 (annotated)
- Committer:
- Bigcheese
- Date:
- Sun Mar 02 06:33:08 2014 +0000
- Revision:
- 3:f151d08d335c
Bunch of stuff. Need to locally merge in updated USB changes.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Bigcheese | 3:f151d08d335c | 1 | #include "../Target.h" |
Bigcheese | 3:f151d08d335c | 2 | |
Bigcheese | 3:f151d08d335c | 3 | #include "PinNames.h" |
Bigcheese | 3:f151d08d335c | 4 | |
Bigcheese | 3:f151d08d335c | 5 | #include <stdlib.h> |
Bigcheese | 3:f151d08d335c | 6 | |
Bigcheese | 3:f151d08d335c | 7 | static PinName pin_map[4][16] = { |
Bigcheese | 3:f151d08d335c | 8 | {PA_0, PA_1, PA_2, PA_3, PA_4, PA_5, PA_6, PA_7, PA_8, PA_9, PA_10, PA_11, PA_12, PA_13, PA_14, PA_15}, |
Bigcheese | 3:f151d08d335c | 9 | {PB_0, PB_1, PB_2, PB_3, PB_4, PB_5, PB_6, PB_7, PB_8, PB_9, PB_10, PB_11, PB_12, PB_13, PB_14, PB_15}, |
Bigcheese | 3:f151d08d335c | 10 | {PC_0, PC_1, PC_2, PC_3, PC_4, PC_5, PC_6, PC_7, PC_8, PC_9, PC_10, PC_11, PC_12, PC_13, PC_14, PC_15}, |
Bigcheese | 3:f151d08d335c | 11 | {PD_0, PD_1, PD_2, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC} |
Bigcheese | 3:f151d08d335c | 12 | }; |
Bigcheese | 3:f151d08d335c | 13 | |
Bigcheese | 3:f151d08d335c | 14 | // STM Nucleo pins are in the form of <PORT>.<PIN> where PORT = [A-D] |
Bigcheese | 3:f151d08d335c | 15 | // and PIN = [1-15]. Port D only has 3 pins. |
Bigcheese | 3:f151d08d335c | 16 | PinName pin_name_from_string(std::string str) { |
Bigcheese | 3:f151d08d335c | 17 | if (str.size() < 3) |
Bigcheese | 3:f151d08d335c | 18 | return NC; |
Bigcheese | 3:f151d08d335c | 19 | unsigned port = str[0]; |
Bigcheese | 3:f151d08d335c | 20 | port -= 'A'; |
Bigcheese | 3:f151d08d335c | 21 | if (port > 3) |
Bigcheese | 3:f151d08d335c | 22 | return NC; |
Bigcheese | 3:f151d08d335c | 23 | if (str[1] != '.') |
Bigcheese | 3:f151d08d335c | 24 | return NC; |
Bigcheese | 3:f151d08d335c | 25 | unsigned long pin = strtoul(str.data() + 2, NULL, 10); |
Bigcheese | 3:f151d08d335c | 26 | if (pin > 15) |
Bigcheese | 3:f151d08d335c | 27 | return NC; |
Bigcheese | 3:f151d08d335c | 28 | return pin_map[port][pin]; |
Bigcheese | 3:f151d08d335c | 29 | } |