feat: better microsecond timer (#4112)
This commit is contained in:
+4
-4
@@ -23,7 +23,7 @@
|
||||
#include "sbus.h"
|
||||
#include "timers_driver.h"
|
||||
|
||||
#define SBUS_FRAME_GAP_DELAY 1000 // 500uS
|
||||
#define SBUS_FRAME_GAP_DELAY_US 500
|
||||
|
||||
#define SBUS_START_BYTE 0x0F
|
||||
#define SBUS_END_BYTE 0x00
|
||||
@@ -99,7 +99,7 @@ void processSbusInput()
|
||||
|
||||
// TODO: place this outside of the function
|
||||
static uint8_t SbusIndex = 0;
|
||||
static uint16_t SbusTimer;
|
||||
static uint32_t SbusTimer;
|
||||
static uint8_t SbusFrame[SBUS_FRAME_SIZE];
|
||||
|
||||
uint32_t active = 0;
|
||||
@@ -117,13 +117,13 @@ void processSbusInput()
|
||||
|
||||
// Data has been received
|
||||
if (active) {
|
||||
SbusTimer = getTmr2MHz();
|
||||
SbusTimer = timersGetUsTick();
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if end-of-frame is detected
|
||||
if (SbusIndex) {
|
||||
if ((uint16_t)(getTmr2MHz() - SbusTimer) > SBUS_FRAME_GAP_DELAY) {
|
||||
if ((uint32_t)(timersGetUsTick() - SbusTimer) > SBUS_FRAME_GAP_DELAY_US) {
|
||||
processSbusFrame(SbusFrame, trainerInput, SbusIndex);
|
||||
SbusIndex = 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user