version_2.0

Dependents:   cc3000_ping_demo_try_2

Fork of mbed by mbed official

Committer:
erezi
Date:
Wed Jun 25 06:08:49 2014 +0000
Revision:
86:4f9a848d74c7
Parent:
84:0b3ab51c8877
version_2.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 84:0b3ab51c8877 1 /**
bogdanm 84:0b3ab51c8877 2 ******************************************************************************
bogdanm 84:0b3ab51c8877 3 * @file stm32l0xx_hal_rng.h
bogdanm 84:0b3ab51c8877 4 * @author MCD Application Team
bogdanm 84:0b3ab51c8877 5 * @version V1.0.0
bogdanm 84:0b3ab51c8877 6 * @date 22-April-2014
bogdanm 84:0b3ab51c8877 7 * @brief Header file of RNG HAL module.
bogdanm 84:0b3ab51c8877 8 ******************************************************************************
bogdanm 84:0b3ab51c8877 9 * @attention
bogdanm 84:0b3ab51c8877 10 *
bogdanm 84:0b3ab51c8877 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
bogdanm 84:0b3ab51c8877 12 *
bogdanm 84:0b3ab51c8877 13 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 84:0b3ab51c8877 14 * are permitted provided that the following conditions are met:
bogdanm 84:0b3ab51c8877 15 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 84:0b3ab51c8877 16 * this list of conditions and the following disclaimer.
bogdanm 84:0b3ab51c8877 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 84:0b3ab51c8877 18 * this list of conditions and the following disclaimer in the documentation
bogdanm 84:0b3ab51c8877 19 * and/or other materials provided with the distribution.
bogdanm 84:0b3ab51c8877 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 84:0b3ab51c8877 21 * may be used to endorse or promote products derived from this software
bogdanm 84:0b3ab51c8877 22 * without specific prior written permission.
bogdanm 84:0b3ab51c8877 23 *
bogdanm 84:0b3ab51c8877 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 84:0b3ab51c8877 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 84:0b3ab51c8877 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 84:0b3ab51c8877 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 84:0b3ab51c8877 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 84:0b3ab51c8877 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 84:0b3ab51c8877 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 84:0b3ab51c8877 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 84:0b3ab51c8877 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 84:0b3ab51c8877 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 84:0b3ab51c8877 34 *
bogdanm 84:0b3ab51c8877 35 ******************************************************************************
bogdanm 84:0b3ab51c8877 36 */
bogdanm 84:0b3ab51c8877 37
bogdanm 84:0b3ab51c8877 38 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 84:0b3ab51c8877 39 #ifndef __STM32L0xx_HAL_RNG_H
bogdanm 84:0b3ab51c8877 40 #define __STM32L0xx_HAL_RNG_H
bogdanm 84:0b3ab51c8877 41
bogdanm 84:0b3ab51c8877 42 #ifdef __cplusplus
bogdanm 84:0b3ab51c8877 43 extern "C" {
bogdanm 84:0b3ab51c8877 44 #endif
bogdanm 84:0b3ab51c8877 45
bogdanm 84:0b3ab51c8877 46 #if !defined (STM32L051xx) && !defined (STM32L061xx)
bogdanm 84:0b3ab51c8877 47 /* Includes ------------------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 48 #include "stm32l0xx_hal_def.h"
bogdanm 84:0b3ab51c8877 49
bogdanm 84:0b3ab51c8877 50 /** @addtogroup STM32L0xx_HAL_Driver
bogdanm 84:0b3ab51c8877 51 * @{
bogdanm 84:0b3ab51c8877 52 */
bogdanm 84:0b3ab51c8877 53
bogdanm 84:0b3ab51c8877 54 /** @addtogroup RNG
bogdanm 84:0b3ab51c8877 55 * @{
bogdanm 84:0b3ab51c8877 56 */
bogdanm 84:0b3ab51c8877 57
bogdanm 84:0b3ab51c8877 58 /* Exported types ------------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 59
bogdanm 84:0b3ab51c8877 60 /**
bogdanm 84:0b3ab51c8877 61 * @brief RNG HAL State Structure definition
bogdanm 84:0b3ab51c8877 62 */
bogdanm 84:0b3ab51c8877 63 typedef enum
bogdanm 84:0b3ab51c8877 64 {
bogdanm 84:0b3ab51c8877 65 HAL_RNG_STATE_RESET = 0x00, /*!< RNG not yet initialized or disabled */
bogdanm 84:0b3ab51c8877 66 HAL_RNG_STATE_READY = 0x01, /*!< RNG initialized and ready for use */
bogdanm 84:0b3ab51c8877 67 HAL_RNG_STATE_BUSY = 0x02, /*!< RNG internal process is ongoing */
bogdanm 84:0b3ab51c8877 68 HAL_RNG_STATE_TIMEOUT = 0x03, /*!< RNG timeout state */
bogdanm 84:0b3ab51c8877 69 HAL_RNG_STATE_ERROR = 0x04 /*!< RNG error state */
bogdanm 84:0b3ab51c8877 70
bogdanm 84:0b3ab51c8877 71 }HAL_RNG_StateTypeDef;
bogdanm 84:0b3ab51c8877 72
bogdanm 84:0b3ab51c8877 73 /**
bogdanm 84:0b3ab51c8877 74 * @brief RNG Handle Structure definition
bogdanm 84:0b3ab51c8877 75 */
bogdanm 84:0b3ab51c8877 76 typedef struct
bogdanm 84:0b3ab51c8877 77 {
bogdanm 84:0b3ab51c8877 78 RNG_TypeDef *Instance; /*!< Register base address */
bogdanm 84:0b3ab51c8877 79
bogdanm 84:0b3ab51c8877 80 HAL_LockTypeDef Lock; /*!< RNG locking object */
bogdanm 84:0b3ab51c8877 81
bogdanm 84:0b3ab51c8877 82 __IO HAL_RNG_StateTypeDef State; /*!< RNG communication state */
bogdanm 84:0b3ab51c8877 83
bogdanm 84:0b3ab51c8877 84 }RNG_HandleTypeDef;
bogdanm 84:0b3ab51c8877 85
bogdanm 84:0b3ab51c8877 86 /* Exported constants --------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 87
bogdanm 84:0b3ab51c8877 88 /** @defgroup RNG_Exported_Constants
bogdanm 84:0b3ab51c8877 89 * @{
bogdanm 84:0b3ab51c8877 90 */
bogdanm 84:0b3ab51c8877 91
bogdanm 84:0b3ab51c8877 92 /** @defgroup RNG_Interrupt_definition
bogdanm 84:0b3ab51c8877 93 * @{
bogdanm 84:0b3ab51c8877 94 */
bogdanm 84:0b3ab51c8877 95 #define RNG_IT_CEI ((uint32_t)0x20) /*!< Clock error interrupt */
bogdanm 84:0b3ab51c8877 96 #define RNG_IT_SEI ((uint32_t)0x40) /*!< Seed error interrupt */
bogdanm 84:0b3ab51c8877 97
bogdanm 84:0b3ab51c8877 98 #define IS_RNG_IT(IT) (((IT) == RNG_IT_CEI) || \
bogdanm 84:0b3ab51c8877 99 ((IT) == RNG_IT_SEI))
bogdanm 84:0b3ab51c8877 100 /**
bogdanm 84:0b3ab51c8877 101 * @}
bogdanm 84:0b3ab51c8877 102 */
bogdanm 84:0b3ab51c8877 103
bogdanm 84:0b3ab51c8877 104
bogdanm 84:0b3ab51c8877 105 /** @defgroup RNG_Flag_definition
bogdanm 84:0b3ab51c8877 106 * @{
bogdanm 84:0b3ab51c8877 107 */
bogdanm 84:0b3ab51c8877 108 #define RNG_FLAG_DRDY ((uint32_t)0x0001) /*!< Data ready */
bogdanm 84:0b3ab51c8877 109 #define RNG_FLAG_CECS ((uint32_t)0x0002) /*!< Clock error current status */
bogdanm 84:0b3ab51c8877 110 #define RNG_FLAG_SECS ((uint32_t)0x0004) /*!< Seed error current status */
bogdanm 84:0b3ab51c8877 111
bogdanm 84:0b3ab51c8877 112 #define IS_RNG_FLAG(FLAG) (((FLAG) == RNG_FLAG_DRDY) || \
bogdanm 84:0b3ab51c8877 113 ((FLAG) == RNG_FLAG_CECS) || \
bogdanm 84:0b3ab51c8877 114 ((FLAG) == RNG_FLAG_SECS))
bogdanm 84:0b3ab51c8877 115 /**
bogdanm 84:0b3ab51c8877 116 * @}
bogdanm 84:0b3ab51c8877 117 */
bogdanm 84:0b3ab51c8877 118
bogdanm 84:0b3ab51c8877 119 /**
bogdanm 84:0b3ab51c8877 120 * @}
bogdanm 84:0b3ab51c8877 121 */
bogdanm 84:0b3ab51c8877 122
bogdanm 84:0b3ab51c8877 123 /* Exported macro ------------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 124
bogdanm 84:0b3ab51c8877 125 /** @brief Reset RNG handle state
bogdanm 84:0b3ab51c8877 126 * @param __HANDLE__: RNG Handle
bogdanm 84:0b3ab51c8877 127 * @retval None
bogdanm 84:0b3ab51c8877 128 */
bogdanm 84:0b3ab51c8877 129 #define __HAL_RNG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_RNG_STATE_RESET)
bogdanm 84:0b3ab51c8877 130
bogdanm 84:0b3ab51c8877 131 /**
bogdanm 84:0b3ab51c8877 132 * @brief Enables the RNG peripheral.
bogdanm 84:0b3ab51c8877 133 * @param __HANDLE__: RNG Handle
bogdanm 84:0b3ab51c8877 134 * @retval None
bogdanm 84:0b3ab51c8877 135 */
bogdanm 84:0b3ab51c8877 136 #define __HAL_RNG_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_RNGEN)
bogdanm 84:0b3ab51c8877 137
bogdanm 84:0b3ab51c8877 138 /**
bogdanm 84:0b3ab51c8877 139 * @brief Disables the RNG peripheral.
bogdanm 84:0b3ab51c8877 140 * @param __HANDLE__: RNG Handle
bogdanm 84:0b3ab51c8877 141 * @retval None
bogdanm 84:0b3ab51c8877 142 */
bogdanm 84:0b3ab51c8877 143 #define __HAL_RNG_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_RNGEN)
bogdanm 84:0b3ab51c8877 144
bogdanm 84:0b3ab51c8877 145 /**
bogdanm 84:0b3ab51c8877 146 * @brief Gets the selected RNG's flag status.
bogdanm 84:0b3ab51c8877 147 * @param __HANDLE__: RNG Handle
bogdanm 84:0b3ab51c8877 148 * @param __FLAG__: RNG flag
bogdanm 84:0b3ab51c8877 149 * @retval The new state of RNG_FLAG (SET or RESET).
bogdanm 84:0b3ab51c8877 150 */
bogdanm 84:0b3ab51c8877 151 #define __HAL_RNG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__))
bogdanm 84:0b3ab51c8877 152
bogdanm 84:0b3ab51c8877 153 /**
bogdanm 84:0b3ab51c8877 154 * @brief Clears the RNG's pending flags.
bogdanm 84:0b3ab51c8877 155 * @param __HANDLE__: RNG Handle
bogdanm 84:0b3ab51c8877 156 * @param __FLAG__: RNG flag
bogdanm 84:0b3ab51c8877 157 * @retval None
bogdanm 84:0b3ab51c8877 158 */
bogdanm 84:0b3ab51c8877 159 #define __HAL_RNG_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) &= ~(__FLAG__))
bogdanm 84:0b3ab51c8877 160
bogdanm 84:0b3ab51c8877 161 /**
bogdanm 84:0b3ab51c8877 162 * @brief Enables the RNG interrupts.
bogdanm 84:0b3ab51c8877 163 * @param __HANDLE__: RNG Handle
bogdanm 84:0b3ab51c8877 164 * @retval None
bogdanm 84:0b3ab51c8877 165 */
bogdanm 84:0b3ab51c8877 166 #define __HAL_RNG_ENABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR |= RNG_CR_IE)
bogdanm 84:0b3ab51c8877 167
bogdanm 84:0b3ab51c8877 168 /**
bogdanm 84:0b3ab51c8877 169 * @brief Disables the RNG interrupts.
bogdanm 84:0b3ab51c8877 170 * @param __HANDLE__: RNG Handle
bogdanm 84:0b3ab51c8877 171 * @param __INTERRUPT__: specifies the RNG interrupt source to check.
bogdanm 84:0b3ab51c8877 172 * This parameter can be one of the following values:
bogdanm 84:0b3ab51c8877 173 * @arg RNG_FLAG_DRDY: Data ready interrupt
bogdanm 84:0b3ab51c8877 174 * @arg RNG_FLAG_CECS: Clock error interrupt
bogdanm 84:0b3ab51c8877 175 * @arg RNG_FLAG_SECS: Seed error interrupt
bogdanm 84:0b3ab51c8877 176 * @retval None
bogdanm 84:0b3ab51c8877 177 */
bogdanm 84:0b3ab51c8877 178 #define __HAL_RNG_DISABLE_IT(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~RNG_CR_IE)
bogdanm 84:0b3ab51c8877 179
bogdanm 84:0b3ab51c8877 180 /**
bogdanm 84:0b3ab51c8877 181 * @brief Checks whether the specified RNG interrupt has occurred or not.
bogdanm 84:0b3ab51c8877 182 * @param __HANDLE__: RNG Handle
bogdanm 84:0b3ab51c8877 183 * @param __INTERRUPT__: specifies the RNG interrupt source to check.
bogdanm 84:0b3ab51c8877 184 * This parameter can be one of the following values:
bogdanm 84:0b3ab51c8877 185 * @arg RNG_FLAG_DRDY: Data ready interrupt
bogdanm 84:0b3ab51c8877 186 * @arg RNG_FLAG_CECS: Clock error interrupt
bogdanm 84:0b3ab51c8877 187 * @arg RNG_FLAG_SECS: Seed error interrupt
bogdanm 84:0b3ab51c8877 188 * @retval The new state of RNG_FLAG (SET or RESET).
bogdanm 84:0b3ab51c8877 189 */
bogdanm 84:0b3ab51c8877 190 #define __HAL_RNG_GET_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->SR & (__INTERRUPT__)) == (__INTERRUPT__))
bogdanm 84:0b3ab51c8877 191
bogdanm 84:0b3ab51c8877 192 /* Exported functions --------------------------------------------------------*/
bogdanm 84:0b3ab51c8877 193
bogdanm 84:0b3ab51c8877 194 /* Initialization/de-initialization functions **********************************/
bogdanm 84:0b3ab51c8877 195 HAL_StatusTypeDef HAL_RNG_Init(RNG_HandleTypeDef *hrng);
bogdanm 84:0b3ab51c8877 196 HAL_StatusTypeDef HAL_RNG_DeInit (RNG_HandleTypeDef *hrng);
bogdanm 84:0b3ab51c8877 197 void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng);
bogdanm 84:0b3ab51c8877 198 void HAL_RNG_MspDeInit(RNG_HandleTypeDef *hrng);
bogdanm 84:0b3ab51c8877 199
bogdanm 84:0b3ab51c8877 200 /* Peripheral Control functions ************************************************/
bogdanm 84:0b3ab51c8877 201 uint32_t HAL_RNG_GetRandomNumber(RNG_HandleTypeDef *hrng);
bogdanm 84:0b3ab51c8877 202 uint32_t HAL_RNG_GetRandomNumber_IT(RNG_HandleTypeDef *hrng);
bogdanm 84:0b3ab51c8877 203 void HAL_RNG_IRQHandler(RNG_HandleTypeDef *hrng);
bogdanm 84:0b3ab51c8877 204 void HAL_RNG_ReadyCallback(RNG_HandleTypeDef* hrng);
bogdanm 84:0b3ab51c8877 205 void HAL_RNG_ErrorCallback(RNG_HandleTypeDef *hrng);
bogdanm 84:0b3ab51c8877 206
bogdanm 84:0b3ab51c8877 207 /* Peripheral State functions **************************************************/
bogdanm 84:0b3ab51c8877 208 HAL_RNG_StateTypeDef HAL_RNG_GetState(RNG_HandleTypeDef *hrng);
bogdanm 84:0b3ab51c8877 209
bogdanm 84:0b3ab51c8877 210 #endif /* STM32L051xx && STM32L061xx*/
bogdanm 84:0b3ab51c8877 211 /**
bogdanm 84:0b3ab51c8877 212 * @}
bogdanm 84:0b3ab51c8877 213 */
bogdanm 84:0b3ab51c8877 214
bogdanm 84:0b3ab51c8877 215 /**
bogdanm 84:0b3ab51c8877 216 * @}
bogdanm 84:0b3ab51c8877 217 */
bogdanm 84:0b3ab51c8877 218
bogdanm 84:0b3ab51c8877 219 #ifdef __cplusplus
bogdanm 84:0b3ab51c8877 220 }
bogdanm 84:0b3ab51c8877 221 #endif
bogdanm 84:0b3ab51c8877 222
bogdanm 84:0b3ab51c8877 223 #endif /* __STM32L0xx_HAL_RNG_H */
bogdanm 84:0b3ab51c8877 224
bogdanm 84:0b3ab51c8877 225 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/