mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-21 23:35:34 +03:00
Merge pull request #2015 from mikeller/make_isr_variables_volatile
Made variables used in ESC feedback ISR volatile.
This commit is contained in:
commit
e228a91ef8
1 changed files with 6 additions and 6 deletions
|
@ -94,7 +94,7 @@ typedef enum {
|
||||||
#define ESC_BOOTTIME 5000 // 5 seconds
|
#define ESC_BOOTTIME 5000 // 5 seconds
|
||||||
#define ESC_REQUEST_TIMEOUT 100 // 100 ms (data transfer takes only 900us)
|
#define ESC_REQUEST_TIMEOUT 100 // 100 ms (data transfer takes only 900us)
|
||||||
|
|
||||||
static bool tlmFrameDone = false;
|
static volatile bool tlmFramePending = false;
|
||||||
static uint8_t tlm[ESC_SENSOR_BUFFSIZE] = { 0, };
|
static uint8_t tlm[ESC_SENSOR_BUFFSIZE] = { 0, };
|
||||||
static uint8_t tlmFramePosition = 0;
|
static uint8_t tlmFramePosition = 0;
|
||||||
|
|
||||||
|
@ -159,15 +159,16 @@ static void escSensorDataReceive(uint16_t c)
|
||||||
// KISS ESC sends some data during startup, ignore this for now (maybe future use)
|
// KISS ESC sends some data during startup, ignore this for now (maybe future use)
|
||||||
// startup data could be firmware version and serialnumber
|
// startup data could be firmware version and serialnumber
|
||||||
|
|
||||||
if (escSensorTriggerState == ESC_SENSOR_TRIGGER_STARTUP || tlmFrameDone) {
|
if (!tlmFramePending) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tlm[tlmFramePosition] = (uint8_t)c;
|
tlm[tlmFramePosition] = (uint8_t)c;
|
||||||
|
|
||||||
if (tlmFramePosition == ESC_SENSOR_BUFFSIZE - 1) {
|
if (tlmFramePosition == ESC_SENSOR_BUFFSIZE - 1) {
|
||||||
tlmFrameDone = true;
|
|
||||||
tlmFramePosition = 0;
|
tlmFramePosition = 0;
|
||||||
|
|
||||||
|
tlmFramePending = false;
|
||||||
} else {
|
} else {
|
||||||
tlmFramePosition++;
|
tlmFramePosition++;
|
||||||
}
|
}
|
||||||
|
@ -213,7 +214,7 @@ static uint8_t get_crc8(uint8_t *Buf, uint8_t BufLen)
|
||||||
|
|
||||||
static uint8_t decodeEscFrame(void)
|
static uint8_t decodeEscFrame(void)
|
||||||
{
|
{
|
||||||
if (!tlmFrameDone) {
|
if (tlmFramePending) {
|
||||||
return ESC_SENSOR_FRAME_PENDING;
|
return ESC_SENSOR_FRAME_PENDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,8 +237,6 @@ static uint8_t decodeEscFrame(void)
|
||||||
frameStatus = ESC_SENSOR_FRAME_FAILED;
|
frameStatus = ESC_SENSOR_FRAME_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
tlmFrameDone = false;
|
|
||||||
|
|
||||||
return frameStatus;
|
return frameStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,6 +276,7 @@ void escSensorProcess(timeUs_t currentTimeUs)
|
||||||
case ESC_SENSOR_TRIGGER_READY:
|
case ESC_SENSOR_TRIGGER_READY:
|
||||||
escTriggerTimestamp = currentTimeMs;
|
escTriggerTimestamp = currentTimeMs;
|
||||||
|
|
||||||
|
tlmFramePending = true;
|
||||||
motorDmaOutput_t * const motor = getMotorDmaOutput(escSensorMotor);
|
motorDmaOutput_t * const motor = getMotorDmaOutput(escSensorMotor);
|
||||||
motor->requestTelemetry = true;
|
motor->requestTelemetry = true;
|
||||||
escSensorTriggerState = ESC_SENSOR_TRIGGER_PENDING;
|
escSensorTriggerState = ESC_SENSOR_TRIGGER_PENDING;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue