Skip to content

Commit bda200e

Browse files
committed
rework after directory moves
1 parent e189bc7 commit bda200e

File tree

4 files changed

+6
-240
lines changed

4 files changed

+6
-240
lines changed

hal/targets/hal/TARGET_STM/TARGET_STM32L0/trng_api.c

Lines changed: 0 additions & 80 deletions
This file was deleted.

targets/TARGET_STM/TARGET_STM32F4/trng_api.c

Lines changed: 0 additions & 82 deletions
This file was deleted.

targets/TARGET_STM/TARGET_STM32F7/trng_api.c

Lines changed: 0 additions & 76 deletions
This file was deleted.

hal/targets/hal/TARGET_STM/TARGET_STM32L4/trng_api.c renamed to targets/TARGET_STM/trng_api.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Hardware entropy collector for the STM32L4 family
2+
* Hardware entropy collector for the STM32 families
33
*
44
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
55
* SPDX-License-Identifier: Apache-2.0
@@ -36,12 +36,14 @@ static void trng_get_byte(trng_t *obj, unsigned char *byte )
3636

3737
void trng_init(trng_t *obj)
3838
{
39+
#if defined(TARGET_STM32L4)
3940
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;
4041

4142
/*Select PLLQ output as RNG clock source */
4243
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RNG;
4344
PeriphClkInitStruct.RngClockSelection = RCC_RNGCLKSOURCE_PLL;
4445
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);
46+
#endif
4547

4648
/* RNG Peripheral clock enable */
4749
__HAL_RCC_RNG_CLK_ENABLE();
@@ -50,6 +52,9 @@ void trng_init(trng_t *obj)
5052
obj->handle.Instance = RNG;
5153
HAL_RNG_Init(&obj->handle);
5254

55+
/* first random number generated after setting the RNGEN bit should not be used */
56+
HAL_RNG_GetRandomNumber(&obj->handle);
57+
5358
}
5459

5560
void trng_free(trng_t *obj)
@@ -80,5 +85,4 @@ int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_l
8085
return( ret );
8186
}
8287

83-
8488
#endif

0 commit comments

Comments
 (0)