supported STM32
Fork of mbed-rpc by
Diff: parse_pins.cpp
- Revision:
- 12:ac3570c18083
- Parent:
- 5:4490a0d9cb2a
--- a/parse_pins.cpp Mon Aug 19 18:37:40 2013 +0300 +++ b/parse_pins.cpp Fri Feb 19 20:37:14 2016 +0000 @@ -18,67 +18,30 @@ namespace mbed { PinName parse_pins(const char *str) { -#if defined(TARGET_LPC1768) || defined(TARGET_LPC11U24) || defined(TARGET_LPC2368) - static const PinName pin_names[] = {p5, p6, p7, p8, p9, p10, p11, p12, p13, p14 - , p15, p16, p17, p18, p19, p20, p21, p22, p23 - , p24, p25, p26, p27, p28, p29, p30}; -#elif defined(TARGET_LPC1114) - static const PinName pin_names[] = {dp1, dp2, dp4, dp5, dp6, dp9, dp10, dp11 - , dp13, dp14, dp15, dp16, dp17, dp18, dp23 - , dp24, dp25, dp26, dp27, dp28}; -#elif defined(TARGET_LPC4088) - static const PinName pin_names[] = {p5, p6, p7, p8, p9, p10, p11, p12, p13, p14 - , p15, p16, p17, p18, p19, p20, NC, NC, p23 - , p24, p25, p26, p27, p28, p29, p30, p31, p32 - , p33, p34, NC, NC, p37, p38, p39}; -#endif -#if defined(TARGET_LPC1768) || defined(TARGET_LPC11U24) || defined(TARGET_LPC2368) || defined(TARGET_LPC812) || defined(TARGET_LPC4088)|| defined(TARGET_LPC1114) - if (str[0] == 'P') { // Pn_n - uint32_t port = str[1] - '0'; - uint32_t pin = str[3] - '0'; // Pn_n - uint32_t pin2 = str[4] - '0'; // Pn_nn + static const PinName pin_digital[] = {D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15}; + static const PinName pin_analog[] = {A0, A1, A2, A3, A4, A5}; + + if (str[0] == 'D') { // Dn + uint32_t pin = str[1] - '0'; // Dn + uint32_t pin2 = str[2] - '0'; // Dnn if (pin2 <= 9) { pin = pin * 10 + pin2; } - return port_pin((PortName)port, pin); - -#elif defined(TARGET_KL25Z) - if (str[0] == 'P' && str[1] == 'T') { // PTx_n - uint32_t port = str[2] - 'A'; - uint32_t pin = str[3] - '0'; // PTxn - uint32_t pin2 = str[4] - '0'; // PTxnn - - if (pin2 <= 9) { - pin = pin * 10 + pin2; - } - return port_pin((PortName)port, pin); -#endif - -#if defined(TARGET_LPC1768) || defined(TARGET_LPC11U24) || defined(TARGET_LPC2368) - } else if (str[0] == 'p') { // pn - uint32_t pin = str[1] - '0'; // pn - uint32_t pin2 = str[2] - '0'; // pnn + if (pin < 0 || pin > 15) { + return NC; + } + return pin_digital[pin]; + } else if (str[0] == 'A') { // An + uint32_t pin = str[1] - '0'; // An + uint32_t pin2 = str[2] - '0'; // Ann if (pin2 <= 9) { pin = pin * 10 + pin2; } - if (pin < 5 || pin > 30) { + if (pin < 0 || pin > 5) { return NC; } - return pin_names[pin - 5]; -#elif defined(TARGET_LPC4088) - } else if (str[0] == 'p') { // pn - uint32_t pin = str[1] - '0'; // pn - uint32_t pin2 = str[2] - '0'; // pnn - if (pin2 <= 9) { - pin = pin * 10 + pin2; - } - if (pin < 5 || pin > 39) { - return NC; - } - return pin_names[pin - 5]; -#endif - + return pin_analog[pin]; } else if (str[0] == 'L') { // LEDn switch (str[3]) { case '1' : return LED1;