1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #ifndef __RINGFRAME_H
- #define __RINGFRAME_H
- typedef enum
- {
- ringframe_size_4 = 0x0004U,
- ringframe_size_8 = 0x0008U,
- ringframe_size_16 = 0x0010U,
- ringframe_size_32 = 0x0020U,
- ringframe_size_64 = 0x0040U,
- ringframe_size_128 = 0x0080U,
- ringframe_size_256 = 0x0100U,
- ringframe_size_512 = 0x0200U,
- ringframe_size_1024 = 0x0400U,
- ringframe_size_2048 = 0x0800U,
- ringframe_size_4096 = 0x1000U,
- ringframe_size_8192 = 0x2000U,
- ringframe_size_16384 = 0x4000U,
- ringframe_size_32768 = 0x8000U,
- }ringframe_size_t;
- typedef struct
- {
- volatile unsigned short front;
- volatile unsigned short back;
- void * p_buffer;
- ringframe_size_t size;
- unsigned short element_count;
- unsigned short freespace;
- } ringframe_t;
- #define RINGFRAME_DEF( _name, _size) \
- unsigned char _name##_ringframe_buffer[(_size)]; \
- ringframe_t _name= \
- { \
- .front = 0, \
- .back = 0, \
- .p_buffer = _name##_ringframe_buffer, \
- .size = (_size), \
- .element_count = 0, \
- .freespace = (_size)-1, \
- }
- unsigned short ringframe_in(ringframe_t * p_ringframe, void * p_data,unsigned char data_size);
- unsigned short ringframe_out(ringframe_t * p_ringframe, void * p_data,unsigned char * data_size);
-
- void ringframe_reset(ringframe_t * p_ringframe);
- unsigned short ringframe_peek(ringframe_t * p_ringframe, void * p_data,unsigned char * data_size);
- unsigned short ringframe_throw(ringframe_t * p_ringframe);
-
-
- #endif
|