123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428 |
- /**
- ******************************************************************************
- * @file stm32l4xx_ll_rng.h
- * @author MCD Application Team
- * @brief Header file of RNG LL module.
- ******************************************************************************
- * @attention
- *
- * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
- /* Define to prevent recursive inclusion -------------------------------------*/
- #ifndef __STM32L4xx_LL_RNG_H
- #define __STM32L4xx_LL_RNG_H
- #ifdef __cplusplus
- extern "C" {
- #endif
- /* Includes ------------------------------------------------------------------*/
- #include "stm32l4xx.h"
- /** @addtogroup STM32L4xx_LL_Driver
- * @{
- */
- #if defined(RNG)
- /** @defgroup RNG_LL RNG
- * @{
- */
- /* Private types -------------------------------------------------------------*/
- /* Private variables ---------------------------------------------------------*/
- /* Private constants ---------------------------------------------------------*/
- /* Private macros ------------------------------------------------------------*/
- /* Exported types ------------------------------------------------------------*/
- #if defined(USE_FULL_LL_DRIVER)
- /** @defgroup RNG_LL_ES_Init_Struct RNG Exported Init structures
- * @{
- */
-
- #if defined(RNG_CR_CED)
- /**
- * @brief LL RNG Init Structure Definition
- */
- typedef struct
- {
- uint32_t ClockErrorDetection; /*!< Clock error detection.
- This parameter can be one value of @ref RNG_LL_CED.
-
- This parameter can be modified using unitary functions @ref LL_RNG_EnableClkErrorDetect(). */
- }LL_RNG_InitTypeDef;
- #endif /* defined(RNG_CR_CED) */
- /**
- * @}
- */
- #endif /* USE_FULL_LL_DRIVER */
-
- /* Exported constants --------------------------------------------------------*/
- /** @defgroup RNG_LL_Exported_Constants RNG Exported Constants
- * @{
- */
-
- #if defined(RNG_CR_CED)
- /** @defgroup RNG_LL_CED Clock Error Detection
- * @{
- */
- #define LL_RNG_CED_ENABLE 0x00000000U /*!< Clock error detection enabled */
- #define LL_RNG_CED_DISABLE RNG_CR_CED /*!< Clock error detection disabled */
- /**
- * @}
- */
- #endif /* defined(RNG_CR_CED) */
-
- /** @defgroup RNG_LL_EC_GET_FLAG Get Flags Defines
- * @brief Flags defines which can be used with LL_RNG_ReadReg function
- * @{
- */
- #define LL_RNG_SR_DRDY RNG_SR_DRDY /*!< Register contains valid random data */
- #define LL_RNG_SR_CECS RNG_SR_CECS /*!< Clock error current status */
- #define LL_RNG_SR_SECS RNG_SR_SECS /*!< Seed error current status */
- #define LL_RNG_SR_CEIS RNG_SR_CEIS /*!< Clock error interrupt status */
- #define LL_RNG_SR_SEIS RNG_SR_SEIS /*!< Seed error interrupt status */
- /**
- * @}
- */
- /** @defgroup RNG_LL_EC_IT IT Defines
- * @brief IT defines which can be used with LL_RNG_ReadReg and LL_RNG_WriteReg macros
- * @{
- */
- #define LL_RNG_CR_IE RNG_CR_IE /*!< RNG Interrupt enable */
- /**
- * @}
- */
- /**
- * @}
- */
- /* Exported macro ------------------------------------------------------------*/
- /** @defgroup RNG_LL_Exported_Macros RNG Exported Macros
- * @{
- */
- /** @defgroup RNG_LL_EM_WRITE_READ Common Write and read registers Macros
- * @{
- */
- /**
- * @brief Write a value in RNG register
- * @param __INSTANCE__ RNG Instance
- * @param __REG__ Register to be written
- * @param __VALUE__ Value to be written in the register
- * @retval None
- */
- #define LL_RNG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
- /**
- * @brief Read a value in RNG register
- * @param __INSTANCE__ RNG Instance
- * @param __REG__ Register to be read
- * @retval Register value
- */
- #define LL_RNG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
- /**
- * @}
- */
- /**
- * @}
- */
- /* Exported functions --------------------------------------------------------*/
- /** @defgroup RNG_LL_Exported_Functions RNG Exported Functions
- * @{
- */
- /** @defgroup RNG_LL_EF_Configuration RNG Configuration functions
- * @{
- */
- /**
- * @brief Enable Random Number Generation
- * @rmtoll CR RNGEN LL_RNG_Enable
- * @param RNGx RNG Instance
- * @retval None
- */
- __STATIC_INLINE void LL_RNG_Enable(RNG_TypeDef *RNGx)
- {
- SET_BIT(RNGx->CR, RNG_CR_RNGEN);
- }
- /**
- * @brief Disable Random Number Generation
- * @rmtoll CR RNGEN LL_RNG_Disable
- * @param RNGx RNG Instance
- * @retval None
- */
- __STATIC_INLINE void LL_RNG_Disable(RNG_TypeDef *RNGx)
- {
- CLEAR_BIT(RNGx->CR, RNG_CR_RNGEN);
- }
- /**
- * @brief Check if Random Number Generator is enabled
- * @rmtoll CR RNGEN LL_RNG_IsEnabled
- * @param RNGx RNG Instance
- * @retval State of bit (1 or 0).
- */
- __STATIC_INLINE uint32_t LL_RNG_IsEnabled(RNG_TypeDef *RNGx)
- {
- return (READ_BIT(RNGx->CR, RNG_CR_RNGEN) == (RNG_CR_RNGEN));
- }
- #if defined(RNG_CR_CED)
- /**
- * @brief Enable RNG Clock Error Detection
- * @rmtoll CR CED LL_RNG_EnableClkErrorDetect
- * @param RNGx RNG Instance
- * @retval None
- */
- __STATIC_INLINE void LL_RNG_EnableClkErrorDetect(RNG_TypeDef *RNGx)
- {
- CLEAR_BIT(RNGx->CR, RNG_CR_CED);
- }
- /**
- * @brief Disable RNG Clock Error Detection
- * @rmtoll CR CED LL_RNG_DisableClkErrorDetect
- * @param RNGx RNG Instance
- * @retval None
- */
- __STATIC_INLINE void LL_RNG_DisableClkErrorDetect(RNG_TypeDef *RNGx)
- {
- SET_BIT(RNGx->CR, RNG_CR_CED);
- }
- /**
- * @brief Check if RNG Clock Error Detection is enabled
- * @rmtoll CR CED LL_RNG_IsEnabledClkErrorDetect
- * @param RNGx RNG Instance
- * @retval State of bit (1 or 0).
- */
- __STATIC_INLINE uint32_t LL_RNG_IsEnabledClkErrorDetect(RNG_TypeDef *RNGx)
- {
- return (!(READ_BIT(RNGx->CR, RNG_CR_CED) == (RNG_CR_CED)));
- }
- #endif /* defined(RNG_CR_CED) */
- /**
- * @}
- */
- /** @defgroup RNG_LL_EF_FLAG_Management FLAG Management
- * @{
- */
- /**
- * @brief Indicate if the RNG Data ready Flag is set or not
- * @rmtoll SR DRDY LL_RNG_IsActiveFlag_DRDY
- * @param RNGx RNG Instance
- * @retval State of bit (1 or 0).
- */
- __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_DRDY(RNG_TypeDef *RNGx)
- {
- return (READ_BIT(RNGx->SR, RNG_SR_DRDY) == (RNG_SR_DRDY));
- }
- /**
- * @brief Indicate if the Clock Error Current Status Flag is set or not
- * @rmtoll SR CECS LL_RNG_IsActiveFlag_CECS
- * @param RNGx RNG Instance
- * @retval State of bit (1 or 0).
- */
- __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_CECS(RNG_TypeDef *RNGx)
- {
- return (READ_BIT(RNGx->SR, RNG_SR_CECS) == (RNG_SR_CECS));
- }
- /**
- * @brief Indicate if the Seed Error Current Status Flag is set or not
- * @rmtoll SR SECS LL_RNG_IsActiveFlag_SECS
- * @param RNGx RNG Instance
- * @retval State of bit (1 or 0).
- */
- __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_SECS(RNG_TypeDef *RNGx)
- {
- return (READ_BIT(RNGx->SR, RNG_SR_SECS) == (RNG_SR_SECS));
- }
- /**
- * @brief Indicate if the Clock Error Interrupt Status Flag is set or not
- * @rmtoll SR CEIS LL_RNG_IsActiveFlag_CEIS
- * @param RNGx RNG Instance
- * @retval State of bit (1 or 0).
- */
- __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_CEIS(RNG_TypeDef *RNGx)
- {
- return (READ_BIT(RNGx->SR, RNG_SR_CEIS) == (RNG_SR_CEIS));
- }
- /**
- * @brief Indicate if the Seed Error Interrupt Status Flag is set or not
- * @rmtoll SR SEIS LL_RNG_IsActiveFlag_SEIS
- * @param RNGx RNG Instance
- * @retval State of bit (1 or 0).
- */
- __STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_SEIS(RNG_TypeDef *RNGx)
- {
- return (READ_BIT(RNGx->SR, RNG_SR_SEIS) == (RNG_SR_SEIS));
- }
- /**
- * @brief Clear Clock Error interrupt Status (CEIS) Flag
- * @rmtoll SR CEIS LL_RNG_ClearFlag_CEIS
- * @param RNGx RNG Instance
- * @retval None
- */
- __STATIC_INLINE void LL_RNG_ClearFlag_CEIS(RNG_TypeDef *RNGx)
- {
- WRITE_REG(RNGx->SR, ~RNG_SR_CEIS);
- }
- /**
- * @brief Clear Seed Error interrupt Status (SEIS) Flag
- * @rmtoll SR SEIS LL_RNG_ClearFlag_SEIS
- * @param RNGx RNG Instance
- * @retval None
- */
- __STATIC_INLINE void LL_RNG_ClearFlag_SEIS(RNG_TypeDef *RNGx)
- {
- WRITE_REG(RNGx->SR, ~RNG_SR_SEIS);
- }
- /**
- * @}
- */
- /** @defgroup RNG_LL_EF_IT_Management IT Management
- * @{
- */
- /**
- * @brief Enable Random Number Generator Interrupt
- * (applies for either Seed error, Clock Error or Data ready interrupts)
- * @rmtoll CR IE LL_RNG_EnableIT
- * @param RNGx RNG Instance
- * @retval None
- */
- __STATIC_INLINE void LL_RNG_EnableIT(RNG_TypeDef *RNGx)
- {
- SET_BIT(RNGx->CR, RNG_CR_IE);
- }
- /**
- * @brief Disable Random Number Generator Interrupt
- * (applies for either Seed error, Clock Error or Data ready interrupts)
- * @rmtoll CR IE LL_RNG_DisableIT
- * @param RNGx RNG Instance
- * @retval None
- */
- __STATIC_INLINE void LL_RNG_DisableIT(RNG_TypeDef *RNGx)
- {
- CLEAR_BIT(RNGx->CR, RNG_CR_IE);
- }
- /**
- * @brief Check if Random Number Generator Interrupt is enabled
- * (applies for either Seed error, Clock Error or Data ready interrupts)
- * @rmtoll CR IE LL_RNG_IsEnabledIT
- * @param RNGx RNG Instance
- * @retval State of bit (1 or 0).
- */
- __STATIC_INLINE uint32_t LL_RNG_IsEnabledIT(RNG_TypeDef *RNGx)
- {
- return (READ_BIT(RNGx->CR, RNG_CR_IE) == (RNG_CR_IE));
- }
- /**
- * @}
- */
- /** @defgroup RNG_LL_EF_Data_Management Data Management
- * @{
- */
- /**
- * @brief Return32-bit Random Number value
- * @rmtoll DR RNDATA LL_RNG_ReadRandData32
- * @param RNGx RNG Instance
- * @retval Generated 32-bit random value
- */
- __STATIC_INLINE uint32_t LL_RNG_ReadRandData32(RNG_TypeDef *RNGx)
- {
- return (uint32_t)(READ_REG(RNGx->DR));
- }
- /**
- * @}
- */
- #if defined(USE_FULL_LL_DRIVER)
- /** @defgroup RNG_LL_EF_Init Initialization and de-initialization functions
- * @{
- */
- #if defined(RNG_CR_CED)
- ErrorStatus LL_RNG_Init(RNG_TypeDef *RNGx, LL_RNG_InitTypeDef *RNG_InitStruct);
- void LL_RNG_StructInit(LL_RNG_InitTypeDef *RNG_InitStruct);
- #endif /* defined(RNG_CR_CED) */
- ErrorStatus LL_RNG_DeInit(RNG_TypeDef *RNGx);
- /**
- * @}
- */
- #endif /* USE_FULL_LL_DRIVER */
- /**
- * @}
- */
- /**
- * @}
- */
- #endif /* defined(RNG) */
- /**
- * @}
- */
- #ifdef __cplusplus
- }
- #endif
- #endif /* __STM32L4xx_LL_RNG_H */
- /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|