diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2018-12-08 11:23:21 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2018-12-08 11:23:21 +0000 |
commit | f3249c78d9353bca99172f5cbbc6b7fb0c64c665 (patch) | |
tree | 66d4f82230e664021b0999ce97a827660432346f /os/hal/include | |
parent | 53093a74b030cffbb4ebd78adaa4707ea4ecf9db (diff) | |
download | ChibiOS-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/include')
-rw-r--r-- | os/hal/include/hal_rtc.h | 2 | ||||
-rw-r--r-- | os/hal/include/hal_spi.h | 105 |
2 files changed, 102 insertions, 5 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. */
|