utzig commented on a change in pull request #2610:
URL: https://github.com/apache/mynewt-core/pull/2610#discussion_r642969547



##########
File path: hw/mcu/nxp/kinetis/src/hal_lpuart.c
##########
@@ -70,25 +70,112 @@ struct hal_uart {
 };
 
 /* UART configurations */
-static struct hal_uart uarts[FSL_FEATURE_SOC_LPUART_COUNT];
+#define UART_CNT (((uint8_t)(MYNEWT_VAL(UART_0) != 0)) + \
+                  ((uint8_t)(MYNEWT_VAL(UART_1) != 0)) + \
+                  ((uint8_t)(MYNEWT_VAL(UART_2) != 0)) + \
+                  ((uint8_t)(MYNEWT_VAL(UART_3) != 0)) + \
+                  ((uint8_t)(MYNEWT_VAL(UART_4) != 0)))
+
+static struct hal_uart uarts[UART_CNT];
+static struct hal_uart *
+uart_by_port(int port)
+{
+    int index;
+
+    (void)index;
+    (void)uarts;
+
+    index = 0;
+#if MYNEWT_VAL(UART_0)
+    if (port == 0) {
+        return &uarts[index];
+    }
+    index++;
+#endif
+#if MYNEWT_VAL(UART_1)
+    if (port == 1) {
+        return &uarts[index];
+    }
+    index++;
+#endif
+#if MYNEWT_VAL(UART_2)
+#   if FSL_FEATURE_SOC_LPUART_COUNT < 3
+#   error "UART_2 is not supported on this MCU"
+#   endif
+    if (port == 2) {
+        return &uarts[index];
+    }
+    index++;
+#endif
+#if MYNEWT_VAL(UART_3)
+#   if FSL_FEATURE_SOC_LPUART_COUNT < 4
+#   error "UART_3 is not supported on this MCU"

Review comment:
       I am not sure I get what you mean exactly, but I added an extra indent 
to the `error ...` line, although it looks weird to me.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to