Skip to content

Commit

Permalink
Update SBUS and CRSF to use microsISR() in the interrupt handler
Browse files Browse the repository at this point in the history
  • Loading branch information
etracer65 committed Nov 22, 2019
1 parent 0541829 commit cb80314
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/rx/crsf.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ STATIC_UNIT_TESTED void crsfDataReceive(uint16_t c, void *data)
UNUSED(data);

static uint8_t crsfFramePosition = 0;
const timeUs_t currentTimeUs = micros();
const timeUs_t currentTimeUs = microsISR();
static timeUs_t lastRcFrameCompleteTimeUs = 0;

#ifdef DEBUG_CRSF_PACKETS
Expand Down
2 changes: 1 addition & 1 deletion src/main/rx/sbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static void sbusDataReceive(uint16_t c, void *data)
static timeUs_t lastFrameCompleteTimeUs = 0;
sbusFrameData_t *sbusFrameData = data;

const timeUs_t nowUs = micros();
const timeUs_t nowUs = microsISR();

const timeDelta_t sbusFrameTime = cmpTimeUs(nowUs, sbusFrameData->startAtUs);

Expand Down
4 changes: 4 additions & 0 deletions src/test/unit/link_quality_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,10 @@ extern "C" {
return simulationTime;
}

uint32_t microsISR() {
return micros();
}

uint32_t millis() {
return micros() / 1000;
}
Expand Down
1 change: 1 addition & 0 deletions src/test/unit/rx_crsf_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ extern "C" {

int16_t debug[DEBUG16_VALUE_COUNT];
uint32_t micros(void) {return dummyTimeUs;}
uint32_t microsISR(void) {return micros();}
serialPort_t *openSerialPort(serialPortIdentifier_e, serialPortFunction_e, serialReceiveCallbackPtr, void *, uint32_t, portMode_e, portOptions_e) {return NULL;}
serialPortConfig_t *findSerialPortConfig(serialPortFunction_e ) {return NULL;}
bool telemetryCheckRxPortShared(const serialPortConfig_t *) {return false;}
Expand Down
1 change: 1 addition & 0 deletions src/test/unit/telemetry_crsf_msp_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ extern "C" {
attitudeEulerAngles_t attitude = { { 0, 0, 0 } };

uint32_t micros(void) {return dummyTimeUs;}
uint32_t microsISR(void) {return micros();}
serialPort_t *openSerialPort(serialPortIdentifier_e, serialPortFunction_e, serialReceiveCallbackPtr, void *, uint32_t, portMode_e, portOptions_e) {return NULL;}
serialPortConfig_t *findSerialPortConfig(serialPortFunction_e ) {return NULL;}
bool isBatteryVoltageConfigured(void) { return true; }
Expand Down
1 change: 1 addition & 0 deletions src/test/unit/telemetry_crsf_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ gpsSolutionData_t gpsSol;
void beeperConfirmationBeeps(uint8_t beepCount) {UNUSED(beepCount);}

uint32_t micros(void) {return 0;}
uint32_t microsISR(void) {return micros();}

bool featureIsEnabled(uint32_t) {return true;}

Expand Down

0 comments on commit cb80314

Please sign in to comment.