blob: 9a57d77b65e2bd61cd22766655086a2ae07f7d01 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/**************************************************************************//**
*
* @copyright (C) 2020 Nuvoton Technology Corp. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-3-15 Wayne First version
*
******************************************************************************/
#include <rtconfig.h>
#if (defined(BSP_USING_TRNG) && defined(RT_HWCRYPTO_USING_RNG))
#include <rtdevice.h>
#include "NuMicro.h"
#define NU_CRYPTO_TRNG_NAME "nu_TRNG"
#define LOG_TAG "TRNG"
#define DBG_ENABLE
#define DBG_SECTION_NAME "TRNG"
#define DBG_LEVEL DBG_INFO
#define DBG_COLOR
#include <rtdbg.h>
/* Private variables ------------------------------------------------------------*/
rt_err_t nu_trng_init(void)
{
CLK_EnableModuleClock(TRNG_MODULE);
SYS_ResetModule(TRNG_RST);
TRNG_Open();
return RT_EOK;
}
rt_uint32_t nu_trng_rand(struct hwcrypto_rng *ctx)
{
uint32_t u32RNGValue;
TRNG_GenWord(&u32RNGValue);
return u32RNGValue;
}
#endif //#if (defined(BSP_USING_TRNG) && defined(RT_HWCRYPTO_USING_RNG))
|