summaryrefslogtreecommitdiffstats
path: root/drivers/chibios/serial_usart.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/chibios/serial_usart.h')
-rw-r--r--drivers/chibios/serial_usart.h40
1 files changed, 33 insertions, 7 deletions
diff --git a/drivers/chibios/serial_usart.h b/drivers/chibios/serial_usart.h
index fee7b4d159..c64e15566f 100644
--- a/drivers/chibios/serial_usart.h
+++ b/drivers/chibios/serial_usart.h
@@ -23,19 +23,45 @@
#include <ch.h>
#include <hal.h>
-#ifndef USART_CR1_M0
+#if !defined(SERIAL_USART_DRIVER)
+# define SERIAL_USART_DRIVER SD1
+#endif
+
+#if !defined(USE_GPIOV1)
+/* The default PAL alternate modes are used to signal that the pins are used for USART. */
+# if !defined(SERIAL_USART_TX_PAL_MODE)
+# define SERIAL_USART_TX_PAL_MODE 7
+# endif
+# if !defined(SERIAL_USART_RX_PAL_MODE)
+# define SERIAL_USART_RX_PAL_MODE 7
+# endif
+#endif
+
+#if defined(SOFT_SERIAL_PIN)
+# define SERIAL_USART_TX_PIN SOFT_SERIAL_PIN
+#endif
+
+#if !defined(SERIAL_USART_TX_PIN)
+# define SERIAL_USART_TX_PIN A9
+#endif
+
+#if !defined(SERIAL_USART_RX_PIN)
+# define SERIAL_USART_RX_PIN A10
+#endif
+
+#if !defined(USART_CR1_M0)
# define USART_CR1_M0 USART_CR1_M // some platforms (f1xx) dont have this so
#endif
-#ifndef SERIAL_USART_CR1
+#if !defined(SERIAL_USART_CR1)
# define SERIAL_USART_CR1 (USART_CR1_PCE | USART_CR1_PS | USART_CR1_M0) // parity enable, odd parity, 9 bit length
#endif
-#ifndef SERIAL_USART_CR2
+#if !defined(SERIAL_USART_CR2)
# define SERIAL_USART_CR2 (USART_CR2_STOP_1) // 2 stop bits
#endif
-#ifndef SERIAL_USART_CR3
+#if !defined(SERIAL_USART_CR3)
# define SERIAL_USART_CR3 0
#endif
@@ -61,11 +87,11 @@
} while (0)
#endif
-#ifndef SELECT_SOFT_SERIAL_SPEED
+#if !defined(SELECT_SOFT_SERIAL_SPEED)
# define SELECT_SOFT_SERIAL_SPEED 1
#endif
-#ifdef SERIAL_USART_SPEED
+#if defined(SERIAL_USART_SPEED)
// Allow advanced users to directly set SERIAL_USART_SPEED
#elif SELECT_SOFT_SERIAL_SPEED == 0
# define SERIAL_USART_SPEED 460800
@@ -83,7 +109,7 @@
# error invalid SELECT_SOFT_SERIAL_SPEED value
#endif
-#ifndef SERIAL_USART_TIMEOUT
+#if !defined(SERIAL_USART_TIMEOUT)
# define SERIAL_USART_TIMEOUT 100
#endif