Improve PPM
This commit is contained in:
parent
ec64b8b005
commit
962f57a85f
|
@ -338,7 +338,7 @@
|
||||||
* https://gist.github.com/peterpoetzi/1b63a4a844162196613871767189bd05
|
* https://gist.github.com/peterpoetzi/1b63a4a844162196613871767189bd05
|
||||||
*/
|
*/
|
||||||
#define CONTROL_PPM_LEFT // use PPM-Sum as input on the LEFT cable . disable CONTROL_SERIAL_USART2!
|
#define CONTROL_PPM_LEFT // use PPM-Sum as input on the LEFT cable . disable CONTROL_SERIAL_USART2!
|
||||||
// #define CONTROL_PPM_RIGHT // use PPM-Sum as input on the RIGHT cable. disable CONTROL_SERIAL_USART3!
|
//#define CONTROL_PPM_RIGHT // use PPM-Sum as input on the RIGHT cable. disable CONTROL_SERIAL_USART3!
|
||||||
#ifdef CONTROL_PPM_RIGHT
|
#ifdef CONTROL_PPM_RIGHT
|
||||||
#define DEBUG_SERIAL_USART2 // left sensor cable debug
|
#define DEBUG_SERIAL_USART2 // left sensor cable debug
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -34,13 +34,14 @@ void PPM_ISR_Callback(void) {
|
||||||
if (rc_delay > 3000) {
|
if (rc_delay > 3000) {
|
||||||
if (ppm_valid && ppm_count == PPM_NUM_CHANNELS) {
|
if (ppm_valid && ppm_count == PPM_NUM_CHANNELS) {
|
||||||
ppm_timeout = 0;
|
ppm_timeout = 0;
|
||||||
|
timeoutCnt = 0; // added this
|
||||||
memcpy(ppm_captured_value, ppm_captured_value_buffer, sizeof(ppm_captured_value));
|
memcpy(ppm_captured_value, ppm_captured_value_buffer, sizeof(ppm_captured_value));
|
||||||
}
|
}
|
||||||
ppm_valid = true;
|
ppm_valid = true;
|
||||||
ppm_count = 0;
|
ppm_count = 0;
|
||||||
}
|
}
|
||||||
else if (ppm_count < PPM_NUM_CHANNELS && IN_RANGE(rc_delay, 900, 2100)){
|
else if (ppm_count < PPM_NUM_CHANNELS && IN_RANGE(rc_delay, 900, 2100)){
|
||||||
timeoutCnt = 0;
|
//timeoutCnt = 0;
|
||||||
ppm_captured_value_buffer[ppm_count++] = CLAMP(rc_delay, 1000, 2000) - 1000;
|
ppm_captured_value_buffer[ppm_count++] = CLAMP(rc_delay, 1000, 2000) - 1000;
|
||||||
} else {
|
} else {
|
||||||
ppm_valid = false;
|
ppm_valid = false;
|
||||||
|
@ -77,9 +78,18 @@ void PPM_Init(void) {
|
||||||
TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
HAL_TIM_Base_Init(&TimHandle);
|
HAL_TIM_Base_Init(&TimHandle);
|
||||||
|
|
||||||
|
#if defined(CONTROL_PPM_LEFT)
|
||||||
/* EXTI interrupt init*/
|
/* EXTI interrupt init*/
|
||||||
HAL_NVIC_SetPriority(EXTI3_IRQn, 0, 0);
|
HAL_NVIC_SetPriority(EXTI3_IRQn, 0, 0);
|
||||||
HAL_NVIC_EnableIRQ(EXTI3_IRQn);
|
HAL_NVIC_EnableIRQ(EXTI3_IRQn);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONTROL_PPM_RIGHT)
|
||||||
|
/* EXTI interrupt init*/
|
||||||
|
HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
|
||||||
|
#endif
|
||||||
|
|
||||||
HAL_TIM_Base_Start(&TimHandle);
|
HAL_TIM_Base_Start(&TimHandle);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue