aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2018-12-08 11:23:21 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2018-12-08 11:23:21 +0000
commitf3249c78d9353bca99172f5cbbc6b7fb0c64c665 (patch)
tree66d4f82230e664021b0999ce97a827660432346f /os/hal
parent53093a74b030cffbb4ebd78adaa4707ea4ecf9db (diff)
downloadChibiOS-f3249c78d9353bca99172f5cbbc6b7fb0c64c665.tar.gz
ChibiOS-f3249c78d9353bca99172f5cbbc6b7fb0c64c665.tar.bz2
ChibiOS-f3249c78d9353bca99172f5cbbc6b7fb0c64c665.zip
LLD drivers organization changes: RTC, SPI.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12463 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'os/hal')
-rw-r--r--os/hal/include/hal_rtc.h2
-rw-r--r--os/hal/include/hal_spi.h105
-rw-r--r--os/hal/ports/STM32/LLD/RTCv1/hal_rtc_lld.h4
-rw-r--r--os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.h4
-rw-r--r--os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.h132
-rw-r--r--os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.h132
-rw-r--r--os/hal/ports/STM32/LLD/SPIv3/hal_spi_lld.h222
-rw-r--r--os/hal/templates/hal_rtc_lld.h4
-rw-r--r--os/hal/templates/hal_spi_lld.h94
9 files changed, 233 insertions, 466 deletions
diff --git a/os/hal/include/hal_rtc.h b/os/hal/include/hal_rtc.h
index 342d61815..e64b036e9 100644
--- a/os/hal/include/hal_rtc.h
+++ b/os/hal/include/hal_rtc.h
@@ -153,7 +153,7 @@ struct RTCDriver {
RTC_DRIVER_EXT_FIELDS
#endif
/* End of the mandatory fields.*/
- _rtc_lld_driver_fields
+ rtc_lld_driver_fields;
};
/*===========================================================================*/
diff --git a/os/hal/include/hal_spi.h b/os/hal/include/hal_spi.h
index a94f5dee7..ab07811c0 100644
--- a/os/hal/include/hal_spi.h
+++ b/os/hal/include/hal_spi.h
@@ -97,6 +97,15 @@
#error "invalid SPI_SELECT_MODE setting"
#endif
+/* Some modes have a dependency on the PAL driver, making the required
+ checks here.*/
+#if ((SPI_SELECT_MODE != SPI_SELECT_MODE_PAD) || \
+ (SPI_SELECT_MODE != SPI_SELECT_MODE_PORT) || \
+ (SPI_SELECT_MODE != SPI_SELECT_MODE_LINE)) && \
+ (HAL_USE_PAL != TRUE)
+#error "current SPI_SELECT_MODE requires HAL_USE_PAL"
+#endif
+
/*===========================================================================*/
/* Driver data structures and types. */
/*===========================================================================*/
@@ -112,13 +121,101 @@ typedef enum {
SPI_COMPLETE = 4 /**< Asynchronous operation complete. */
} spistate_t;
+/**
+ * @brief Type of a structure representing an SPI driver.
+ */
+typedef struct hal_spi_driver SPIDriver;
+/**
+ * @brief Type of a SPI driver configuration structure.
+ */
+typedef struct hal_spi_config SPIConfig;
+
+/**
+ * @brief SPI notification callback type.
+ *
+ * @param[in] spip pointer to the @p SPIDriver object triggering the
+ * callback
+ */
+typedef void (*spicallback_t)(SPIDriver *spip);
+
+/* Including the low level driver header, it exports information required
+ for completing types.*/
#include "hal_spi_lld.h"
-/* Some more checks, must happen after inclusion of the LLD header, this is
- why are placed here.*/
-#if !defined(SPI_SUPPORTS_CIRCULAR)
-#define SPI_SUPPORTS_CIRCULAR FALSE
+/**
+ * @brief Structure representing an SPI driver.
+ */
+struct hal_spi_driver {
+ /**
+ * @brief Driver state.
+ */
+ spistate_t state;
+ /**
+ * @brief Current configuration data.
+ */
+ const SPIConfig *config;
+#if SPI_USE_WAIT || defined(__DOXYGEN__)
+ /**
+ * @brief Waiting thread.
+ */
+ thread_reference_t thread;
+#endif /* SPI_USE_WAIT */
+#if SPI_USE_MUTUAL_EXCLUSION || defined(__DOXYGEN__)
+ /**
+ * @brief Mutex protecting the peripheral.
+ */
+ mutex_t mutex;
+#endif /* SPI_USE_MUTUAL_EXCLUSION */
+#if defined(SPI_DRIVER_EXT_FIELDS)
+ SPI_DRIVER_EXT_FIELDS
+#endif
+ /* End of the mandatory fields.*/
+ spi_lld_driver_fields;
+};
+
+/**
+ * @brief Driver configuration structure.
+ */
+struct hal_spi_config {
+#if (SPI_SUPPORTS_CIRCULAR == TRUE) || defined(__DOXYGEN__)
+ /**
+ * @brief Enables the circular buffer mode.
+ */
+ bool circular;
+#endif
+ /**
+ * @brief Operation complete callback or @p NULL.
+ */
+ spicallback_t end_cb;
+#if (SPI_SELECT_MODE == SPI_SELECT_MODE_LINE) || defined(__DOXYGEN__)
+ /**
+ * @brief The chip select line.
+ */
+ ioline_t ssline;
+#endif
+#if (SPI_SELECT_MODE == SPI_SELECT_MODE_PORT) || defined(__DOXYGEN__)
+ /**
+ * @brief The chip select port.
+ */
+ ioportid_t ssport;
+ /**
+ * @brief The chip select port mask.
+ */
+ ioportmask_t ssmask;
+#endif
+#if (SPI_SELECT_MODE == SPI_SELECT_MODE_PAD) || defined(__DOXYGEN__)
+ /**
+ * @brief The chip select port.
+ */
+ ioportid_t ssport;
+ /**
+ * @brief The chip select pad number.
+ */
+ uint_fast8_t sspad;
#endif
+ /* End of the mandatory fields.*/
+ spi_lld_config_fields;
+};
/*===========================================================================*/
/* Driver macros. */
diff --git a/os/hal/ports/STM32/LLD/RTCv1/hal_rtc_lld.h b/os/hal/ports/STM32/LLD/RTCv1/hal_rtc_lld.h
index 821985158..a784c3918 100644
--- a/os/hal/ports/STM32/LLD/RTCv1/hal_rtc_lld.h
+++ b/os/hal/ports/STM32/LLD/RTCv1/hal_rtc_lld.h
@@ -111,11 +111,11 @@ typedef struct hsl_rtc_alarm {
/**
* @brief Implementation-specific @p RTCDriver fields.
*/
-#define _rtc_lld_driver_fields \
+#define rtc_lld_driver_fields \
/* Pointer to the RTC registers block.*/ \
RTC_TypeDef *rtc; \
/* Callback pointer.*/ \
- rtccb_t callback;
+ rtccb_t callback
/*===========================================================================*/
/* Driver macros. */
diff --git a/os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.h b/os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.h
index cab56c94b..f60e79846 100644
--- a/os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.h
+++ b/os/hal/ports/STM32/LLD/RTCv2/hal_rtc_lld.h
@@ -203,11 +203,11 @@ typedef struct hal_rtc_wakeup {
/**
* @brief Implementation-specific @p RTCDriver fields.
*/
-#define _rtc_lld_driver_fields \
+#define rtc_lld_driver_fields \
/* Pointer to the RTC registers block.*/ \
RTC_TypeDef *rtc; \
/* Callback pointer.*/ \
- rtccb_t callback;
+ rtccb_t callback
/*===========================================================================*/
/* Driver macros. */
diff --git a/os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.h b/os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.h
index 62b9c061c..09a6eec01 100644
--- a/os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.h
+++ b/os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.h
@@ -409,123 +409,33 @@
/* Driver data structures and types. */
/*===========================================================================*/
-/**
- * @brief Type of a structure representing an SPI driver.
- */
-typedef struct SPIDriver SPIDriver;
-
-/**
- * @brief SPI notification callback type.
- *
- * @param[in] spip pointer to the @p SPIDriver object triggering the
- * callback
- */
-typedef void (*spicallback_t)(SPIDriver *spip);
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
/**
- * @brief Driver configuration structure.
+ * @brief Low level fields of the SPI driver structure.
*/
-typedef struct {
-#if (SPI_SUPPORTS_CIRCULAR == TRUE) || defined(__DOXYGEN__)
- /**
- * @brief Enables the circular buffer mode.
- */
- bool circular;
-#endif
- /**
- * @brief Operation complete callback or @p NULL.
- */
- spicallback_t end_cb;
-#if (SPI_SELECT_MODE == SPI_SELECT_MODE_LINE) || defined(__DOXYGEN__)
- /**
- * @brief The chip select line.
- */
- ioline_t ssline;
-#endif
-#if (SPI_SELECT_MODE == SPI_SELECT_MODE_PORT) || defined(__DOXYGEN__)
- /**
- * @brief The chip select port.
- */
- ioportid_t ssport;
- /**
- * @brief The chip select port mask.
- */
- ioportmask_t ssmask;
-#endif
-#if (SPI_SELECT_MODE == SPI_SELECT_MODE_PAD) || defined(__DOXYGEN__)
- /**
- * @brief The chip select port.
- */
- ioportid_t ssport;
- /**
- * @brief The chip select pad number.
- */
- uint_fast8_t sspad;
-#endif
- /* End of the mandatory fields.*/
- /**
- * @brief SPI CR1 register initialization data.
- */
- uint16_t cr1;
- /**
- * @brief SPI CR2 register initialization data.
- */
- uint16_t cr2;
-} SPIConfig;
+#define spi_lld_driver_fields \
+ /* Pointer to the SPIx registers block.*/ \
+ SPI_TypeDef *spi; \
+ /* Receive DMA stream.*/ \
+ const stm32_dma_stream_t *dmarx; \
+ /* Transmit DMA stream.*/ \
+ const stm32_dma_stream_t *dmatx; \
+ /* RX DMA mode bit mask.*/ \
+ uint32_t rxdmamode; \
+ /* TX DMA mode bit mask.*/ \
+ uint32_t txdmamode
/**
- * @brief Structure representing an SPI driver.
+ * @brief Low level fields of the SPI configuration structure.
*/
-struct SPIDriver {
- /**
- * @brief Driver state.
- */
- spistate_t state;
- /**
- * @brief Current configuration data.
- */
- const SPIConfig *config;
-#if SPI_USE_WAIT || defined(__DOXYGEN__)
- /**
- * @brief Waiting thread.
- */
- thread_reference_t thread;
-#endif /* SPI_USE_WAIT */
-#if SPI_USE_MUTUAL_EXCLUSION || defined(__DOXYGEN__)
- /**
- * @brief Mutex protecting the bus.
- */
- mutex_t mutex;
-#endif /* SPI_USE_MUTUAL_EXCLUSION */
-#if defined(SPI_DRIVER_EXT_FIELDS)
- SPI_DRIVER_EXT_FIELDS
-#endif
- /* End of the mandatory fields.*/
- /**
- * @brief Pointer to the SPIx registers block.
- */
- SPI_TypeDef *spi;
- /**
- * @brief Receive DMA stream.
- */
- const stm32_dma_stream_t *dmarx;
- /**
- * @brief Transmit DMA stream.
- */
- const stm32_dma_stream_t *dmatx;
- /**
- * @brief RX DMA mode bit mask.
- */
- uint32_t rxdmamode;
- /**
- * @brief TX DMA mode bit mask.
- */
- uint32_t txdmamode;
-};
-
-/*===========================================================================*/
-/* Driver macros. */
-/*===========================================================================*/
+#define spi_lld_config_fields \
+ /* SPI CR1 register initialization data.*/ \
+ uint16_t cr1; \
+ /* SPI CR2 register initialization data.*/ \
+ uint16_t cr2
/*===========================================================================*/
/* External declarations. */
diff --git a/os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.h b/os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.h
index 66d805937..15f08f84a 100644
--- a/os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.h
+++ b/os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.h
@@ -505,123 +505,33 @@
/* Driver data structures and types. */
/*===========================================================================*/
-/**
- * @brief Type of a structure representing an SPI driver.
- */
-typedef struct SPIDriver SPIDriver;
-
-/**
- * @brief SPI notification callback type.
- *
- * @param[in] spip pointer to the @p SPIDriver object triggering the
- * callback
- */
-typedef void (*spicallback_t)(SPIDriver *spip);
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
/**
- * @brief Driver configuration structure.
+ * @brief Low level fields of the SPI driver structure.
*/
-typedef struct {
-#if (SPI_SUPPORTS_CIRCULAR == TRUE) || defined(__DOXYGEN__)
- /**
- * @brief Enables the circular buffer mode.
- */
- bool circular;
-#endif
- /**
- * @brief Operation complete callback or @p NULL.
- */
- spicallback_t end_cb;
-#if (SPI_SELECT_MODE == SPI_SELECT_MODE_LINE) || defined(__DOXYGEN__)
- /**
- * @brief The chip select line.
- */
- ioline_t ssline;
-#endif
-#if (SPI_SELECT_MODE == SPI_SELECT_MODE_PORT) || defined(__DOXYGEN__)
- /**
- * @brief The chip select port.
- */
- ioportid_t ssport;
- /**
- * @brief The chip select port mask.
- */
- ioportmask_t ssmask;
-#endif
-#if (SPI_SELECT_MODE == SPI_SELECT_MODE_PAD) || defined(__DOXYGEN__)
- /**
- * @brief The chip select port.
- */
- ioportid_t ssport;
- /**
- * @brief The chip select pad number.
- */
- uint_fast8_t sspad;
-#endif
- /* End of the mandatory fields.*/
- /**
- * @brief SPI CR1 register initialization data.
- */
- uint16_t cr1;
- /**
- * @brief SPI CR2 register initialization data.
- */
- uint16_t cr2;
-} SPIConfig;
+#define spi_lld_driver_fields \
+ /* Pointer to the SPIx registers block.*/ \
+ SPI_TypeDef *spi; \
+ /* Receive DMA stream.*/ \
+ const stm32_dma_stream_t *dmarx; \
+ /* Transmit DMA stream.*/ \
+ const stm32_dma_stream_t *dmatx; \
+ /* RX DMA mode bit mask.*/ \
+ uint32_t rxdmamode; \
+ /* TX DMA mode bit mask.*/ \
+ uint32_t txdmamode
/**
- * @brief Structure representing an SPI driver.
+ * @brief Low level fields of the SPI configuration structure.
*/
-struct SPIDriver {
- /**
- * @brief Driver state.
- */
- spistate_t state;
- /**
- * @brief Current configuration data.
- */
- const SPIConfig *config;
-#if SPI_USE_WAIT || defined(__DOXYGEN__)
- /**
- * @brief Waiting thread.
- */
- thread_reference_t thread;
-#endif /* SPI_USE_WAIT */
-#if SPI_USE_MUTUAL_EXCLUSION || defined(__DOXYGEN__)
- /**
- * @brief Mutex protecting the peripheral.
- */
- mutex_t mutex;
-#endif /* SPI_USE_MUTUAL_EXCLUSION */
-#if defined(SPI_DRIVER_EXT_FIELDS)
- SPI_DRIVER_EXT_FIELDS
-#endif
- /* End of the mandatory fields.*/
- /**
- * @brief Pointer to the SPIx registers block.
- */
- SPI_TypeDef *spi;
- /**
- * @brief Receive DMA stream.
- */
- const stm32_dma_stream_t *dmarx;
- /**
- * @brief Transmit DMA stream.
- */
- const stm32_dma_stream_t *dmatx;
- /**
- * @brief RX DMA mode bit mask.
- */
- uint32_t rxdmamode;
- /**
- * @brief TX DMA mode bit mask.
- */
- uint32_t txdmamode;
-};
-
-/*===========================================================================*/
-/* Driver macros. */
-/*===========================================================================*/
+#define spi_lld_config_fields \
+ /* SPI CR1 register initialization data.*/ \
+ uint16_t cr1; \
+ /* SPI CR2 register initialization data.*/ \
+ uint16_t cr2
/*===========================================================================*/
/* External declarations. */
diff --git a/os/hal/ports/STM32/LLD/SPIv3/hal_spi_lld.h b/os/hal/ports/STM32/LLD/SPIv3/hal_spi_lld.h
index 43414a010..26b30f9b0 100644
--- a/os/hal/ports/STM32/LLD/SPIv3/hal_spi_lld.h
+++ b/os/hal/ports/STM32/LLD/SPIv3/hal_spi_lld.h
@@ -504,156 +504,86 @@
/* Driver data structures and types. */
/*===========================================================================*/
-/**
- * @brief Type of a structure representing an SPI driver.
- */
-typedef struct SPIDriver SPIDriver;
-
-/**
- * @brief SPI notification callback type.
- *
- * @param[in] spip pointer to the @p SPIDriver object triggering the
- * callback
- */
-typedef void (*spicallback_t)(SPIDriver *spip);
-
-/**
- * @brief Driver configuration structure.
- */
-typedef struct {
-#if (SPI_SUPPORTS_CIRCULAR == TRUE) || defined(__DOXYGEN__)
- /**
- * @brief Enables the circular buffer mode.
- */
- bool circular;
-#endif
- /**
- * @brief Operation complete callback or @p NULL.
- */
- spicallback_t end_cb;
-#if (SPI_SELECT_MODE == SPI_SELECT_MODE_LINE) || defined(__DOXYGEN__)
- /**
- * @brief The chip select line.
- */
- ioline_t ssline;
-#endif
-#if (SPI_SELECT_MODE == SPI_SELECT_MODE_PORT) || defined(__DOXYGEN__)
- /**
- * @brief The chip select port.
- */
- ioportid_t ssport;
- /**
- * @brief The chip select port mask.
- */
- ioportmask_t ssmask;
-#endif
-#if (SPI_SELECT_MODE == SPI_SELECT_MODE_PAD) || defined(__DOXYGEN__)
- /**
- * @brief The chip select port.
- */
- ioportid_t ssport;
- /**
- * @brief The chip select pad number.
- */
- uint_fast8_t sspad;
-#endif
- /* End of the mandatory fields.*/
- /**
- * @brief SPI CFG1 register initialization data.
- */
- uint32_t cfg1;
- /**
- * @brief SPI CFG2 register initialization data.
- */
- uint32_t cfg2;
-} SPIConfig;
-
-/**
- * @brief Structure representing an SPI driver.
- */
-struct SPIDriver {
- /**
- * @brief Driver state.
- */
- spistate_t state;
- /**
- * @brief Current configuration data.
- */
- const SPIConfig *config;
-#if SPI_USE_WAIT || defined(__DOXYGEN__)
- /**
- * @brief Waiting thread.
- */
- thread_reference_t thread;
-#endif /* SPI_USE_WAIT */
-#if SPI_USE_MUTUAL_EXCLUSION || defined(__DOXYGEN__)
- /**
- * @brief Mutex protecting the peripheral.
- */
- mutex_t mutex;
-#endif /* SPI_USE_MUTUAL_EXCLUSION */
-#if defined(SPI_DRIVER_EXT_FIELDS)
- SPI_DRIVER_EXT_FIELDS
-#endif
- /* End of the mandatory fields.*/
- /**
- * @brief Pointer to the SPIx registers block.
- */
- SPI_TypeDef *spi;
-#if defined(STM32_SPI_DMA_REQUIRED) && defined(STM32_SPI_BDMA_REQUIRED)
- /**
- * @brief DMA type for this instance.
- */
- bool is_bdma;
-#endif
- /**
- * @brief Union of the RX DMA streams.
- */
- union {
-#if defined(STM32_SPI_DMA_REQUIRED) || defined(__DOXYGEN__)
- /**
- * @brief Receive DMA stream.
- */
- const stm32_dma_stream_t *dma;
-#endif
-#if defined(STM32_SPI_BDMA_REQUIRED) || defined(__DOXYGEN__)
- /**
- * @brief Receive BDMA stream.
- */
- const stm32_bdma_stream_t *bdma;
-#endif
- } rx;
- /**
- * @brief Union of the TX DMA streams.
- */
- union {
-#if defined(STM32_SPI_DMA_REQUIRED) || defined(__DOXYGEN__)
- /**
- * @brief Transmit DMA stream.
- */
- const stm32_dma_stream_t *dma;
-#endif
-#if defined(STM32_SPI_BDMA_REQUIRED) || defined(__DOXYGEN__)
- /**
- * @brief Transmit DMA stream.
- */
- const stm32_bdma_stream_t *bdma;
-#endif
- } tx;
- /**
- * @brief RX DMA mode bit mask.
- */
- uint32_t rxdmamode;
- /**
- * @brief TX DMA mode bit mask.
- */
- uint32_t txdmamode;
-};
-
/*===========================================================================*/
/* Driver macros. */
/*===========================================================================*/
+#if (defined(STM32_SPI_DMA_REQUIRED) && defined(STM32_SPI_BDMA_REQUIRED)) ||\
+ defined(__DOXYGEN__)
+#define spi_lld_driver_fields \
+ /* Pointer to the SPIx registers block.*/ \
+ SPI_TypeDef *spi; \
+ /** DMA type for this instance.*/ \
+ bool is_bdma; \
+ /** Union of the RX DMA streams.*/ \
+ union { \
+ /* Receive DMA stream.*/ \
+ const stm32_dma_stream_t *dma; \
+ /* Receive BDMA stream.*/ \
+ const stm32_bdma_stream_t *bdma; \
+ } rx; \
+ /* Union of the TX DMA streams.*/ \
+ union { \
+ /* Transmit DMA stream.*/ \
+ const stm32_dma_stream_t *dma; \
+ /* Transmit DMA stream.*/ \
+ const stm32_bdma_stream_t *bdma; \
+ } tx; \
+ /* RX DMA mode bit mask.*/ \
+ uint32_t rxdmamode; \
+ /* TX DMA mode bit mask.*/ \
+ uint32_t txdmamode
+#endif
+
+#if defined(STM32_SPI_DMA_REQUIRED) && !defined(STM32_SPI_BDMA_REQUIRED)
+#define spi_lld_driver_fields \
+ /* Pointer to the SPIx registers block.*/ \
+ SPI_TypeDef *spi; \
+ /** Union of the RX DMA streams.*/ \
+ union { \
+ /* Receive DMA stream.*/ \
+ const stm32_dma_stream_t *dma; \
+ } rx; \
+ /* Union of the TX DMA streams.*/ \
+ union { \
+ /* Transmit DMA stream.*/ \
+ const stm32_dma_stream_t *dma; \
+ } tx; \
+ /* RX DMA mode bit mask.*/ \
+ uint32_t rxdmamode; \
+ /* TX DMA mode bit mask.*/ \
+ uint32_t txdmamode
+#endif
+
+#if !defined(STM32_SPI_DMA_REQUIRED) && defined(STM32_SPI_BDMA_REQUIRED)
+#define spi_lld_driver_fields \
+ /* Pointer to the SPIx registers block.*/ \
+ SPI_TypeDef *spi; \
+ /** Union of the RX DMA streams.*/ \
+ union { \
+ /* Receive BDMA stream.*/ \
+ const stm32_bdma_stream_t *bdma; \
+ } rx; \
+ /* Union of the TX DMA streams.*/ \
+ union { \
+ /* Transmit DMA stream.*/ \
+ const stm32_bdma_stream_t *bdma; \
+ } tx; \
+ /* RX DMA mode bit mask.*/ \
+ uint32_t rxdmamode; \
+ /* TX DMA mode bit mask.*/ \
+ uint32_t txdmamode
+#endif
+
+/**
+ * @brief Low level fields of the SPI configuration structure.
+ */
+#define spi_lld_config_fields \
+ /* SPI CFG1 register initialization data.*/ \
+ uint32_t cfg1; \
+ /* SPI CFG2 register initialization data.*/ \
+ uint32_t cfg2
+
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/
diff --git a/os/hal/templates/hal_rtc_lld.h b/os/hal/templates/hal_rtc_lld.h
index 40ca8b1ef..be988cf03 100644
--- a/os/hal/templates/hal_rtc_lld.h
+++ b/os/hal/templates/hal_rtc_lld.h
@@ -105,8 +105,8 @@ typedef struct {
/**
* @brief Implementation-specific @p RTCDriver fields.
*/
-#define _rtc_lld_driver_fields \
- uint32_t dummy;
+#define rtc_lld_driver_fields \
+ uint32_t dummy
/*===========================================================================*/
/* Driver macros. */
diff --git a/os/hal/templates/hal_spi_lld.h b/os/hal/templates/hal_spi_lld.h
index e939c3955..ad3939c9b 100644
--- a/os/hal/templates/hal_spi_lld.h
+++ b/os/hal/templates/hal_spi_lld.h
@@ -62,99 +62,19 @@
/* Driver data structures and types. */
/*===========================================================================*/
-/**
- * @brief Type of a structure representing an SPI driver.
- */
-typedef struct SPIDriver SPIDriver;
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
/**
- * @brief SPI notification callback type.
- *
- * @param[in] spip pointer to the @p SPIDriver object triggering the
- * callback
+ * @brief Low level fields of the SPI driver structure.
*/
-typedef void (*spicallback_t)(SPIDriver *spip);
+#define spi_lld_driver_fields
/**
- * @brief Driver configuration structure.
- * @note Implementations may extend this structure to contain more,
- * architecture dependent, fields.
+ * @brief Low level fields of the SPI configuration structure.
*/
-typedef struct {
-#if (SPI_SUPPORTS_CIRCULAR == TRUE) || defined(__DOXYGEN__)
- /**
- * @brief Enables the circular buffer mode.
- */
- bool circular;
-#endif
- /**
- * @brief Operation complete callback or @p NULL.
- */
- spicallback_t end_cb;
-#if (SPI_SELECT_MODE == SPI_SELECT_MODE_LINE) || defined(__DOXYGEN__)
- /**
- * @brief The chip select line.
- */
- ioline_t ssline;
-#endif
-#if (SPI_SELECT_MODE == SPI_SELECT_MODE_PORT) || defined(__DOXYGEN__)
- /**
- * @brief The chip select port.
- */
- ioportid_t ssport;
- /**
- * @brief The chip select port mask.
- */
- ioportmask_t ssmask;
-#endif
-#if (SPI_SELECT_MODE == SPI_SELECT_MODE_PAD) || defined(__DOXYGEN__)
- /**
- * @brief The chip select port.
- */
- ioportid_t ssport;
- /**
- * @brief The chip select pad number.
- */
- uint_fast8_t sspad;
-#endif
- /* End of the mandatory fields.*/
-} SPIConfig;
-
-/**
- * @brief Structure representing an SPI driver.
- * @note Implementations may extend this structure to contain more,
- * architecture dependent, fields.
- */
-struct SPIDriver {
- /**
- * @brief Driver state.
- */
- spistate_t state;
- /**
- * @brief Current configuration data.
- */
- const SPIConfig *config;
-#if (SPI_USE_WAIT == TRUE) || defined(__DOXYGEN__)
- /**
- * @brief Waiting thread.
- */
- thread_reference_t thread;
-#endif
-#if (SPI_USE_MUTUAL_EXCLUSION == TRUE) || defined(__DOXYGEN__)
- /**
- * @brief Mutex protecting the peripheral.
- */
- mutex_t mutex;
-#endif
-#if defined(SPI_DRIVER_EXT_FIELDS)
- SPI_DRIVER_EXT_FIELDS
-#endif
- /* End of the mandatory fields.*/
-};
-
-/*===========================================================================*/
-/* Driver macros. */
-/*===========================================================================*/
+#define spi_lld_config_fields
/*===========================================================================*/
/* External declarations. */