From cfa40d28d195be98569f52efb30c247f7427240c Mon Sep 17 00:00:00 2001 From: Hussam Al-Hertani Date: Thu, 3 Mar 2016 22:52:11 -0500 Subject: [PATCH 1/4] Enable rpc library usage on the Nucleo_F072 & Nucleo_F411RE boards Adding additional 'defined' statements to line 62 of parse_pins.cpp should in theory enable the rpc libraries for all other Nucleo boards, since all stm32 parts use the same pin labeling scheme i.e. P(port)_pinNumber e.g. PA_3, PC_15 e.t.c. --- libraries/rpc/parse_pins.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/libraries/rpc/parse_pins.cpp b/libraries/rpc/parse_pins.cpp index 2887749b577..af7230e9801 100644 --- a/libraries/rpc/parse_pins.cpp +++ b/libraries/rpc/parse_pins.cpp @@ -49,7 +49,7 @@ PinName parse_pins(const char *str) { return port_pin((PortName)port, pin); #elif defined(TARGET_KL25Z) || defined(TARGET_KL05Z) || defined(TARGET_KL46Z) || defined(TARGET_K64F) - if (str[0] == 'P' && str[1] == 'T') { // PTxn + if (str[0] == 'P' && str[1] == 'T') { // PTxn uint32_t port = str[2] - 'A'; uint32_t pin = str[3] - '0'; // PTxn uint32_t pin2 = str[4] - '0'; // PTxnn @@ -58,8 +58,22 @@ PinName parse_pins(const char *str) { pin = pin * 10 + pin2; } return port_pin((PortName)port, pin); + +#elif defined(TARGET_NUCLEO_F072RB) || defined(TARGET_NUCLEO_F411RE) + if (str[0] == 'P') { // PX_XX e.g.PA_2 PC_15 + uint32_t port = str[1] - 'A'; + uint32_t pin = str[3] - '0'; + uint32_t pin2 = str[4] - '0'; + + 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 @@ -83,7 +97,6 @@ PinName parse_pins(const char *str) { } return pin_names[pin - 1]; #endif - } else if (str[0] == 'L') { // LEDn switch (str[3]) { case '1' : return LED1; @@ -101,5 +114,6 @@ PinName parse_pins(const char *str) { return NC; } - } + + From 00554f7e1138d5ea3f5c5740211b16ca23a2959b Mon Sep 17 00:00:00 2001 From: halherta Date: Sat, 5 Mar 2016 01:02:44 -0500 Subject: [PATCH 2/4] fixed tab spacing on line 52 --- libraries/rpc/parse_pins.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/rpc/parse_pins.cpp b/libraries/rpc/parse_pins.cpp index af7230e9801..6bd77ac5b70 100644 --- a/libraries/rpc/parse_pins.cpp +++ b/libraries/rpc/parse_pins.cpp @@ -49,7 +49,7 @@ PinName parse_pins(const char *str) { return port_pin((PortName)port, pin); #elif defined(TARGET_KL25Z) || defined(TARGET_KL05Z) || defined(TARGET_KL46Z) || defined(TARGET_K64F) - if (str[0] == 'P' && str[1] == 'T') { // PTxn + if (str[0] == 'P' && str[1] == 'T') { // PTxn uint32_t port = str[2] - 'A'; uint32_t pin = str[3] - '0'; // PTxn uint32_t pin2 = str[4] - '0'; // PTxnn @@ -60,7 +60,7 @@ PinName parse_pins(const char *str) { return port_pin((PortName)port, pin); #elif defined(TARGET_NUCLEO_F072RB) || defined(TARGET_NUCLEO_F411RE) - if (str[0] == 'P') { // PX_XX e.g.PA_2 PC_15 + if (str[0] == 'P') { // PX_XX e.g.PA_2 PC_15 uint32_t port = str[1] - 'A'; uint32_t pin = str[3] - '0'; uint32_t pin2 = str[4] - '0'; From 73ba74b87f7b3984f12c761ae0df62474a293a8a Mon Sep 17 00:00:00 2001 From: halherta Date: Mon, 7 Mar 2016 06:26:58 -0500 Subject: [PATCH 3/4] Hoprfully this fixes the tabbing issue --- libraries/rpc/parse_pins.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/rpc/parse_pins.cpp b/libraries/rpc/parse_pins.cpp index 6bd77ac5b70..6dd7de182db 100644 --- a/libraries/rpc/parse_pins.cpp +++ b/libraries/rpc/parse_pins.cpp @@ -49,7 +49,7 @@ PinName parse_pins(const char *str) { return port_pin((PortName)port, pin); #elif defined(TARGET_KL25Z) || defined(TARGET_KL05Z) || defined(TARGET_KL46Z) || defined(TARGET_K64F) - if (str[0] == 'P' && str[1] == 'T') { // PTxn + if (str[0] == 'P' && str[1] == 'T') { // PTxn uint32_t port = str[2] - 'A'; uint32_t pin = str[3] - '0'; // PTxn uint32_t pin2 = str[4] - '0'; // PTxnn @@ -60,7 +60,7 @@ PinName parse_pins(const char *str) { return port_pin((PortName)port, pin); #elif defined(TARGET_NUCLEO_F072RB) || defined(TARGET_NUCLEO_F411RE) - if (str[0] == 'P') { // PX_XX e.g.PA_2 PC_15 + if (str[0] == 'P') { // PX_XX e.g.PA_2 PC_15 uint32_t port = str[1] - 'A'; uint32_t pin = str[3] - '0'; uint32_t pin2 = str[4] - '0'; From b80ec93ba2e8a9dcef645b53b74a61d122908702 Mon Sep 17 00:00:00 2001 From: Hussam Al-Hertani Date: Thu, 3 Mar 2016 22:52:11 -0500 Subject: [PATCH 4/4] Enable rpc library usage on the Nucleo_F072 & Nucleo_F411RE boards Adding additional 'defined' statements to line 62 of parse_pins.cpp should in theory enable the rpc libraries for all other Nucleo boards, since all stm32 parts use the same pin labeling scheme i.e. P(port)_pinNumber e.g. PA_3, PC_15 e.t.c. fixed tab spacing on line 52 Hopefully this fixes the tabbing issue --- libraries/rpc/parse_pins.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/libraries/rpc/parse_pins.cpp b/libraries/rpc/parse_pins.cpp index 2887749b577..6dd7de182db 100644 --- a/libraries/rpc/parse_pins.cpp +++ b/libraries/rpc/parse_pins.cpp @@ -58,8 +58,22 @@ PinName parse_pins(const char *str) { pin = pin * 10 + pin2; } return port_pin((PortName)port, pin); + +#elif defined(TARGET_NUCLEO_F072RB) || defined(TARGET_NUCLEO_F411RE) + if (str[0] == 'P') { // PX_XX e.g.PA_2 PC_15 + uint32_t port = str[1] - 'A'; + uint32_t pin = str[3] - '0'; + uint32_t pin2 = str[4] - '0'; + + 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 @@ -83,7 +97,6 @@ PinName parse_pins(const char *str) { } return pin_names[pin - 1]; #endif - } else if (str[0] == 'L') { // LEDn switch (str[3]) { case '1' : return LED1; @@ -101,5 +114,6 @@ PinName parse_pins(const char *str) { return NC; } - } + +