source: trunk/fw_g473rct/SES/inc/ring.h@ 69

Last change on this file since 69 was 69, checked in by f.jahn, 4 weeks ago

Started implementing Modbus on USB CDC channel.

File size: 623 bytes
RevLine 
[69]1#ifndef RING_BUFFER_H
2#define RING_BUFFER_H
3
4#include <stdint.h>
5#include <stdbool.h>
6
7#define RB_SIZE (1U << 13U) // must be power of 2 for efficiency
8
9typedef struct
10{
11 uint8_t buffer[RB_SIZE];
12 volatile uint16_t head;
13 volatile uint16_t tail;
14} ring_buffer_t;
15
16void rb_init(ring_buffer_t* rb);
17bool rb_push(ring_buffer_t* rb, uint8_t data);
18bool rb_pop(ring_buffer_t* rb, uint8_t* data);
19uint16_t rb_available(const ring_buffer_t* rb);
20bool rb_peek(const ring_buffer_t* const rb, uint8_t* const data);
21bool rb_peek_at(const ring_buffer_t* const rb, uint16_t index, uint8_t* data);
22
23#endif
Note: See TracBrowser for help on using the repository browser.