12 volatile uint32_t head, tail;
33int log_q_put(uint8_t src, uint8_t type,
const void *p, uint8_t len)
37 const uint32_t h = r->
head;
40 const uint32_t
n = 2u + len;
42 const uint32_t m = r->
size - 1u;
44 r->
buf[(h + 1u) & m] = len;
45 const uint8_t *
b = (
const uint8_t *)p;
46 for (uint32_t k = 0; k < len; ++k) r->
buf[(h + 2u + k) & m] =
b[k];
52uint32_t
log_q_get(uint8_t src, uint8_t *type,
void *p, uint8_t
cap)
56 const uint32_t t = r->
tail;
57 const uint32_t h = r->
head;
60 const uint32_t m = r->
size - 1u;
61 *type = r->
buf[t & m];
62 const uint8_t len = r->
buf[(t + 1u) & m];
63 uint8_t *
b = (uint8_t *)p;
64 for (uint32_t k = 0; k < len; ++k) {
65 const uint8_t v = r->
buf[(t + 2u + k) & m];
66 if (k <
cap)
b[k] = v;
69 r->
tail = t + 2u + len;
70 return (uint32_t)(len >
cap ?
cap : len) + 1u;
77 const uint16_t d = r->
drops;
static volatile uint8_t s_active
int log_q_put(uint8_t src, uint8_t type, const void *p, uint8_t len)
0 = queued
static uint8_t s_b_batt[LOG_Q_BATT_SIZE]
static uint8_t s_b_imu[LOG_Q_IMU_SIZE]
static ring_t s_r[LOG_SRC_COUNT]
uint32_t log_q_get(uint8_t src, uint8_t *type, void *p, uint8_t cap)
next record of 'src': returns payload length + 1, 0 if empty
uint8_t log_q_active(void)
void log_q_set_active(uint8_t on)
uint16_t log_q_take_drops(uint8_t src)
Record queues from the producing tasks to the LogTask.
#define LOG_Q_IMU_SIZE
~1.2 s of ImuTask records: covers a sector erase
Lock-free single-producer single-consumer queue of fixed-size items.
uint8_t buf[TLM_BLE_RING_SIZE]