stm32f1: reset peripherals in enable_pcclock()

Some bootloaders do not disable peripherals in use before jumping to the application.  Reset peripherals to assure correct operation.

SIgned-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2021-04-03 06:54:07 -04:00 committed by KevinOConnor
parent 5729109727
commit 689c2f9baf
1 changed files with 4 additions and 0 deletions

View File

@ -21,10 +21,14 @@ enable_pclock(uint32_t periph_base)
uint32_t pos = (periph_base - APB1PERIPH_BASE) / 0x400; uint32_t pos = (periph_base - APB1PERIPH_BASE) / 0x400;
RCC->APB1ENR |= (1<<pos); RCC->APB1ENR |= (1<<pos);
RCC->APB1ENR; RCC->APB1ENR;
RCC->APB1RSTR |= (1<<pos);
RCC->APB1RSTR &= ~(1<<pos);
} else if (periph_base < AHBPERIPH_BASE) { } else if (periph_base < AHBPERIPH_BASE) {
uint32_t pos = (periph_base - APB2PERIPH_BASE) / 0x400; uint32_t pos = (periph_base - APB2PERIPH_BASE) / 0x400;
RCC->APB2ENR |= (1<<pos); RCC->APB2ENR |= (1<<pos);
RCC->APB2ENR; RCC->APB2ENR;
RCC->APB2RSTR |= (1<<pos);
RCC->APB2RSTR &= ~(1<<pos);
} else { } else {
uint32_t pos = (periph_base - AHBPERIPH_BASE) / 0x400; uint32_t pos = (periph_base - AHBPERIPH_BASE) / 0x400;
RCC->AHBENR |= (1<<pos); RCC->AHBENR |= (1<<pos);