-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6685 from kernel-machine/flip-over-after-crash
Flip over after crash aka TURTLE MODE
- Loading branch information
Showing
19 changed files
with
514 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* This file is part of INAV Project. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
* Alternatively, the contents of this file may be used under the terms | ||
* of the GNU General Public License Version 3, as described below: | ||
* | ||
* This file is free software: you may copy, redistribute and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or (at your | ||
* option) any later version. | ||
* | ||
* This file is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
|
||
#include "circular_queue.h" | ||
|
||
void circularBufferInit(circularBuffer_t *circular_buffer, uint8_t *buffer, size_t buffer_size, | ||
size_t buffer_element_size) { | ||
circular_buffer->buffer = buffer; | ||
circular_buffer->bufferSize = buffer_size; | ||
circular_buffer->elementSize = buffer_element_size; | ||
circular_buffer->head = 0; | ||
circular_buffer->tail = 0; | ||
circular_buffer->size = 0; | ||
} | ||
|
||
void circularBufferPushElement(circularBuffer_t *circularBuffer, uint8_t *element) { | ||
if (circularBufferIsFull(circularBuffer)) | ||
return; | ||
|
||
memcpy(circularBuffer->buffer + circularBuffer->tail, element, circularBuffer->elementSize); | ||
|
||
circularBuffer->tail += circularBuffer->elementSize; | ||
circularBuffer->tail %= circularBuffer->bufferSize; | ||
circularBuffer->size += 1; | ||
} | ||
|
||
void circularBufferPopHead(circularBuffer_t *circularBuffer, uint8_t *element) { | ||
memcpy(element, circularBuffer->buffer + circularBuffer->head, circularBuffer->elementSize); | ||
|
||
circularBuffer->head += circularBuffer->elementSize; | ||
circularBuffer->head %= circularBuffer->bufferSize; | ||
circularBuffer->size -= 1; | ||
} | ||
|
||
int circularBufferIsFull(circularBuffer_t *circularBuffer) { | ||
return circularBufferCountElements(circularBuffer) * circularBuffer->elementSize == circularBuffer->bufferSize; | ||
} | ||
|
||
int circularBufferIsEmpty(circularBuffer_t *circularBuffer) { | ||
return circularBuffer==NULL || circularBufferCountElements(circularBuffer) == 0; | ||
} | ||
|
||
size_t circularBufferCountElements(circularBuffer_t *circularBuffer) { | ||
return circularBuffer->size; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* This file is part of INAV Project. | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* | ||
* Alternatively, the contents of this file may be used under the terms | ||
* of the GNU General Public License Version 3, as described below: | ||
* | ||
* This file is free software: you may copy, redistribute and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or (at your | ||
* option) any later version. | ||
* | ||
* This file is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see http://www.gnu.org/licenses/. | ||
*/ | ||
|
||
#ifndef INAV_CIRCULAR_QUEUE_H | ||
#define INAV_CIRCULAR_QUEUE_H | ||
|
||
#include "stdint.h" | ||
#include "string.h" | ||
|
||
typedef struct circularBuffer_s{ | ||
size_t head; | ||
size_t tail; | ||
size_t bufferSize; | ||
uint8_t * buffer; | ||
size_t elementSize; | ||
size_t size; | ||
}circularBuffer_t; | ||
|
||
void circularBufferInit(circularBuffer_t * circularBuffer, uint8_t * buffer, size_t bufferSize, size_t bufferElementSize); | ||
void circularBufferPushElement(circularBuffer_t * circularBuffer, uint8_t * element); | ||
void circularBufferPopHead(circularBuffer_t * circularBuffer, uint8_t * element); | ||
int circularBufferIsFull(circularBuffer_t * circularBuffer); | ||
int circularBufferIsEmpty(circularBuffer_t *circularBuffer); | ||
size_t circularBufferCountElements(circularBuffer_t * circularBuffer); | ||
|
||
#endif //INAV_CIRCULAR_QUEUE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.