aboutsummaryrefslogtreecommitdiffstats
path: root/wirish
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2012-06-01 17:26:03 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2012-06-01 17:26:03 -0400
commit66876d1883055bccae9ae5e73fb3c5d29cb2b453 (patch)
tree555275f97ed04efdf2524a8c2d27d08a9f9ad394 /wirish
parentd4d924ccda26083f4495661ee1fd1b6e549626d7 (diff)
downloadlibrambutan-66876d1883055bccae9ae5e73fb3c5d29cb2b453.tar.gz
librambutan-66876d1883055bccae9ae5e73fb3c5d29cb2b453.zip
Preprocessor-fu to derive BOARD_HAVE_USARTn from <board/board.h>.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'wirish')
-rw-r--r--wirish/boards/VLDiscovery/include/board/board.h6
-rw-r--r--wirish/boards/maple/include/board/board.h9
-rw-r--r--wirish/boards/maple_RET6/include/board/board.h6
-rw-r--r--wirish/boards/maple_mini/include/board/board.h6
-rw-r--r--wirish/boards/maple_native/include/board/board.h6
-rw-r--r--wirish/boards/olimex_stm32_h103/include/board/board.h6
-rw-r--r--wirish/boards/st_stm3220g_eval/include/board/board.h6
-rw-r--r--wirish/include/wirish/boards.h21
8 files changed, 22 insertions, 44 deletions
diff --git a/wirish/boards/VLDiscovery/include/board/board.h b/wirish/boards/VLDiscovery/include/board/board.h
index c54abc1..04d21c7 100644
--- a/wirish/boards/VLDiscovery/include/board/board.h
+++ b/wirish/boards/VLDiscovery/include/board/board.h
@@ -45,12 +45,6 @@
/* Number of USARTs/UARTs whose pins are broken out to headers */
#define BOARD_NR_USARTS 3
-#define BOARD_HAVE_USART1 1
-#define BOARD_HAVE_USART2 1
-#define BOARD_HAVE_USART3 1
-#define BOARD_HAVE_UART4 0
-#define BOARD_HAVE_UART5 0
-#define BOARD_HAVE_USART6 0
/* Default USART pin numbers (not considering AFIO remap) */
#define BOARD_USART1_TX_PIN 7
diff --git a/wirish/boards/maple/include/board/board.h b/wirish/boards/maple/include/board/board.h
index ed89fee..9319989 100644
--- a/wirish/boards/maple/include/board/board.h
+++ b/wirish/boards/maple/include/board/board.h
@@ -39,15 +39,8 @@
#define BOARD_BUTTON_PIN 38
#define BOARD_LED_PIN 13
-/* Number of USARTs/UARTs whose pins are broken out to headers, and
- * macros saying which ones they are. */
+/* Number of USARTs/UARTs whose pins are broken out to headers. */
#define BOARD_NR_USARTS 3
-#define BOARD_HAVE_USART1 1
-#define BOARD_HAVE_USART2 1
-#define BOARD_HAVE_USART3 1
-#define BOARD_HAVE_UART4 0
-#define BOARD_HAVE_UART5 0
-#define BOARD_HAVE_USART6 0
/* Default USART pin numbers (not considering AFIO remap) */
#define BOARD_USART1_TX_PIN 7
diff --git a/wirish/boards/maple_RET6/include/board/board.h b/wirish/boards/maple_RET6/include/board/board.h
index 3291498..05b9031 100644
--- a/wirish/boards/maple_RET6/include/board/board.h
+++ b/wirish/boards/maple_RET6/include/board/board.h
@@ -44,12 +44,6 @@
/* UART4 and UART5 have pins which aren't broken out :( */
#define BOARD_NR_USARTS 3
-#define BOARD_HAVE_USART1 1
-#define BOARD_HAVE_USART2 1
-#define BOARD_HAVE_USART3 1
-#define BOARD_HAVE_UART4 0
-#define BOARD_HAVE_UART5 0
-#define BOARD_HAVE_USART6 0
#define BOARD_USART1_TX_PIN 7
#define BOARD_USART1_RX_PIN 8
#define BOARD_USART2_TX_PIN 1
diff --git a/wirish/boards/maple_mini/include/board/board.h b/wirish/boards/maple_mini/include/board/board.h
index 8ba91ce..bfba46d 100644
--- a/wirish/boards/maple_mini/include/board/board.h
+++ b/wirish/boards/maple_mini/include/board/board.h
@@ -43,12 +43,6 @@
#define BOARD_LED_PIN 33
#define BOARD_NR_USARTS 3
-#define BOARD_HAVE_USART1 1
-#define BOARD_HAVE_USART2 1
-#define BOARD_HAVE_USART3 1
-#define BOARD_HAVE_UART4 0
-#define BOARD_HAVE_UART5 0
-#define BOARD_HAVE_USART6 0
#define BOARD_USART1_TX_PIN 26
#define BOARD_USART1_RX_PIN 25
#define BOARD_USART2_TX_PIN 9
diff --git a/wirish/boards/maple_native/include/board/board.h b/wirish/boards/maple_native/include/board/board.h
index a4f8896..397afaf 100644
--- a/wirish/boards/maple_native/include/board/board.h
+++ b/wirish/boards/maple_native/include/board/board.h
@@ -43,12 +43,6 @@
#define BOARD_BUTTON_PIN 6
#define BOARD_NR_USARTS 5
-#define BOARD_HAVE_USART1 1
-#define BOARD_HAVE_USART2 1
-#define BOARD_HAVE_USART3 1
-#define BOARD_HAVE_UART4 1
-#define BOARD_HAVE_UART5 1
-#define BOARD_HAVE_USART6 0
#define BOARD_USART1_TX_PIN 24
#define BOARD_USART1_RX_PIN 25
#define BOARD_USART2_TX_PIN 50
diff --git a/wirish/boards/olimex_stm32_h103/include/board/board.h b/wirish/boards/olimex_stm32_h103/include/board/board.h
index 46367ac..b312e26 100644
--- a/wirish/boards/olimex_stm32_h103/include/board/board.h
+++ b/wirish/boards/olimex_stm32_h103/include/board/board.h
@@ -42,12 +42,6 @@
/* Number of USARTs/UARTs whose pins are broken out to headers */
#define BOARD_NR_USARTS 3
-#define BOARD_HAVE_USART1 1
-#define BOARD_HAVE_USART2 1
-#define BOARD_HAVE_USART3 1
-#define BOARD_HAVE_UART4 0
-#define BOARD_HAVE_UART5 0
-#define BOARD_HAVE_USART6 0
/* Default USART pin numbers (not considering AFIO remap) */
#define BOARD_USART1_TX_PIN 3
diff --git a/wirish/boards/st_stm3220g_eval/include/board/board.h b/wirish/boards/st_stm3220g_eval/include/board/board.h
index f99a585..fe9658a 100644
--- a/wirish/boards/st_stm3220g_eval/include/board/board.h
+++ b/wirish/boards/st_stm3220g_eval/include/board/board.h
@@ -44,12 +44,6 @@
#define BOARD_LED_PIN 0
#define BOARD_NR_USARTS 0
-#define BOARD_HAVE_USART1 0
-#define BOARD_HAVE_USART2 0
-#define BOARD_HAVE_USART3 0
-#define BOARD_HAVE_UART4 0
-#define BOARD_HAVE_UART5 0
-#define BOARD_HAVE_USART6 0
#define BOARD_NR_SPI 0
#define BOARD_NR_GPIO_PINS 6
#define BOARD_NR_PWM_PINS 0
diff --git a/wirish/include/wirish/boards.h b/wirish/include/wirish/boards.h
index 3c2740a..2da252d 100644
--- a/wirish/include/wirish/boards.h
+++ b/wirish/include/wirish/boards.h
@@ -114,4 +114,25 @@ bool boardUsesPin(uint8 pin);
#define CLOCK_SPEED_MHZ CYCLES_PER_MICROSECOND
#define CLOCK_SPEED_HZ (CLOCK_SPEED_MHZ * 1000000UL)
+/**
+ * @brief Does the board break out a USART/UART's RX and TX pins?
+ *
+ * BOARD_HAVE_USART(n) is nonzero iff USARTn is available. Also see
+ * BOARD_HAVE_USART1, ..., BOARD_HAVE_UART4 (sic), etc.
+ */
+#define BOARD_HAVE_USART(n) (defined(BOARD_USART##n##_TX_PIN) && \
+ defined(BOARD_USART##n##_RX_PIN))
+/** Feature test: nonzero iff the board has USART1. */
+#define BOARD_HAVE_USART1 BOARD_HAVE_USART(1)
+/** Feature test: nonzero iff the board has USART2, 0 otherwise. */
+#define BOARD_HAVE_USART2 BOARD_HAVE_USART(2)
+/** Feature test: nonzero iff the board has USART3, 0 otherwise. */
+#define BOARD_HAVE_USART3 BOARD_HAVE_USART(3)
+/** Feature test: nonzero iff the board has UART4, 0 otherwise. */
+#define BOARD_HAVE_UART4 BOARD_HAVE_USART(4)
+/** Feature test: nonzero iff the board has UART5, 0 otherwise. */
+#define BOARD_HAVE_UART5 BOARD_HAVE_USART(5)
+/** Feature test: nonzero iff the board has USART6, 0 otherwise. */
+#define BOARD_HAVE_USART6 BOARD_HAVE_USART(6)
+
#endif