From 4a53794f1afbb9951bd87f413c64614d1006294c Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Sun, 3 Jun 2012 02:48:57 -0400 Subject: : Add feature test macros for SPI. Signed-off-by: Marti Bolivar --- wirish/include/wirish/boards.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'wirish') diff --git a/wirish/include/wirish/boards.h b/wirish/include/wirish/boards.h index 2da252d..69e8882 100644 --- a/wirish/include/wirish/boards.h +++ b/wirish/include/wirish/boards.h @@ -117,8 +117,9 @@ bool boardUsesPin(uint8 pin); /** * @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. + * BOARD_HAVE_USART(n) is nonzero iff USARTn is available (n must be + * an integer literal, 1 through 6). 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)) @@ -135,4 +136,21 @@ bool boardUsesPin(uint8 pin); /** Feature test: nonzero iff the board has USART6, 0 otherwise. */ #define BOARD_HAVE_USART6 BOARD_HAVE_USART(6) +/** + * @brief Does the board break out a SPI peripheral's pins? + * + * BOARD_HAVE_SPI(n) is nonzero iff SPIn is available (n must be an + * integer literal: 1, 2, or 3). Also see BOARD_HAVE_SPI1, + * BOARD_HAVE_SPI2, BOARD_HAVE_SPI3. */ +#define BOARD_HAVE_SPI(n) (defined(BOARD_SPI##n##_NSS_PIN) && \ + defined(BOARD_SPI##n##_SCK_PIN) && \ + defined(BOARD_SPI##n##_MISO_PIN) && \ + defined(BOARD_SPI##n##_MOSI_PIN)) +/** Feature test: nonzero iff the board has SPI1. */ +#define BOARD_HAVE_SPI1 BOARD_HAVE_SPI(1) +/** Feature test: nonzero iff the board has SPI2. */ +#define BOARD_HAVE_SPI2 BOARD_HAVE_SPI(2) +/** Feature test: nonzero iff the board has SPI3. */ +#define BOARD_HAVE_SPI3 BOARD_HAVE_SPI(3) + #endif -- cgit v1.2.3