Skip to content

Commit

Permalink
Move allegedly unsafe afio->mapr RMW
Browse files Browse the repository at this point in the history
  • Loading branch information
penfold42 committed Dec 3, 2019
1 parent 8ab2e4f commit 512d557
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/amiga.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void amiga_init(void)

/* We map PB4 (KBCLK) to TIM3,CH1 and use its input filter and edge
* detector to generate interrupts on clock transitions. */
afio->mapr |= AFIO_MAPR_TIM3_REMAP_PARTIAL;

/* f_sampling = 72MHz/8 = 9MHz, N=8 -> must be stable for 889us. */
tim3->ccmr1 = TIM_CCMR1_CC1S(TIM_CCS_INPUT_TI1) | TIM_CCMR1_IC1F(9);
tim3->ccer = TIM_CCER_CC1E | TIM_CCER_CC1P; /* Falling edge */
Expand Down
7 changes: 5 additions & 2 deletions src/stm32f10x.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,11 @@ static void peripheral_init(void)

rcc->ahbenr = RCC_AHBENR_DMA1EN;

/* Turn off serial-wire JTAG and reclaim the GPIOs. */
afio->mapr = AFIO_MAPR_SWJ_CFG_JTAGDISABLE;
/* Turn off serial-wire JTAG and reclaim the GPIOs.
* Amiga keyboard map PB4 (KBCLK) to TIM3,CH1 and use its input filter
* and edge detector to generate interrupts on clock transitions. */
afio->mapr = (AFIO_MAPR_SWJ_CFG_JTAGDISABLE
| AFIO_MAPR_TIM3_REMAP_PARTIAL);

/* All pins in a stable state. */
gpio_init(gpioa);
Expand Down

0 comments on commit 512d557

Please sign in to comment.