HPM SDK
HPMicro Software Development Kit
hpm_rng_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef HPM_RNG_DRV_H
9 #define HPM_RNG_DRV_H
10 #include "hpm_common.h"
11 #include "hpm_rng_regs.h"
12 
13 enum {
17 };
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
24 
25 hpm_stat_t rng_rand_wait(RNG_Type *ptr, void *buf, uint32_t count_in_byte);
26 
27 hpm_stat_t rng_rand_no_wait(RNG_Type *ptr, void *buf, uint32_t count_in_byte);
28 
30 
32 
33 static inline void rng_sw_reset(RNG_Type *ptr)
34 {
35  ptr->CMD |= RNG_CMD_SFTRST_MASK;
36 }
37 
38 static inline void rng_clear_interrupt_error(RNG_Type *ptr)
39 {
40  ptr->CMD |= RNG_CMD_CLRERR_MASK;
41 }
42 
43 static inline void rng_clear_interrupt(RNG_Type *ptr)
44 {
45  ptr->CMD |= RNG_CMD_CLRINT_MASK;
46 }
47 
48 static inline bool rng_is_busy(RNG_Type *ptr)
49 {
50  return ((ptr->STA & RNG_STA_BUSY_MASK) == RNG_STA_BUSY_MASK) ? true : false;
51 }
52 
53 static inline bool rng_need_reseed(RNG_Type *ptr)
54 {
55  return ((ptr->STA & RNG_STA_RSDREQ_MASK) == RNG_STA_RSDREQ_MASK) ? true : false;
56 }
57 
58 #ifdef __cplusplus
59 }
60 #endif
61 #endif /* HPM_RNG_DRV_H */
62 
#define RNG_STA_RSDREQ_MASK
Definition: hpm_rng_regs.h:203
#define RNG_CMD_SFTRST_MASK
Definition: hpm_rng_regs.h:31
#define RNG_STA_BUSY_MASK
Definition: hpm_rng_regs.h:221
#define RNG_CMD_CLRERR_MASK
Definition: hpm_rng_regs.h:43
#define RNG_CMD_CLRINT_MASK
Definition: hpm_rng_regs.h:55
uint32_t hpm_stat_t
Definition: hpm_common.h:123
#define MAKE_STATUS(group, code)
Definition: hpm_common.h:132
@ status_group_rng
Definition: hpm_common.h:150
hpm_stat_t rng_rand_no_wait(RNG_Type *ptr, void *buf, uint32_t count_in_byte)
Definition: hpm_rng_drv.c:87
hpm_stat_t rng_feed_rand_to_sdp(RNG_Type *ptr)
Definition: hpm_rng_drv.c:26
hpm_stat_t rng_rand_wait(RNG_Type *ptr, void *buf, uint32_t count_in_byte)
Definition: hpm_rng_drv.c:82
static void rng_sw_reset(RNG_Type *ptr)
Definition: hpm_rng_drv.h:33
static bool rng_need_reseed(RNG_Type *ptr)
Definition: hpm_rng_drv.h:53
@ status_rng_not_available
Definition: hpm_rng_drv.h:16
@ status_rng_busy
Definition: hpm_rng_drv.h:14
@ status_rng_selftest_failed
Definition: hpm_rng_drv.h:15
hpm_stat_t rng_init(RNG_Type *ptr)
Definition: hpm_rng_drv.c:92
static void rng_clear_interrupt_error(RNG_Type *ptr)
Definition: hpm_rng_drv.h:38
static void rng_clear_interrupt(RNG_Type *ptr)
Definition: hpm_rng_drv.h:43
static bool rng_is_busy(RNG_Type *ptr)
Definition: hpm_rng_drv.h:48
hpm_stat_t rng_run_selftest(RNG_Type *ptr)
Definition: hpm_rng_drv.c:10
Definition: hpm_rng_regs.h:12
__R uint32_t STA
Definition: hpm_rng_regs.h:15
__RW uint32_t CMD
Definition: hpm_rng_regs.h:13