Skip to content

Commit bab27ec

Browse files
committed
lib: stm32wb0: Call appropriate Zephyr function for using TRNG peripheral
Call appropriate Zephyr function for using TRNG peripheral. Modify README to include the new changes. Signed-off-by: Ali Hozhabri <[email protected]>
1 parent 5dcc08c commit bab27ec

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/stm32wb0/BLE_TransparentMode/STM32_BLE/Target/bleplat.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "osal.h"
3333
#include "stm32wb0x.h"
3434
#include "stm32wb0x_ll_radio.h"
35+
#include <zephyr/drivers/entropy.h>
3536

3637
#define PLL_ADC_CALIB_CORR 2
3738
#define CP_ISEL_Msk (0x07UL)
@@ -40,6 +41,8 @@
4041
#define LL_DUMMY_ACCESS_ADDRESS (0x00000000U)
4142
#define LL_DTM_ACCESS_ADDRESS (0x71764129U)
4243

44+
const struct device *rng_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_entropy));
45+
4346
#if defined(STM32WB06) || defined(STM32WB07) || defined(STM32WB09)
4447
uint32_t SYNTH0_ANA_ENG_bak, PWR_ENGTRIM_bak;
4548
#endif
@@ -120,12 +123,14 @@ int32_t BLEPLAT_AesCMACEncryptFinish(BLEPLAT_AESCMACctxTypeDef *pAESCMACctx,
120123

121124
void BLEPLAT_RngGetRandom16(uint16_t* num)
122125
{
123-
HW_RNG_GetRandom16(num);
126+
uint16_t len = 2;
127+
entropy_get_entropy_isr(rng_dev, (uint8_t *)num, len, 1);
124128
}
125129

126130
void BLEPLAT_RngGetRandom32(uint32_t* num)
127131
{
128-
HW_RNG_GetRandom32(num);
132+
uint16_t len = 4;
133+
entropy_get_entropy_isr(rng_dev, (uint8_t *)num, len, 1);
129134
}
130135

131136
uint8_t BLEPLAT_DBmToPALevel(int8_t TX_dBm)

lib/stm32wb0/README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,5 +127,9 @@ Patch List:
127127
Impacted file: app_conf.h
128128
- Exclude HAL_UART_MspInit and HAL_UART_MspDeInit from compilation:
129129
Impacted file: stm32wb0x_hal_msp.c
130+
- Included Zephyr "entropy.h":
131+
Impacted file: bleplat.c
132+
- Modified BLEPLAT_RngGetRandom16 and BLEPLAT_RngGetRandom32 functions:
133+
Impacted file: bleplat.c
130134
- dos2unix applied
131135
- trailing white spaces removed

0 commit comments

Comments
 (0)