aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2018-12-09 09:11:21 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2018-12-09 09:11:21 +0000
commit964ca6029035706e5ba5be7a8304eba67920386d (patch)
tree33dd1e258a78ff1c40f10bfdcb7c394678f0d84e /os/hal/ports
parent584f19dbe94ea1ad9585ce04c5f1d5b424ebaa09 (diff)
downloadChibiOS-964ca6029035706e5ba5be7a8304eba67920386d.tar.gz
ChibiOS-964ca6029035706e5ba5be7a8304eba67920386d.tar.bz2
ChibiOS-964ca6029035706e5ba5be7a8304eba67920386d.zip
DAC reworked, fixed a problem in WSPI template.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12466 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'os/hal/ports')
-rw-r--r--os/hal/ports/STM32/LLD/DACv1/hal_dac_lld.h142
-rw-r--r--os/hal/ports/STM32/LLD/OCTOSPIv1/hal_wspi_lld.h92
-rw-r--r--os/hal/ports/STM32/LLD/QUADSPIv1/hal_wspi_lld.h71
3 files changed, 66 insertions, 239 deletions
diff --git a/os/hal/ports/STM32/LLD/DACv1/hal_dac_lld.h b/os/hal/ports/STM32/LLD/DACv1/hal_dac_lld.h
index a3d29956a..d66a8b0e7 100644
--- a/os/hal/ports/STM32/LLD/DACv1/hal_dac_lld.h
+++ b/os/hal/ports/STM32/LLD/DACv1/hal_dac_lld.h
@@ -287,6 +287,11 @@
typedef uint32_t dacchannel_t;
/**
+ * @brief Type representing a DAC sample.
+ */
+typedef uint16_t dacsample_t;
+
+/**
* @brief DAC channel parameters type.
*/
typedef struct {
@@ -327,16 +332,6 @@ typedef struct {
} dacparams_t;
/**
- * @brief Type of a structure representing an DAC driver.
- */
-typedef struct DACDriver DACDriver;
-
-/**
- * @brief Type representing a DAC sample.
- */
-typedef uint16_t dacsample_t;
-
-/**
* @brief Possible DAC failure causes.
* @note Error codes are architecture dependent and should not relied
* upon.
@@ -347,25 +342,6 @@ typedef enum {
} dacerror_t;
/**
- * @brief DAC notification callback type.
- *
- * @param[in] dacp pointer to the @p DACDriver object triggering the
- * @param[in] buffer pointer to the next semi-buffer to be filled
- * @param[in] n number of buffer rows available starting from @p buffer
- * callback
- */
-typedef void (*daccallback_t)(DACDriver *dacp, dacsample_t *buffer, size_t n);
-
-/**
- * @brief DAC error callback type.
- *
- * @param[in] dacp pointer to the @p DACDriver object triggering the
- * callback
- * @param[in] err DAC error code
- */
-typedef void (*dacerrorcallback_t)(DACDriver *dacp, dacerror_t err);
-
-/**
* @brief Samples alignment and size mode.
*/
typedef enum {
@@ -379,100 +355,36 @@ typedef enum {
#endif
} dacdhrmode_t;
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
+
/**
- * @brief DAC Conversion group structure.
+ * @brief Low level fields of the DAC driver structure.
*/
-typedef struct {
- /**
- * @brief Number of DAC channels.
- */
- uint32_t num_channels;
- /**
- * @brief Operation complete callback or @p NULL.
- */
- daccallback_t end_cb;
- /**
- * @brief Error handling callback or @p NULL.
- */
- dacerrorcallback_t error_cb;
- /* End of the mandatory fields.*/
- /**
- * @brief DAC initialization data.
- * @note This field contains the (not shifted) value to be put into the
- * TSEL field of the DAC CR register during initialization. All
- * other fields are handled internally.
- */
- uint32_t trigger;
-} DACConversionGroup;
+#define dac_lld_driver_fields \
+ /* DAC channel parameters.*/ \
+ const dacparams_t *params
/**
- * @brief Driver configuration structure.
+ * @brief Low level fields of the DAC configuration structure.
*/
-typedef struct {
- /* End of the mandatory fields.*/
- /**
- * @brief Initial output on DAC channels.
- */
- dacsample_t init;
- /**
- * @brief DAC data holding register mode.
- */
- dacdhrmode_t datamode;
- /**
- * @brief DAC control register.
- */
- uint16_t cr;
-} DACConfig;
+#define dac_lld_config_fields \
+ /* Initial output on DAC channels.*/ \
+ dacsample_t init; \
+ /* DAC data holding register mode.*/ \
+ dacdhrmode_t datamode; \
+ /* DAC control register.*/ \
+ uint16_t cr
/**
- * @brief Structure representing a DAC driver.
+ * @brief Low level fields of the DAC group configuration structure.
*/
-struct DACDriver {
- /**
- * @brief Driver state.
- */
- dacstate_t state;
- /**
- * @brief Conversion group.
- */
- const DACConversionGroup *grpp;
- /**
- * @brief Samples buffer pointer.
- */
- dacsample_t *samples;
- /**
- * @brief Samples buffer size.
- */
- uint16_t depth;
- /**
- * @brief Current configuration data.
- */
- const DACConfig *config;
-#if DAC_USE_WAIT || defined(__DOXYGEN__)
- /**
- * @brief Waiting thread.
- */
- thread_reference_t thread;
-#endif /* DAC_USE_WAIT */
-#if DAC_USE_MUTUAL_EXCLUSION || defined(__DOXYGEN__)
- /**
- * @brief Mutex protecting the bus.
- */
- mutex_t mutex;
-#endif /* DAC_USE_MUTUAL_EXCLUSION */
-#if defined(DAC_DRIVER_EXT_FIELDS)
- DAC_DRIVER_EXT_FIELDS
-#endif
- /* End of the mandatory fields.*/
- /**
- * @brief DAC channel parameters.
- */
- const dacparams_t *params;
-};
-
-/*===========================================================================*/
-/* Driver macros. */
-/*===========================================================================*/
+#define dac_lld_conversion_group_fields \
+ /* DAC initialization data. This field contains the (not shifted) value \
+ to be put into the TSEL field of the DAC CR register during \
+ initialization. All other fields are handled internally.*/ \
+ uint32_t trigger
/*===========================================================================*/
/* External declarations. */
diff --git a/os/hal/ports/STM32/LLD/OCTOSPIv1/hal_wspi_lld.h b/os/hal/ports/STM32/LLD/OCTOSPIv1/hal_wspi_lld.h
index fd0ac2cd1..eada95b2b 100644
--- a/os/hal/ports/STM32/LLD/OCTOSPIv1/hal_wspi_lld.h
+++ b/os/hal/ports/STM32/LLD/OCTOSPIv1/hal_wspi_lld.h
@@ -265,80 +265,34 @@
/* Driver data structures and types. */
/*===========================================================================*/
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
+
/**
- * @brief Driver configuration structure.
+ * @brief Low level fields of the WSPI configuration structure.
*/
-struct hal_wspi_config {
- /**
- * @brief Operation complete callback or @p NULL.
- */
- wspicallback_t end_cb;
- /* End of the mandatory fields.*/
- /**
- * @brief DCR1 register initialization data.
- */
- uint32_t dcr1;
- /**
- * @brief DCR2 register initialization data.
- * @note Prescaler field is internally ORed to this field, leave it
- * to zero.
- */
- uint32_t dcr2;
- /**
- * @brief DCR3 register initialization data.
- */
- uint32_t dcr3;
- /**
- * @brief DCR4 register initialization data.
- */
- uint32_t dcr4;
-};
+#define wspi_lld_config_fields \
+ /* DCR1 register initialization data.*/ \
+ uint32_t dcr1; \
+ /* DCR2 register initialization data. The prescaler field is internally \
+ ORed to this field, leave it to zero.*/ \
+ uint32_t dcr2; \
+ /* DCR3 register initialization data.*/ \
+ uint32_t dcr3; \
+ /* DCR4 register initialization data.*/ \
+ uint32_t dcr4
/**
- * @brief Structure representing an WSPI driver.
+ * @brief Low level fields of the WSPI driver structure.
*/
-struct hal_wspi_driver {
- /**
- * @brief Driver state.
- */
- wspistate_t state;
- /**
- * @brief Current configuration data.
- */
- const WSPIConfig *config;
-#if (WSPI_USE_WAIT == TRUE) || defined(__DOXYGEN__)
- /**
- * @brief Waiting thread.
- */
- thread_reference_t thread;
-#endif /* WSPI_USE_WAIT */
-#if (WSPI_USE_MUTUAL_EXCLUSION == TRUE) || defined(__DOXYGEN__)
- /**
- * @brief Mutex protecting the peripheral.
- */
- mutex_t mutex;
-#endif /* WSPI_USE_MUTUAL_EXCLUSION */
-#if defined(WSPI_DRIVER_EXT_FIELDS)
- WSPI_DRIVER_EXT_FIELDS
-#endif
- /* End of the mandatory fields.*/
- /**
- * @brief Pointer to the OCTOSPIx registers block.
- */
- OCTOSPI_TypeDef *ospi;
- /**
- * @brief OCTOSPI DMA stream.
- */
- const stm32_dma_stream_t *dma;
- /**
- * @brief OCTOSPI DMA mode bit mask.
- */
- uint32_t dmamode;
-};
-
-/*===========================================================================*/
-/* Driver macros. */
-/*===========================================================================*/
+#define wspi_lld_driver_fields \
+ /* Pointer to the OCTOSPIx registers block.*/ \
+ OCTOSPI_TypeDef *ospi; \
+ /* OCTOSPI DMA stream.*/ \
+ const stm32_dma_stream_t *dma; \
+ /* OCTOSPI DMA mode bit mask.*/ \
+ uint32_t dmamode
/*===========================================================================*/
/* External declarations. */
diff --git a/os/hal/ports/STM32/LLD/QUADSPIv1/hal_wspi_lld.h b/os/hal/ports/STM32/LLD/QUADSPIv1/hal_wspi_lld.h
index 4f7f913ef..418ea613f 100644
--- a/os/hal/ports/STM32/LLD/QUADSPIv1/hal_wspi_lld.h
+++ b/os/hal/ports/STM32/LLD/QUADSPIv1/hal_wspi_lld.h
@@ -244,66 +244,27 @@
/* Driver data structures and types. */
/*===========================================================================*/
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
+
/**
- * @brief Driver configuration structure.
+ * @brief Low level fields of the WSPI configuration structure.
*/
-struct hal_wspi_config {
- /**
- * @brief Operation complete callback or @p NULL.
- */
- wspicallback_t end_cb;
- /* End of the mandatory fields.*/
- /**
- * @brief DCR register initialization data.
- */
- uint32_t dcr;
-};
+#define wspi_lld_config_fields \
+ /* DCR register initialization data.*/ \
+ uint32_t dcr
/**
- * @brief Structure representing an WSPI driver.
+ * @brief Low level fields of the WSPI driver structure.
*/
-struct hal_wspi_driver {
- /**
- * @brief Driver state.
- */
- wspistate_t state;
- /**
- * @brief Current configuration data.
- */
- const WSPIConfig *config;
-#if (WSPI_USE_WAIT == TRUE) || defined(__DOXYGEN__)
- /**
- * @brief Waiting thread.
- */
- thread_reference_t thread;
-#endif /* WSPI_USE_WAIT */
-#if (WSPI_USE_MUTUAL_EXCLUSION == TRUE) || defined(__DOXYGEN__)
- /**
- * @brief Mutex protecting the peripheral.
- */
- mutex_t mutex;
-#endif /* WSPI_USE_MUTUAL_EXCLUSION */
-#if defined(WSPI_DRIVER_EXT_FIELDS)
- WSPI_DRIVER_EXT_FIELDS
-#endif
- /* End of the mandatory fields.*/
- /**
- * @brief Pointer to the QUADSPIx registers block.
- */
- QUADSPI_TypeDef *qspi;
- /**
- * @brief QUADSPI DMA stream.
- */
- const stm32_dma_stream_t *dma;
- /**
- * @brief QUADSPI DMA mode bit mask.
- */
- uint32_t dmamode;
-};
-
-/*===========================================================================*/
-/* Driver macros. */
-/*===========================================================================*/
+#define wspi_lld_driver_fields \
+ /* Pointer to the QUADSPIx registers block.*/ \
+ QUADSPI_TypeDef *qspi; \
+ /* QUADSPI DMA stream.*/ \
+ const stm32_dma_stream_t *dma; \
+ /* QUADSPI DMA mode bit mask.*/ \
+ uint32_t dmamode
/*===========================================================================*/
/* External declarations. */