forked from lucysrausch/hoverboard-firmware-hack
ADD: buzzer, undervoltage lockout, safe poweroff, foo
This commit is contained in:
@@ -7,16 +7,13 @@
|
||||
TIM_HandleTypeDef TimHandle;
|
||||
uint16_t ppm_captured_value[PPM_NUM_CHANNELS+1] = {0};
|
||||
uint8_t ppm_count = 0;
|
||||
uint32_t timeout = 0;
|
||||
uint32_t timeout = 100;
|
||||
|
||||
void PPM_ISR_Callback() {
|
||||
// Dummy loop with 16 bit count wrap around
|
||||
uint16_t rc_delay = TIM2->CNT;
|
||||
TIM2->CNT = 0;
|
||||
|
||||
HAL_TIM_Base_Stop(&TimHandle);
|
||||
__HAL_RCC_TIM2_CLK_DISABLE();
|
||||
|
||||
if (rc_delay > 3000) {
|
||||
ppm_count = 0;
|
||||
}
|
||||
@@ -25,8 +22,7 @@ void PPM_ISR_Callback() {
|
||||
ppm_captured_value[ppm_count] = CLAMP(rc_delay, 1000, 2000) - 1000;
|
||||
ppm_count++;
|
||||
}
|
||||
__HAL_RCC_TIM2_CLK_ENABLE();
|
||||
HAL_TIM_Base_Start(&TimHandle);
|
||||
|
||||
}
|
||||
|
||||
void PPM_Init() {
|
||||
@@ -49,4 +45,5 @@ void PPM_Init() {
|
||||
/* EXTI interrupt init*/
|
||||
HAL_NVIC_SetPriority(EXTI3_IRQn, 0, 0);
|
||||
HAL_NVIC_EnableIRQ(EXTI3_IRQn);
|
||||
HAL_TIM_Base_Start(&TimHandle);
|
||||
}
|
||||
|
Reference in New Issue
Block a user