Bsongis/rotary encoder delay (#6503)
Rotary encoder fixed on X10 / X12S
This commit is contained in:
@@ -41,60 +41,6 @@ void watchdogInit(unsigned int duration)
|
||||
IWDG->KR = 0xCCCC; // start
|
||||
}
|
||||
|
||||
// Start TIMER7 at 2000000Hz
|
||||
void init2MhzTimer()
|
||||
{
|
||||
TIMER_2MHz_TIMER->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 2000000 - 1; // 0.5 uS, 2 MHz
|
||||
TIMER_2MHz_TIMER->ARR = 65535;
|
||||
TIMER_2MHz_TIMER->CR2 = 0;
|
||||
TIMER_2MHz_TIMER->CR1 = TIM_CR1_CEN;
|
||||
}
|
||||
|
||||
// Starts TIMER at 1000Hz
|
||||
void init1msTimer()
|
||||
{
|
||||
INTERRUPT_xMS_TIMER->ARR = 999; // 1mS in uS
|
||||
INTERRUPT_xMS_TIMER->PSC = (PERI1_FREQUENCY * TIMER_MULT_APB1) / 1000000 - 1; // 1uS
|
||||
INTERRUPT_xMS_TIMER->CCER = 0;
|
||||
INTERRUPT_xMS_TIMER->CCMR1 = 0;
|
||||
INTERRUPT_xMS_TIMER->EGR = 0;
|
||||
INTERRUPT_xMS_TIMER->CR1 = 5;
|
||||
INTERRUPT_xMS_TIMER->DIER |= 1;
|
||||
NVIC_EnableIRQ(INTERRUPT_xMS_IRQn);
|
||||
NVIC_SetPriority(INTERRUPT_xMS_IRQn, 7);
|
||||
}
|
||||
|
||||
// TODO use the same than board_sky9x.cpp
|
||||
void interrupt1ms()
|
||||
{
|
||||
static uint8_t pre_scale; // Used to get 10 Hz counter
|
||||
|
||||
++pre_scale;
|
||||
|
||||
#if defined(HAPTIC)
|
||||
if (pre_scale == 5 || pre_scale == 10) {
|
||||
DEBUG_TIMER_START(debugTimerHaptic);
|
||||
HAPTIC_HEARTBEAT();
|
||||
DEBUG_TIMER_STOP(debugTimerHaptic);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (pre_scale == 10) {
|
||||
pre_scale = 0;
|
||||
DEBUG_TIMER_START(debugTimerPer10ms);
|
||||
DEBUG_TIMER_SAMPLE(debugTimerPer10msPeriod);
|
||||
per10ms();
|
||||
DEBUG_TIMER_STOP(debugTimerPer10ms);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void INTERRUPT_xMS_IRQHandler()
|
||||
{
|
||||
INTERRUPT_xMS_TIMER->SR &= ~TIM_SR_UIF;
|
||||
interrupt1ms();
|
||||
DEBUG_INTERRUPT(INT_1MS);
|
||||
}
|
||||
|
||||
#if defined(SEMIHOSTING)
|
||||
extern "C" void initialise_monitor_handles();
|
||||
#endif
|
||||
@@ -150,7 +96,8 @@ void boardInit()
|
||||
SPORT_UPDATE_RCC_AHB1Periph,
|
||||
ENABLE);
|
||||
|
||||
RCC_APB1PeriphClockCmd(INTERRUPT_xMS_RCC_APB1Periph |
|
||||
RCC_APB1PeriphClockCmd(ROTARY_ENCODER_RCC_APB1Periph |
|
||||
INTERRUPT_xMS_RCC_APB1Periph |
|
||||
ADC_RCC_APB1Periph |
|
||||
TIMER_2MHz_RCC_APB1Periph |
|
||||
AUDIO_RCC_APB1Periph |
|
||||
@@ -208,7 +155,7 @@ void boardInit()
|
||||
backlightInit();
|
||||
|
||||
init2MhzTimer();
|
||||
init1msTimer();
|
||||
init5msTimer();
|
||||
usbInit();
|
||||
hapticInit();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user