Skip to content

Commit 7239be2

Browse files
author
Edmund Hsu
committed
Update trng_api.c
- Maintain compatible code for ARM 5 and ARM 6 while default alignment settings differ. - Instance memory containing memory pointers must be 4 byte aligned for all compilers regardless compilers' settings. - uint32_t is recommended to replace uint8_t for instance memory declaration because uint32_t guarantee 4 byte alignment.
1 parent 7c8cbd6 commit 7239be2

File tree

1 file changed

+8
-1
lines changed
  • targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/api

1 file changed

+8
-1
lines changed

targets/TARGET_Analog_Devices/TARGET_ADUCM302X/TARGET_ADUCM3029/api/trng_api.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@
5454
#define TRNG_CNT_VAL 4095
5555
#define TRNG_PRESCALER 2
5656

57-
/* RNG Device memory */
57+
/*******************************************************************************
58+
RNG Device memory is the instance of ADI_RNG_DEV_DATA_TYPE that contains
59+
pointers and requires 4 byte alignment. The use of uint8_t may cause memory
60+
access fault for some compilers which are not configured to handle unaligned
61+
accesses to SRAM. The size in uint8_t for RngDevMem is ADI_RNG_MEMORY_SIZE.
62+
The size in uint32_t for RngDevMem is recalculated to be
63+
(ADI_RNG_MEMORY_SIZE + 3)/4.
64+
*******************************************************************************/
5865
static uint32_t RngDevMem[(ADI_RNG_MEMORY_SIZE + 3)/4];
5966

6067
void trng_init(trng_t *obj)

0 commit comments

Comments
 (0)