URL
https://opencores.org/ocsvn/igor/igor/trunk
[/] [igor/] [trunk/] [avr/] [src/] [buf.h] - Blame information for rev 4
Details |
Compare with Previous |
View Log
Line No. |
Rev |
Author |
Line |
1 |
4 |
atypic |
#ifndef _BUF_H_
|
2 |
|
|
#define _BUF_H_
|
3 |
|
|
#include <stdint.h>
|
4 |
|
|
|
5 |
|
|
/* Maximum length of buffer. */
|
6 |
|
|
#define MAXBUFLEN 200
|
7 |
|
|
|
8 |
|
|
/* Per device data buffer. */
|
9 |
|
|
struct buf {
|
10 |
|
|
uint8_t data[MAXBUFLEN]; /* The data buffer to be used. */
|
11 |
|
|
uint16_t off_read; /* The current read pointer in the buffer. */
|
12 |
|
|
uint16_t off_write; /* The current write pointer in the buffer. */
|
13 |
|
|
/* These shall be able to store numbers > MAXBUFLEN. */
|
14 |
|
|
uint16_t wcount;
|
15 |
|
|
uint16_t rcount;
|
16 |
|
|
#define BUF_STATUS_FULL 0x1
|
17 |
|
|
#define BUF_STATUS_EMPTY 0x2
|
18 |
|
|
/*
|
19 |
|
|
* For users of buf, note that the status flags will be set when the condition
|
20 |
|
|
* is discovered, which means it will signal an empty buffer after the last call
|
21 |
|
|
* filling it up.
|
22 |
|
|
*/
|
23 |
|
|
int8_t status; /* The status of the buffer. */
|
24 |
|
|
};
|
25 |
|
|
|
26 |
|
|
#define BUF_FULL(b) ((b)->status & BUF_STATUS_FULL)
|
27 |
|
|
#define BUF_EMPTY(b) ((b)->status & BUF_STATUS_EMPTY)
|
28 |
|
|
|
29 |
|
|
void buf_init(struct buf *);
|
30 |
|
|
uint16_t buf_readsleft(struct buf *);
|
31 |
|
|
uint16_t buf_writesleft(struct buf *);
|
32 |
|
|
int8_t buf_write(struct buf *, uint8_t *, uint8_t);
|
33 |
|
|
int8_t buf_read(struct buf *, uint8_t *, uint8_t);
|
34 |
|
|
|
35 |
|
|
#endif /* !_BUF_H_ */
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.