Lines Matching refs:hrng
167 HAL_StatusTypeDef HAL_RNG_Init(RNG_HandleTypeDef *hrng) in HAL_RNG_Init() argument
171 if (hrng == NULL) in HAL_RNG_Init()
176 assert_param(IS_RNG_ALL_INSTANCE(hrng->Instance)); in HAL_RNG_Init()
177 assert_param(IS_RNG_CED(hrng->Init.ClockErrorDetection)); in HAL_RNG_Init()
180 if (hrng->State == HAL_RNG_STATE_RESET) in HAL_RNG_Init()
183 hrng->Lock = HAL_UNLOCKED; in HAL_RNG_Init()
185 hrng->ReadyDataCallback = HAL_RNG_ReadyDataCallback; /* Legacy weak ReadyDataCallback */ in HAL_RNG_Init()
186 hrng->ErrorCallback = HAL_RNG_ErrorCallback; /* Legacy weak ErrorCallback */ in HAL_RNG_Init()
188 if (hrng->MspInitCallback == NULL) in HAL_RNG_Init()
190 hrng->MspInitCallback = HAL_RNG_MspInit; /* Legacy weak MspInit */ in HAL_RNG_Init()
194 hrng->MspInitCallback(hrng); in HAL_RNG_Init()
197 if (hrng->State == HAL_RNG_STATE_RESET) in HAL_RNG_Init()
200 hrng->Lock = HAL_UNLOCKED; in HAL_RNG_Init()
203 HAL_RNG_MspInit(hrng); in HAL_RNG_Init()
208 hrng->State = HAL_RNG_STATE_BUSY; in HAL_RNG_Init()
212 __HAL_RNG_DISABLE(hrng); in HAL_RNG_Init()
215 …MODIFY_REG(hrng->Instance->CR, RNG_CR_CED | RNG_CR_CONDRST, hrng->Init.ClockErrorDetection | RNG_C… in HAL_RNG_Init()
219 WRITE_REG(hrng->Instance->HTCR, RNG_HTCFG_1); in HAL_RNG_Init()
221 WRITE_REG(hrng->Instance->HTCR, RNG_HTCFG); in HAL_RNG_Init()
225 CLEAR_BIT(hrng->Instance->CR, RNG_CR_CONDRST); in HAL_RNG_Init()
231 while (HAL_IS_BIT_SET(hrng->Instance->CR, RNG_CR_CONDRST)) in HAL_RNG_Init()
236 if (HAL_IS_BIT_SET(hrng->Instance->CR, RNG_CR_CONDRST)) in HAL_RNG_Init()
238 hrng->State = HAL_RNG_STATE_READY; in HAL_RNG_Init()
239 hrng->ErrorCode = HAL_RNG_ERROR_TIMEOUT; in HAL_RNG_Init()
246 MODIFY_REG(hrng->Instance->CR, RNG_CR_CED, hrng->Init.ClockErrorDetection); in HAL_RNG_Init()
250 __HAL_RNG_ENABLE(hrng); in HAL_RNG_Init()
253 if (__HAL_RNG_GET_IT(hrng, RNG_IT_SEI) != RESET) in HAL_RNG_Init()
255 hrng->State = HAL_RNG_STATE_ERROR; in HAL_RNG_Init()
261 while (__HAL_RNG_GET_FLAG(hrng, RNG_FLAG_SECS) != RESET) in HAL_RNG_Init()
266 if (__HAL_RNG_GET_FLAG(hrng, RNG_FLAG_SECS) != RESET) in HAL_RNG_Init()
268 hrng->State = HAL_RNG_STATE_ERROR; in HAL_RNG_Init()
269 hrng->ErrorCode = HAL_RNG_ERROR_TIMEOUT; in HAL_RNG_Init()
276 hrng->State = HAL_RNG_STATE_READY; in HAL_RNG_Init()
279 hrng->ErrorCode = HAL_RNG_ERROR_NONE; in HAL_RNG_Init()
291 HAL_StatusTypeDef HAL_RNG_DeInit(RNG_HandleTypeDef *hrng) in HAL_RNG_DeInit() argument
298 if (hrng == NULL) in HAL_RNG_DeInit()
305 MODIFY_REG(hrng->Instance->CR, RNG_CR_CED | RNG_CR_CONDRST, RNG_CED_ENABLE | RNG_CR_CONDRST); in HAL_RNG_DeInit()
308 CLEAR_BIT(hrng->Instance->CR, RNG_CR_CONDRST); in HAL_RNG_DeInit()
314 while (HAL_IS_BIT_SET(hrng->Instance->CR, RNG_CR_CONDRST)) in HAL_RNG_DeInit()
319 if (HAL_IS_BIT_SET(hrng->Instance->CR, RNG_CR_CONDRST)) in HAL_RNG_DeInit()
321 hrng->State = HAL_RNG_STATE_READY; in HAL_RNG_DeInit()
322 hrng->ErrorCode = HAL_RNG_ERROR_TIMEOUT; in HAL_RNG_DeInit()
324 __HAL_UNLOCK(hrng); in HAL_RNG_DeInit()
332 CLEAR_BIT(hrng->Instance->CR, RNG_CR_CED); in HAL_RNG_DeInit()
335 CLEAR_BIT(hrng->Instance->CR, RNG_CR_IE | RNG_CR_RNGEN); in HAL_RNG_DeInit()
338 CLEAR_BIT(hrng->Instance->SR, RNG_SR_CEIS | RNG_SR_SEIS); in HAL_RNG_DeInit()
341 if (hrng->MspDeInitCallback == NULL) in HAL_RNG_DeInit()
343 hrng->MspDeInitCallback = HAL_RNG_MspDeInit; /* Legacy weak MspDeInit */ in HAL_RNG_DeInit()
347 hrng->MspDeInitCallback(hrng); in HAL_RNG_DeInit()
350 HAL_RNG_MspDeInit(hrng); in HAL_RNG_DeInit()
354 hrng->State = HAL_RNG_STATE_RESET; in HAL_RNG_DeInit()
357 hrng->ErrorCode = HAL_RNG_ERROR_NONE; in HAL_RNG_DeInit()
360 __HAL_UNLOCK(hrng); in HAL_RNG_DeInit()
372 __weak void HAL_RNG_MspInit(RNG_HandleTypeDef *hrng) in HAL_RNG_MspInit() argument
375 UNUSED(hrng); in HAL_RNG_MspInit()
387 __weak void HAL_RNG_MspDeInit(RNG_HandleTypeDef *hrng) in HAL_RNG_MspDeInit() argument
390 UNUSED(hrng); in HAL_RNG_MspDeInit()
409 HAL_StatusTypeDef HAL_RNG_RegisterCallback(RNG_HandleTypeDef *hrng, HAL_RNG_CallbackIDTypeDef Callb… in HAL_RNG_RegisterCallback() argument
417 hrng->ErrorCode = HAL_RNG_ERROR_INVALID_CALLBACK; in HAL_RNG_RegisterCallback()
421 if (HAL_RNG_STATE_READY == hrng->State) in HAL_RNG_RegisterCallback()
426 hrng->ErrorCallback = pCallback; in HAL_RNG_RegisterCallback()
430 hrng->MspInitCallback = pCallback; in HAL_RNG_RegisterCallback()
434 hrng->MspDeInitCallback = pCallback; in HAL_RNG_RegisterCallback()
439 hrng->ErrorCode = HAL_RNG_ERROR_INVALID_CALLBACK; in HAL_RNG_RegisterCallback()
445 else if (HAL_RNG_STATE_RESET == hrng->State) in HAL_RNG_RegisterCallback()
450 hrng->MspInitCallback = pCallback; in HAL_RNG_RegisterCallback()
454 hrng->MspDeInitCallback = pCallback; in HAL_RNG_RegisterCallback()
459 hrng->ErrorCode = HAL_RNG_ERROR_INVALID_CALLBACK; in HAL_RNG_RegisterCallback()
468 hrng->ErrorCode = HAL_RNG_ERROR_INVALID_CALLBACK; in HAL_RNG_RegisterCallback()
487 HAL_StatusTypeDef HAL_RNG_UnRegisterCallback(RNG_HandleTypeDef *hrng, HAL_RNG_CallbackIDTypeDef Cal… in HAL_RNG_UnRegisterCallback() argument
492 if (HAL_RNG_STATE_READY == hrng->State) in HAL_RNG_UnRegisterCallback()
497 hrng->ErrorCallback = HAL_RNG_ErrorCallback; /* Legacy weak ErrorCallback */ in HAL_RNG_UnRegisterCallback()
501 hrng->MspInitCallback = HAL_RNG_MspInit; /* Legacy weak MspInit */ in HAL_RNG_UnRegisterCallback()
505 hrng->MspDeInitCallback = HAL_RNG_MspDeInit; /* Legacy weak MspDeInit */ in HAL_RNG_UnRegisterCallback()
510 hrng->ErrorCode = HAL_RNG_ERROR_INVALID_CALLBACK; in HAL_RNG_UnRegisterCallback()
516 else if (HAL_RNG_STATE_RESET == hrng->State) in HAL_RNG_UnRegisterCallback()
521 hrng->MspInitCallback = HAL_RNG_MspInit; /* Legacy weak MspInit */ in HAL_RNG_UnRegisterCallback()
525 hrng->MspDeInitCallback = HAL_RNG_MspDeInit; /* Legacy weak MspInit */ in HAL_RNG_UnRegisterCallback()
530 hrng->ErrorCode = HAL_RNG_ERROR_INVALID_CALLBACK; in HAL_RNG_UnRegisterCallback()
539 hrng->ErrorCode = HAL_RNG_ERROR_INVALID_CALLBACK; in HAL_RNG_UnRegisterCallback()
554 HAL_StatusTypeDef HAL_RNG_RegisterReadyDataCallback(RNG_HandleTypeDef *hrng, pRNG_ReadyDataCallback… in HAL_RNG_RegisterReadyDataCallback() argument
561 hrng->ErrorCode = HAL_RNG_ERROR_INVALID_CALLBACK; in HAL_RNG_RegisterReadyDataCallback()
565 __HAL_LOCK(hrng); in HAL_RNG_RegisterReadyDataCallback()
567 if (HAL_RNG_STATE_READY == hrng->State) in HAL_RNG_RegisterReadyDataCallback()
569 hrng->ReadyDataCallback = pCallback; in HAL_RNG_RegisterReadyDataCallback()
574 hrng->ErrorCode = HAL_RNG_ERROR_INVALID_CALLBACK; in HAL_RNG_RegisterReadyDataCallback()
580 __HAL_UNLOCK(hrng); in HAL_RNG_RegisterReadyDataCallback()
590 HAL_StatusTypeDef HAL_RNG_UnRegisterReadyDataCallback(RNG_HandleTypeDef *hrng) in HAL_RNG_UnRegisterReadyDataCallback() argument
595 __HAL_LOCK(hrng); in HAL_RNG_UnRegisterReadyDataCallback()
597 if (HAL_RNG_STATE_READY == hrng->State) in HAL_RNG_UnRegisterReadyDataCallback()
599 hrng->ReadyDataCallback = HAL_RNG_ReadyDataCallback; /* Legacy weak ReadyDataCallback */ in HAL_RNG_UnRegisterReadyDataCallback()
604 hrng->ErrorCode = HAL_RNG_ERROR_INVALID_CALLBACK; in HAL_RNG_UnRegisterReadyDataCallback()
610 __HAL_UNLOCK(hrng); in HAL_RNG_UnRegisterReadyDataCallback()
654 HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber(RNG_HandleTypeDef *hrng, uint32_t *random32bit) in HAL_RNG_GenerateRandomNumber() argument
660 __HAL_LOCK(hrng); in HAL_RNG_GenerateRandomNumber()
663 if (hrng->State == HAL_RNG_STATE_READY) in HAL_RNG_GenerateRandomNumber()
666 hrng->State = HAL_RNG_STATE_BUSY; in HAL_RNG_GenerateRandomNumber()
669 if (__HAL_RNG_GET_IT(hrng, RNG_IT_SEI) != RESET) in HAL_RNG_GenerateRandomNumber()
672 hrng->ErrorCode = HAL_RNG_ERROR_SEED; in HAL_RNG_GenerateRandomNumber()
674 status = RNG_RecoverSeedError(hrng); in HAL_RNG_GenerateRandomNumber()
686 while (__HAL_RNG_GET_FLAG(hrng, RNG_FLAG_DRDY) == RESET) in HAL_RNG_GenerateRandomNumber()
691 if (__HAL_RNG_GET_FLAG(hrng, RNG_FLAG_DRDY) == RESET) in HAL_RNG_GenerateRandomNumber()
693 hrng->State = HAL_RNG_STATE_READY; in HAL_RNG_GenerateRandomNumber()
694 hrng->ErrorCode = HAL_RNG_ERROR_TIMEOUT; in HAL_RNG_GenerateRandomNumber()
696 __HAL_UNLOCK(hrng); in HAL_RNG_GenerateRandomNumber()
703 hrng->RandomNumber = hrng->Instance->DR; in HAL_RNG_GenerateRandomNumber()
707 if (__HAL_RNG_GET_IT(hrng, RNG_IT_SEI) != RESET) in HAL_RNG_GenerateRandomNumber()
710 hrng->ErrorCode = HAL_RNG_ERROR_SEED; in HAL_RNG_GenerateRandomNumber()
713 CLEAR_BIT(hrng->Instance->SR, RNG_FLAG_DRDY); in HAL_RNG_GenerateRandomNumber()
717 *random32bit = hrng->RandomNumber; in HAL_RNG_GenerateRandomNumber()
720 *random32bit = hrng->RandomNumber; in HAL_RNG_GenerateRandomNumber()
723 hrng->State = HAL_RNG_STATE_READY; in HAL_RNG_GenerateRandomNumber()
727 hrng->ErrorCode = HAL_RNG_ERROR_BUSY; in HAL_RNG_GenerateRandomNumber()
732 __HAL_UNLOCK(hrng); in HAL_RNG_GenerateRandomNumber()
743 HAL_StatusTypeDef HAL_RNG_GenerateRandomNumber_IT(RNG_HandleTypeDef *hrng) in HAL_RNG_GenerateRandomNumber_IT() argument
748 __HAL_LOCK(hrng); in HAL_RNG_GenerateRandomNumber_IT()
751 if (hrng->State == HAL_RNG_STATE_READY) in HAL_RNG_GenerateRandomNumber_IT()
754 hrng->State = HAL_RNG_STATE_BUSY; in HAL_RNG_GenerateRandomNumber_IT()
757 __HAL_RNG_ENABLE_IT(hrng); in HAL_RNG_GenerateRandomNumber_IT()
762 __HAL_UNLOCK(hrng); in HAL_RNG_GenerateRandomNumber_IT()
764 hrng->ErrorCode = HAL_RNG_ERROR_BUSY; in HAL_RNG_GenerateRandomNumber_IT()
792 void HAL_RNG_IRQHandler(RNG_HandleTypeDef *hrng) in HAL_RNG_IRQHandler() argument
797 if (__HAL_RNG_GET_IT(hrng, RNG_IT_CEI) != RESET) in HAL_RNG_IRQHandler()
800 hrng->ErrorCode = HAL_RNG_ERROR_CLOCK; in HAL_RNG_IRQHandler()
803 else if (__HAL_RNG_GET_IT(hrng, RNG_IT_SEI) != RESET) in HAL_RNG_IRQHandler()
806 if (__HAL_RNG_GET_FLAG(hrng, RNG_FLAG_SECS) == RESET) in HAL_RNG_IRQHandler()
810 CLEAR_BIT(hrng->Instance->SR, RNG_IT_SEI); in HAL_RNG_IRQHandler()
815 hrng->ErrorCode = HAL_RNG_ERROR_SEED; in HAL_RNG_IRQHandler()
818 __HAL_RNG_DISABLE_IT(hrng); in HAL_RNG_IRQHandler()
829 hrng->State = HAL_RNG_STATE_ERROR; in HAL_RNG_IRQHandler()
833 hrng->ErrorCallback(hrng); in HAL_RNG_IRQHandler()
836 HAL_RNG_ErrorCallback(hrng); in HAL_RNG_IRQHandler()
840 __HAL_RNG_CLEAR_IT(hrng, RNG_IT_CEI | RNG_IT_SEI); in HAL_RNG_IRQHandler()
846 if (__HAL_RNG_GET_IT(hrng, RNG_IT_DRDY) != RESET) in HAL_RNG_IRQHandler()
849 __HAL_RNG_DISABLE_IT(hrng); in HAL_RNG_IRQHandler()
852 hrng->RandomNumber = hrng->Instance->DR; in HAL_RNG_IRQHandler()
854 if (hrng->State != HAL_RNG_STATE_ERROR) in HAL_RNG_IRQHandler()
857 hrng->State = HAL_RNG_STATE_READY; in HAL_RNG_IRQHandler()
859 __HAL_UNLOCK(hrng); in HAL_RNG_IRQHandler()
863 hrng->ReadyDataCallback(hrng, hrng->RandomNumber); in HAL_RNG_IRQHandler()
866 HAL_RNG_ReadyDataCallback(hrng, hrng->RandomNumber); in HAL_RNG_IRQHandler()
878 uint32_t HAL_RNG_ReadLastRandomNumber(RNG_HandleTypeDef *hrng) in HAL_RNG_ReadLastRandomNumber() argument
880 return (hrng->RandomNumber); in HAL_RNG_ReadLastRandomNumber()
895 __weak void HAL_RNG_ReadyDataCallback(RNG_HandleTypeDef *hrng, uint32_t random32bit) in HAL_RNG_ReadyDataCallback() argument
898 UNUSED(hrng); in HAL_RNG_ReadyDataCallback()
911 __weak void HAL_RNG_ErrorCallback(RNG_HandleTypeDef *hrng) in HAL_RNG_ErrorCallback() argument
914 UNUSED(hrng); in HAL_RNG_ErrorCallback()
945 HAL_RNG_StateTypeDef HAL_RNG_GetState(RNG_HandleTypeDef *hrng) in HAL_RNG_GetState() argument
947 return hrng->State; in HAL_RNG_GetState()
955 uint32_t HAL_RNG_GetError(RNG_HandleTypeDef *hrng) in HAL_RNG_GetError() argument
958 return hrng->ErrorCode; in HAL_RNG_GetError()
978 HAL_StatusTypeDef RNG_RecoverSeedError(RNG_HandleTypeDef *hrng) in RNG_RecoverSeedError() argument
983 if (__HAL_RNG_GET_FLAG(hrng, RNG_FLAG_SECS) == RESET) in RNG_RecoverSeedError()
987 CLEAR_BIT(hrng->Instance->SR, RNG_IT_SEI); in RNG_RecoverSeedError()
992 SET_BIT(hrng->Instance->CR, RNG_CR_CONDRST); in RNG_RecoverSeedError()
994 CLEAR_BIT(hrng->Instance->CR, RNG_CR_CONDRST); in RNG_RecoverSeedError()
1003 hrng->State = HAL_RNG_STATE_READY; in RNG_RecoverSeedError()
1004 hrng->ErrorCode |= HAL_RNG_ERROR_TIMEOUT; in RNG_RecoverSeedError()
1006 __HAL_UNLOCK(hrng); in RNG_RecoverSeedError()
1009 hrng->ErrorCallback(hrng); in RNG_RecoverSeedError()
1012 HAL_RNG_ErrorCallback(hrng); in RNG_RecoverSeedError()
1016 } while (HAL_IS_BIT_SET(hrng->Instance->CR, RNG_CR_CONDRST)); in RNG_RecoverSeedError()
1018 if (__HAL_RNG_GET_IT(hrng, RNG_IT_SEI) != RESET) in RNG_RecoverSeedError()
1021 CLEAR_BIT(hrng->Instance->SR, RNG_IT_SEI); in RNG_RecoverSeedError()
1031 hrng->State = HAL_RNG_STATE_READY; in RNG_RecoverSeedError()
1032 hrng->ErrorCode |= HAL_RNG_ERROR_TIMEOUT; in RNG_RecoverSeedError()
1034 __HAL_UNLOCK(hrng); in RNG_RecoverSeedError()
1037 hrng->ErrorCallback(hrng); in RNG_RecoverSeedError()
1040 HAL_RNG_ErrorCallback(hrng); in RNG_RecoverSeedError()
1044 } while (HAL_IS_BIT_SET(hrng->Instance->SR, RNG_FLAG_SECS)); in RNG_RecoverSeedError()
1047 hrng->ErrorCode &= ~ HAL_RNG_ERROR_SEED; in RNG_RecoverSeedError()