1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 #ifndef __HAL_TRNG_H__ 5 #define __HAL_TRNG_H__ 6 #ifdef __cplusplus 7 extern "C" { 8 #endif 9 #ifdef CHIP_HAS_TRNG 10 #include "plat_types.h" 11 12 13 enum HAL_TRNG_RET { 14 HAL_TRNG_RET_OK = 0, 15 HAL_TRNG_RET_FAILED, 16 }; 17 typedef unsigned int HAL_TRNG_RET_ENUM; 18 19 enum HAL_TRNG_RND_SRC_SEL { 20 HAL_TRNG_RND_SRC_SHORTEST = 0, 21 HAL_TRNG_RND_SRC_SHORT, 22 HAL_TRNG_RND_SRC_LONG, 23 HAL_TRNG_RND_SRC_LONGEST, 24 }; 25 typedef unsigned int HAL_TRNG_RND_SRC_SEL_ENUM; 26 27 struct HAL_TRNG_CFG_T { 28 uint32_t sample_cntr1; // must not be less than 0x11 29 HAL_TRNG_RND_SRC_SEL_ENUM rnd_src_sel; 30 }; 31 32 HAL_TRNG_RET_ENUM hal_trng_open(const struct HAL_TRNG_CFG_T *cfg); 33 void hal_trng_close(void); 34 void get_trngdata(uint32* data); 35 36 #endif // CHIP_HAS_TRNG 37 #ifdef __cplusplus 38 } 39 #endif 40 #endif //__HAL_TRNG_H__ 41