Fixed critical ring buffer underflow bug
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define MAX_CAM_MISS 2
|
#define MAX_CAM_MISS 2
|
||||||
#define SPARK_ADVANCE 20
|
#define SPARK_ADVANCE 40
|
||||||
#define INJECTION_PHASE 0
|
#define INJECTION_PHASE 0
|
||||||
|
|
||||||
typedef enum { SYNC_OK = 0, SYNC_PENDING = 1, SYNC_NOT_OK = 2 } sync_state_t;
|
typedef enum { SYNC_OK = 0, SYNC_PENDING = 1, SYNC_NOT_OK = 2 } sync_state_t;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ring_buffer.h>
|
#include <ring_buffer.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
void ringBufferPush(volatile ring_buffer_t *rb, uint32_t value) {
|
void ringBufferPush(volatile ring_buffer_t *rb, uint32_t value) {
|
||||||
rb->buffer[rb->w_head] = value;
|
rb->buffer[rb->w_head] = value;
|
||||||
@@ -13,7 +14,8 @@ void ringBufferPush(volatile ring_buffer_t *rb, uint32_t value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t ringBufferRead(volatile ring_buffer_t *rb, uint8_t neg_idx) {
|
uint32_t ringBufferRead(volatile ring_buffer_t *rb, uint8_t neg_idx) {
|
||||||
return rb->buffer[rb->w_head - 1 - neg_idx];
|
uint8_t idx = (uint8_t)(rb->w_head - 1u - neg_idx);
|
||||||
|
return rb->buffer[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
void ringBufferRevert(volatile ring_buffer_t *rb, uint8_t val) {
|
void ringBufferRevert(volatile ring_buffer_t *rb, uint8_t val) {
|
||||||
|
|||||||
Reference in New Issue
Block a user