LLD drivers organization changes: RTC, SPI.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12463 110e8d01-0319-4d1e-a829-52ad28d1bb01
This commit is contained in:
parent
53093a74b0
commit
f3249c78d9
|
@ -153,7 +153,7 @@ struct RTCDriver {
|
||||||
RTC_DRIVER_EXT_FIELDS
|
RTC_DRIVER_EXT_FIELDS
|
||||||
#endif
|
#endif
|
||||||
/* End of the mandatory fields.*/
|
/* End of the mandatory fields.*/
|
||||||
_rtc_lld_driver_fields
|
rtc_lld_driver_fields;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
|
@ -97,6 +97,15 @@
|
||||||
#error "invalid SPI_SELECT_MODE setting"
|
#error "invalid SPI_SELECT_MODE setting"
|
||||||
#endif
|
#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. */
|
/* Driver data structures and types. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -112,13 +121,101 @@ typedef enum {
|
||||||
SPI_COMPLETE = 4 /**< Asynchronous operation complete. */
|
SPI_COMPLETE = 4 /**< Asynchronous operation complete. */
|
||||||
} spistate_t;
|
} 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"
|
#include "hal_spi_lld.h"
|
||||||
|
|
||||||
/* Some more checks, must happen after inclusion of the LLD header, this is
|
/**
|
||||||
why are placed here.*/
|
* @brief Structure representing an SPI driver.
|
||||||
#if !defined(SPI_SUPPORTS_CIRCULAR)
|
*/
|
||||||
#define SPI_SUPPORTS_CIRCULAR FALSE
|
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
|
#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. */
|
/* Driver macros. */
|
||||||
|
|
|
@ -111,11 +111,11 @@ typedef struct hsl_rtc_alarm {
|
||||||
/**
|
/**
|
||||||
* @brief Implementation-specific @p RTCDriver fields.
|
* @brief Implementation-specific @p RTCDriver fields.
|
||||||
*/
|
*/
|
||||||
#define _rtc_lld_driver_fields \
|
#define rtc_lld_driver_fields \
|
||||||
/* Pointer to the RTC registers block.*/ \
|
/* Pointer to the RTC registers block.*/ \
|
||||||
RTC_TypeDef *rtc; \
|
RTC_TypeDef *rtc; \
|
||||||
/* Callback pointer.*/ \
|
/* Callback pointer.*/ \
|
||||||
rtccb_t callback;
|
rtccb_t callback
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver macros. */
|
/* Driver macros. */
|
||||||
|
|
|
@ -203,11 +203,11 @@ typedef struct hal_rtc_wakeup {
|
||||||
/**
|
/**
|
||||||
* @brief Implementation-specific @p RTCDriver fields.
|
* @brief Implementation-specific @p RTCDriver fields.
|
||||||
*/
|
*/
|
||||||
#define _rtc_lld_driver_fields \
|
#define rtc_lld_driver_fields \
|
||||||
/* Pointer to the RTC registers block.*/ \
|
/* Pointer to the RTC registers block.*/ \
|
||||||
RTC_TypeDef *rtc; \
|
RTC_TypeDef *rtc; \
|
||||||
/* Callback pointer.*/ \
|
/* Callback pointer.*/ \
|
||||||
rtccb_t callback;
|
rtccb_t callback
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver macros. */
|
/* Driver macros. */
|
||||||
|
|
|
@ -409,124 +409,34 @@
|
||||||
/* Driver data structures and types. */
|
/* 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 CR1 register initialization data.
|
|
||||||
*/
|
|
||||||
uint16_t cr1;
|
|
||||||
/**
|
|
||||||
* @brief SPI CR2 register initialization data.
|
|
||||||
*/
|
|
||||||
uint16_t cr2;
|
|
||||||
} 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 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. */
|
/* Driver macros. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Low level fields of the SPI driver structure.
|
||||||
|
*/
|
||||||
|
#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 Low level fields of the SPI configuration structure.
|
||||||
|
*/
|
||||||
|
#define spi_lld_config_fields \
|
||||||
|
/* SPI CR1 register initialization data.*/ \
|
||||||
|
uint16_t cr1; \
|
||||||
|
/* SPI CR2 register initialization data.*/ \
|
||||||
|
uint16_t cr2
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* External declarations. */
|
/* External declarations. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
|
@ -505,124 +505,34 @@
|
||||||
/* Driver data structures and types. */
|
/* 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 CR1 register initialization data.
|
|
||||||
*/
|
|
||||||
uint16_t cr1;
|
|
||||||
/**
|
|
||||||
* @brief SPI CR2 register initialization data.
|
|
||||||
*/
|
|
||||||
uint16_t cr2;
|
|
||||||
} 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;
|
|
||||||
/**
|
|
||||||
* @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. */
|
/* Driver macros. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Low level fields of the SPI driver structure.
|
||||||
|
*/
|
||||||
|
#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 Low level fields of the SPI configuration structure.
|
||||||
|
*/
|
||||||
|
#define spi_lld_config_fields \
|
||||||
|
/* SPI CR1 register initialization data.*/ \
|
||||||
|
uint16_t cr1; \
|
||||||
|
/* SPI CR2 register initialization data.*/ \
|
||||||
|
uint16_t cr2
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* External declarations. */
|
/* External declarations. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
|
@ -504,156 +504,86 @@
|
||||||
/* Driver data structures and types. */
|
/* 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. */
|
/* 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. */
|
/* External declarations. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
|
@ -105,8 +105,8 @@ typedef struct {
|
||||||
/**
|
/**
|
||||||
* @brief Implementation-specific @p RTCDriver fields.
|
* @brief Implementation-specific @p RTCDriver fields.
|
||||||
*/
|
*/
|
||||||
#define _rtc_lld_driver_fields \
|
#define rtc_lld_driver_fields \
|
||||||
uint32_t dummy;
|
uint32_t dummy
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver macros. */
|
/* Driver macros. */
|
||||||
|
|
|
@ -62,100 +62,20 @@
|
||||||
/* Driver data structures and types. */
|
/* 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.
|
|
||||||
* @note Implementations may extend this structure to contain more,
|
|
||||||
* architecture dependent, fields.
|
|
||||||
*/
|
|
||||||
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. */
|
/* Driver macros. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Low level fields of the SPI driver structure.
|
||||||
|
*/
|
||||||
|
#define spi_lld_driver_fields
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Low level fields of the SPI configuration structure.
|
||||||
|
*/
|
||||||
|
#define spi_lld_config_fields
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* External declarations. */
|
/* External declarations. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
|
@ -75,6 +75,10 @@
|
||||||
*****************************************************************************
|
*****************************************************************************
|
||||||
|
|
||||||
*** Next ***
|
*** Next ***
|
||||||
|
- NEW: Low level drivers simplification. There is a new template of LLD, now
|
||||||
|
driver and configuration types are defined in the HLD, LLD just exports
|
||||||
|
macros with the fields to be added to the structures.
|
||||||
|
So far the drivers updated are: RTC, SPI.
|
||||||
- NEW: Added UART7/8 support to STM32 UART USARTv1 driver.
|
- NEW: Added UART7/8 support to STM32 UART USARTv1 driver.
|
||||||
- NEW: Added persistent storage interface to the STM32 RTCv2 driver.
|
- NEW: Added persistent storage interface to the STM32 RTCv2 driver.
|
||||||
- NEW: STM32 RTCv2 driver now supports callbacks on events.
|
- NEW: STM32 RTCv2 driver now supports callbacks on events.
|
||||||
|
|
Loading…
Reference in New Issue