summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/uart.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-05-27 16:51:04 +0100
committerDamien George <damien.p.george@gmail.com>2015-05-27 16:51:04 +0100
commit1775b65e07fae808dc50f9cee2005608cd3a26de (patch)
tree128a45e0be3e09165980c94bfe3614309123077b /stmhal/uart.c
parent9ae3fc65235303322ef5282d3cdd4ca99a2c37cc (diff)
downloadmicropython-1775b65e07fae808dc50f9cee2005608cd3a26de.tar.gz
micropython-1775b65e07fae808dc50f9cee2005608cd3a26de.zip
stmhal: Remove PYBVxx defines and use config vars for UART/CAN names.
Now all stmhal-based boards can name their peripherals (if they want) to any string.
Diffstat (limited to 'stmhal/uart.c')
-rw-r--r--stmhal/uart.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/stmhal/uart.c b/stmhal/uart.c
index 676ccee48f..e1357b1f64 100644
--- a/stmhal/uart.c
+++ b/stmhal/uart.c
@@ -504,16 +504,30 @@ STATIC mp_obj_t pyb_uart_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t
if (MP_OBJ_IS_STR(args[0])) {
const char *port = mp_obj_str_get_str(args[0]);
if (0) {
-#if defined(PYBV10)
- } else if (strcmp(port, "XA") == 0) {
- uart_id = PYB_UART_XA;
- } else if (strcmp(port, "XB") == 0) {
- uart_id = PYB_UART_XB;
- } else if (strcmp(port, "YA") == 0) {
- uart_id = PYB_UART_YA;
- } else if (strcmp(port, "YB") == 0) {
- uart_id = PYB_UART_YB;
-#endif
+ #ifdef MICROPY_HW_UART1_NAME
+ } else if (strcmp(port, MICROPY_HW_UART1_NAME) == 0) {
+ uart_id = PYB_UART_1;
+ #endif
+ #ifdef MICROPY_HW_UART2_NAME
+ } else if (strcmp(port, MICROPY_HW_UART2_NAME) == 0) {
+ uart_id = PYB_UART_2;
+ #endif
+ #ifdef MICROPY_HW_UART3_NAME
+ } else if (strcmp(port, MICROPY_HW_UART3_NAME) == 0) {
+ uart_id = PYB_UART_3;
+ #endif
+ #ifdef MICROPY_HW_UART4_NAME
+ } else if (strcmp(port, MICROPY_HW_UART4_NAME) == 0) {
+ uart_id = PYB_UART_4;
+ #endif
+ #ifdef MICROPY_HW_UART5_NAME
+ } else if (strcmp(port, MICROPY_HW_UART5_NAME) == 0) {
+ uart_id = PYB_UART_5;
+ #endif
+ #ifdef MICROPY_HW_UART6_NAME
+ } else if (strcmp(port, MICROPY_HW_UART6_NAME) == 0) {
+ uart_id = PYB_UART_6;
+ #endif
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "UART(%s) does not exist", port));
}