diff --git a/src/amiga.c b/src/amiga.c index bfbae43..17b4ce1 100644 --- a/src/amiga.c +++ b/src/amiga.c @@ -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 */ diff --git a/src/stm32f10x.c b/src/stm32f10x.c index 5159ca3..47c5a5d 100644 --- a/src/stm32f10x.c +++ b/src/stm32f10x.c @@ -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);