From: Christian Lamparter Date: Sun, 14 Feb 2016 23:33:56 +0000 (+0100) Subject: carl9170 firmware: add get_random_u16 helper X-Git-Url: https://jxself.org/git/?p=carl9170fw.git;a=commitdiff_plain;h=b16e4b8d1a59abc67e1e7f2f4a5d297fbac6ee73 carl9170 firmware: add get_random_u16 helper The HW has a built-in random number generator. This patch adds a convenient helper to get random 16-bit values in the firmware. Signed-off-by: Christian Lamparter --- diff --git a/carlfw/include/gpio.h b/carlfw/include/gpio.h index a9c0b88..56c554a 100644 --- a/carlfw/include/gpio.h +++ b/carlfw/include/gpio.h @@ -36,6 +36,11 @@ static inline __inline void led_set(const unsigned int ledstate) set(AR9170_GPIO_REG_PORT_DATA, ledstate); } +static inline __inline u16 get_random_u16(void) +{ + return getw(AR9170_RAND_REG_NUM); +} + #ifdef CONFIG_CARL9170FW_GPIO_INTERRUPT void gpio_timer(void); diff --git a/carlfw/include/io.h b/carlfw/include/io.h index d480594..5bdc821 100644 --- a/carlfw/include/io.h +++ b/carlfw/include/io.h @@ -149,4 +149,9 @@ static inline __inline void orb(const volatile uint32_t addr, const volatile uin setb(addr, getb(addr) | val); } +static inline __inline uint16_t getw(const volatile uint32_t addr) +{ + return readw((const volatile void *) addr); +} + #endif /* __CARL9170FW_IO_H */