From 70c14fb23ed9eb08f8d310f4ad2e3448db489be6 Mon Sep 17 00:00:00 2001 From: logicog Date: Sat, 29 Nov 2025 12:35:13 +0100 Subject: [PATCH] Add get_random_32() --- rtl837x_common.h | 1 + rtlplayground.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/rtl837x_common.h b/rtl837x_common.h index cab8b96..5156603 100644 --- a/rtl837x_common.h +++ b/rtl837x_common.h @@ -104,5 +104,6 @@ uint16_t strtox(register __xdata uint8_t *dst, register __code const char *s); void tcpip_output(void); void print_string_x(__xdata char *p); uint8_t read_flash(uint8_t bank, __code uint8_t *addr); +void get_random_32(void); #endif diff --git a/rtlplayground.c b/rtlplayground.c index 946e472..bba57a4 100644 --- a/rtlplayground.c +++ b/rtlplayground.c @@ -402,6 +402,18 @@ void sfr_set_zero(void) { } } + +/* + * Create 32 random number in sfr_data + */ +void get_random_32(void) +{ + // In order to get a new random numner, this bit has to be set each time! + reg_bit_set(RTL837X_RLDP_RLPP, RLDP_RND_EN); + reg_read_m(RTL837X_RAND_NUM0); +} + + /* * Transfer Network Interface RX data from the ASIC to the 8051 XMEM * data will be stored in the rx_header structure