From 584f19dbe94ea1ad9585ce04c5f1d5b424ebaa09 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sat, 8 Dec 2018 12:04:11 +0000 Subject: Updated TRNG. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12465 110e8d01-0319-4d1e-a829-52ad28d1bb01 --- os/hal/include/hal_spi.h | 62 ++++++++++++++--------------- os/hal/include/hal_trng.h | 38 +++++++++++++++++- os/hal/ports/STM32/LLD/RNGv1/hal_trng_lld.h | 44 ++++++-------------- os/hal/templates/hal_trng_lld.h | 38 +++++------------- readme.txt | 2 +- 5 files changed, 91 insertions(+), 93 deletions(-) diff --git a/os/hal/include/hal_spi.h b/os/hal/include/hal_spi.h index ab07811c0..4d2ebdefb 100644 --- a/os/hal/include/hal_spi.h +++ b/os/hal/include/hal_spi.h @@ -142,37 +142,6 @@ typedef void (*spicallback_t)(SPIDriver *spip); for completing types.*/ #include "hal_spi_lld.h" -/** - * @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. */ @@ -217,6 +186,37 @@ struct hal_spi_config { spi_lld_config_fields; }; +/** + * @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; +}; + /*===========================================================================*/ /* Driver macros. */ /*===========================================================================*/ diff --git a/os/hal/include/hal_trng.h b/os/hal/include/hal_trng.h index 48d95613e..a92f4f665 100644 --- a/os/hal/include/hal_trng.h +++ b/os/hal/include/hal_trng.h @@ -56,10 +56,46 @@ typedef enum { /** * @brief Type of a structure representing a TRNG driver. */ -typedef struct TRNGDriver TRNGDriver; +typedef struct hal_trng_driver TRNGDriver; +/** + * @brief Driver configuration structure. + * @note It could be empty on some architectures. + */ +typedef struct hal_trng_config TRNGConfig; + + +/* Including the low level driver header, it exports information required + for completing types.*/ #include "hal_trng_lld.h" +/** + * @brief Driver configuration structure. + */ +struct hal_trng_config { + /* End of the mandatory fields.*/ + trng_lld_config_fields; +}; + +/** + * @brief Structure representing a TRNG driver. + */ +struct hal_trng_driver { + /** + * @brief Driver state. + */ + trngstate_t state; + /** + * @brief Current configuration data. + */ + const TRNGConfig *config; +#if defined(TRNG_DRIVER_EXT_FIELDS) + TRNG_DRIVER_EXT_FIELDS +#endif + /* End of the mandatory fields.*/ + trng_lld_driver_fields; +}; + /*===========================================================================*/ /* Driver macros. */ /*===========================================================================*/ diff --git a/os/hal/ports/STM32/LLD/RNGv1/hal_trng_lld.h b/os/hal/ports/STM32/LLD/RNGv1/hal_trng_lld.h index 3f04adcde..c537b84fd 100644 --- a/os/hal/ports/STM32/LLD/RNGv1/hal_trng_lld.h +++ b/os/hal/ports/STM32/LLD/RNGv1/hal_trng_lld.h @@ -93,43 +93,23 @@ /* Driver data structures and types. */ /*===========================================================================*/ +/*===========================================================================*/ +/* Driver macros. */ +/*===========================================================================*/ + /** - * @brief Driver configuration structure. - * @note It could be empty on some architectures. + * @brief Low level fields of the TRNG configuration structure. */ -typedef struct { - /* End of the mandatory fields.*/ - /** - * @brief Dummy configuration, it is not needed. - */ - uint32_t dummy; -} TRNGConfig; +#define trng_lld_config_fields \ + /* Dummy configuration, it is not needed.*/ \ + uint32_t dummy /** - * @brief Structure representing a TRNG driver. + * @brief Low level fields of the TRNG driver structure. */ -struct TRNGDriver { - /** - * @brief Driver state. - */ - trngstate_t state; - /** - * @brief Current configuration data. - */ - const TRNGConfig *config; -#if defined(TRNG_DRIVER_EXT_FIELDS) - TRNG_DRIVER_EXT_FIELDS -#endif - /* End of the mandatory fields.*/ - /** - * @brief Pointer to the RNG registers block. - */ - RNG_TypeDef *rng; -}; - -/*===========================================================================*/ -/* Driver macros. */ -/*===========================================================================*/ +#define trng_lld_driver_fields \ + /* Pointer to the RNG registers block.*/ \ + RNG_TypeDef *rng /*===========================================================================*/ /* External declarations. */ diff --git a/os/hal/templates/hal_trng_lld.h b/os/hal/templates/hal_trng_lld.h index c1ca6bed2..1c7cfc7e7 100644 --- a/os/hal/templates/hal_trng_lld.h +++ b/os/hal/templates/hal_trng_lld.h @@ -57,39 +57,21 @@ /* Driver data structures and types. */ /*===========================================================================*/ +/*===========================================================================*/ +/* Driver macros. */ +/*===========================================================================*/ + /** - * @brief Driver configuration structure. - * @note It could be empty on some architectures. + * @brief Low level fields of the TRNG configuration structure. */ -typedef struct { - /* End of the mandatory fields.*/ - /** - * @brief Dummy configuration, it is not needed.. - */ - uint32_t dummy; -} TRNGConfig; +#define trng_lld_config_fields \ + /* Dummy configuration, it is not needed.*/ \ + uint32_t dummy /** - * @brief Structure representing a TRNG driver. + * @brief Low level fields of the TRNG driver structure. */ -struct TRNGDriver { - /** - * @brief Driver state. - */ - trngstate_t state; - /** - * @brief Current configuration data. - */ - const TRNGConfig *config; -#if defined(TRNG_DRIVER_EXT_FIELDS) - TRNG_DRIVER_EXT_FIELDS -#endif - /* End of the mandatory fields.*/ -}; - -/*===========================================================================*/ -/* Driver macros. */ -/*===========================================================================*/ +#define trng_lld_driver_fields /*===========================================================================*/ /* External declarations. */ diff --git a/readme.txt b/readme.txt index f50d1bb71..fde900120 100644 --- a/readme.txt +++ b/readme.txt @@ -78,7 +78,7 @@ - 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. + So far the drivers updated are: RTC, SPI, TRNG. - NEW: Added UART7/8 support to STM32 UART USARTv1 driver. - NEW: Added persistent storage interface to the STM32 RTCv2 driver. - NEW: STM32 RTCv2 driver now supports callbacks on events. -- cgit v1.2.3