STM32H7: Support the RNG Peripheral

The random number generator on the STM32H7 is identical to the v1 RNG
already present in the library. So use that, and make sure that the RCC
knows about the peripheral.

Originally filed at: https://github.com/libopencm3/libopencm3/pull/1244

Reviewed-by: Karl Palsson <karlp@tweak.net.au>
 * whitespace changes from review
This commit is contained in:
Matt Walker
2020-08-06 16:28:45 -04:00
committed by Karl Palsson
parent b47d769369
commit 1c54d58c81
5 changed files with 47 additions and 0 deletions

View File

@@ -44,6 +44,7 @@ OBJS += fmc_common_f47.o
OBJS += gpio_common_all.o gpio_common_f0234.o
OBJS += pwr.o rcc.o
OBJS += rcc_common_all.o
OBJS += rng_common_v1.o
OBJS += spi_common_all.o spi_common_v2.o
OBJS += timer_common_all.o
OBJS += usart_common_v2.o usart_common_fifos.o

View File

@@ -361,6 +361,11 @@ void rcc_set_peripheral_clk_sel(uint32_t periph, uint32_t sel) {
mask = RCC_D2CCIP1R_FDCANSEL_MASK << RCC_D2CCIP1R_FDCANSEL_SHIFT;
val = sel << RCC_D2CCIP1R_FDCANSEL_SHIFT;
break;
case RNG_BASE:
reg = &RCC_D2CCIP2R;
mask = RCC_D2CCIP2R_RNGSEL_MASK << RCC_D2CCIP2R_RNGSEL_SHIFT;
val = sel << RCC_D2CCIP2R_RNGSEL_SHIFT;
break;
case SPI1_BASE:
case SPI2_BASE:
case SPI3_BASE:
@@ -406,6 +411,11 @@ void rcc_set_fdcan_clksel(uint8_t clksel) {
RCC_D2CCIP1R |= clksel << RCC_D2CCIP1R_FDCANSEL_SHIFT;
}
void rcc_set_rng_clksel(uint8_t clksel) {
RCC_D2CCIP2R &= ~(RCC_D2CCIP2R_RNGSEL_MASK << RCC_D2CCIP2R_RNGSEL_SHIFT);
RCC_D2CCIP2R |= clksel << RCC_D2CCIP2R_RNGSEL_SHIFT;
}
void rcc_set_spi123_clksel(uint8_t clksel) {
RCC_D2CCIP1R &= ~(RCC_D2CCIP1R_SPI123SEL_MASK << RCC_D2CCIP1R_SPI123SEL_SHIFT);
RCC_D2CCIP1R |= clksel << RCC_D2CCIP1R_SPI123SEL_SHIFT;