mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
In the case of swapping in userspace due to the buffer being blocked during
ISR, make sure the latency is less than 50 us to avoid framesync errors. Still seeing a few nonsense packets on Overo side but fairly few. Probably need to add CRC to whole packet now and call it done.
This commit is contained in:
parent
1930d092eb
commit
c957172f8f
@ -48,6 +48,7 @@ static xQueueHandle queue;
|
||||
static UAVTalkConnection uavTalkCon;
|
||||
static xTaskHandle overoSyncTaskHandle;
|
||||
volatile bool buffer_swap_failed;
|
||||
volatile uint32_t buffer_swap_timeval;
|
||||
|
||||
// Private functions
|
||||
static void overoSyncTask(void *parameters);
|
||||
@ -281,6 +282,7 @@ static void transmitDataDone(bool crc_ok, uint8_t crc_val)
|
||||
* \return -1 on failure
|
||||
* \return number of bytes transmitted on success
|
||||
*/
|
||||
uint32_t too_long = 0;
|
||||
static int32_t packData(uint8_t * data, int32_t length)
|
||||
{
|
||||
uint8_t *tx_buffer;
|
||||
@ -312,9 +314,12 @@ static int32_t packData(uint8_t * data, int32_t length)
|
||||
// When the NSS line rises while we are packing data then a transaction doesn't start
|
||||
// because that means we will be here very shortly afterwards (priority of task making that
|
||||
// not always perfectly true) schedule the transaction here.
|
||||
if (buffer_swap_failed) {
|
||||
if (buffer_swap_failed && (PIOS_DELAY_DiffuS(buffer_swap_timeval) < 50)) {
|
||||
buffer_swap_failed = false;
|
||||
transmitData();
|
||||
} else if (buffer_swap_failed) {
|
||||
buffer_swap_failed = false;
|
||||
too_long++;
|
||||
}
|
||||
|
||||
return length;
|
||||
@ -335,6 +340,7 @@ static int32_t transmitData()
|
||||
xSemaphoreGiveFromISR(overosync->transaction_lock, &xHigherPriorityTaskWoken);
|
||||
portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
|
||||
buffer_swap_failed = true;
|
||||
buffer_swap_timeval = PIOS_DELAY_GetRaw();
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user