Fixed race condition that casued concurrent SPI operation and hunged the RX module
This commit is contained in:
20
crossbow.ino
20
crossbow.ino
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#define FEATURE_TX_OLED
|
#define FEATURE_TX_OLED
|
||||||
|
|
||||||
#define DEBUG_SERIAL
|
// #define DEBUG_SERIAL
|
||||||
// #define DEBUG_PING_PONG
|
// #define DEBUG_PING_PONG
|
||||||
// #define DEBUG_LED
|
// #define DEBUG_LED
|
||||||
// #define WAIT_FOR_SERIAL
|
// #define WAIT_FOR_SERIAL
|
||||||
@@ -238,8 +238,6 @@ void updateRxDeviceState(RxDeviceState_t *rxDeviceState) {
|
|||||||
rxDeviceState->rxVoltage = map(analogRead(RX_ADC_PIN_1), 0, 1024, 0, 255);
|
rxDeviceState->rxVoltage = map(analogRead(RX_ADC_PIN_1), 0, 1024, 0, 255);
|
||||||
rxDeviceState->a1Voltage = map(analogRead(RX_ADC_PIN_2), 0, 1024, 0, 255);
|
rxDeviceState->a1Voltage = map(analogRead(RX_ADC_PIN_2), 0, 1024, 0, 255);
|
||||||
rxDeviceState->a2Voltage = map(analogRead(RX_ADC_PIN_3), 0, 1024, 0, 255);
|
rxDeviceState->a2Voltage = map(analogRead(RX_ADC_PIN_3), 0, 1024, 0, 255);
|
||||||
rxDeviceState->rssi = getRadioRssi();
|
|
||||||
rxDeviceState->snr = getRadioSnr();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t getFrameToTransmit(QspConfiguration_t *qsp) {
|
int8_t getFrameToTransmit(QspConfiguration_t *qsp) {
|
||||||
@@ -285,14 +283,6 @@ void loop(void)
|
|||||||
uint32_t currentMillis = millis();
|
uint32_t currentMillis = millis();
|
||||||
bool transmitPayload = false;
|
bool transmitPayload = false;
|
||||||
|
|
||||||
#ifdef DEBUG_SERIAL
|
|
||||||
static uint32_t r = 0;
|
|
||||||
if (currentMillis - r > 1000) {
|
|
||||||
Serial.println(currentMillis / 1000);
|
|
||||||
r = currentMillis;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Watchdog for frame decoding stuck somewhere in the middle of a process
|
* Watchdog for frame decoding stuck somewhere in the middle of a process
|
||||||
*/
|
*/
|
||||||
@@ -348,7 +338,6 @@ void loop(void)
|
|||||||
lastRxStateTaskTime = currentMillis;
|
lastRxStateTaskTime = currentMillis;
|
||||||
updateRxDeviceState(&rxDeviceState);
|
updateRxDeviceState(&rxDeviceState);
|
||||||
ppm[RSSI_CHANNEL - 1] = map(rxDeviceState.rssi, 0, 255, 1000, 2000);
|
ppm[RSSI_CHANNEL - 1] = map(rxDeviceState.rssi, 0, 255, 1000, 2000);
|
||||||
|
|
||||||
if (qsp.deviceState == DEVICE_STATE_FAILSAFE) {
|
if (qsp.deviceState == DEVICE_STATE_FAILSAFE) {
|
||||||
digitalWrite(LED_BUILTIN, HIGH);
|
digitalWrite(LED_BUILTIN, HIGH);
|
||||||
} else {
|
} else {
|
||||||
@@ -360,19 +349,15 @@ void loop(void)
|
|||||||
* Main routine to answer to TX module
|
* Main routine to answer to TX module
|
||||||
*/
|
*/
|
||||||
if (qsp.transmitWindowOpen && qsp.protocolState == QSP_STATE_IDLE) {
|
if (qsp.transmitWindowOpen && qsp.protocolState == QSP_STATE_IDLE) {
|
||||||
|
|
||||||
qsp.transmitWindowOpen = false;
|
qsp.transmitWindowOpen = false;
|
||||||
|
|
||||||
int8_t frameToSend = getFrameToTransmit(&qsp);
|
int8_t frameToSend = getFrameToTransmit(&qsp);
|
||||||
|
|
||||||
if (frameToSend > -1) {
|
if (frameToSend > -1) {
|
||||||
|
|
||||||
qsp.frameToSend = frameToSend;
|
qsp.frameToSend = frameToSend;
|
||||||
|
|
||||||
if (frameToSend != QSP_FRAME_PONG) {
|
if (frameToSend != QSP_FRAME_PONG) {
|
||||||
qspClearPayload(&qsp);
|
qspClearPayload(&qsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (qsp.frameToSend) {
|
switch (qsp.frameToSend) {
|
||||||
case QSP_FRAME_PONG:
|
case QSP_FRAME_PONG:
|
||||||
/*
|
/*
|
||||||
@@ -461,4 +446,7 @@ void onReceive(int packetSize)
|
|||||||
{
|
{
|
||||||
qspDecodeIncomingFrame(&qsp, LoRa.read(), ppm, &rxDeviceState);
|
qspDecodeIncomingFrame(&qsp, LoRa.read(), ppm, &rxDeviceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rxDeviceState.rssi = getRadioRssi();
|
||||||
|
rxDeviceState.snr = getRadioSnr();
|
||||||
}
|
}
|
||||||
31
track1.txt
Normal file
31
track1.txt
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
2
|
||||||
|
3
|
||||||
|
4
|
||||||
|
5
|
||||||
|
12
|
||||||
|
13
|
||||||
|
12
|
||||||
|
13
|
||||||
|
12
|
||||||
|
13
|
||||||
|
12
|
||||||
|
13
|
||||||
|
12
|
||||||
|
13
|
||||||
|
12
|
||||||
|
13
|
||||||
|
12
|
||||||
|
13
|
||||||
|
12
|
||||||
|
13
|
||||||
|
12
|
||||||
|
13
|
||||||
|
6
|
||||||
|
7
|
||||||
|
12
|
||||||
|
13
|
||||||
|
12
|
||||||
|
13
|
||||||
|
12
|
||||||
|
13
|
||||||
|
2
|
||||||
14
track2.txt
Normal file
14
track2.txt
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
13
|
||||||
|
12
|
||||||
|
13
|
||||||
|
6
|
||||||
|
7
|
||||||
|
12
|
||||||
|
13
|
||||||
|
12
|
||||||
|
13
|
||||||
|
12
|
||||||
|
13
|
||||||
|
12
|
||||||
|
13
|
||||||
|
2
|
||||||
10
track3.txt
Normal file
10
track3.txt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
12
|
||||||
|
13
|
||||||
|
12
|
||||||
|
13
|
||||||
|
2
|
||||||
|
21
|
||||||
|
22
|
||||||
|
23
|
||||||
|
24
|
||||||
|
25
|
||||||
Reference in New Issue
Block a user