ringbuffer and tests
This commit is contained in:
6
cube/User/Inc/logger.h
Normal file
6
cube/User/Inc/logger.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef _LOGGER_H_
|
||||
#define _LOGGER_H_
|
||||
|
||||
void log(char *msg);
|
||||
|
||||
#endif // _LOGGER_H_
|
8
cube/User/Inc/mbusComm.h
Normal file
8
cube/User/Inc/mbusComm.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef _MBUSCOMM_H_
|
||||
#define _MBUSCOMM_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void mbusCommRequest(uint8_t cmd, uint8_t addr);
|
||||
|
||||
#endif // _MBUSCOMM_H_
|
23
cube/User/Inc/ringbuffer.h
Normal file
23
cube/User/Inc/ringbuffer.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef _RINGBUFFER_H_
|
||||
#define _RINGBUFFER_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint32_t bufferReadIdx;
|
||||
uint32_t bufferWriteIdx;
|
||||
uint32_t bufferSize;
|
||||
uint8_t* buffer;
|
||||
} ringbuffer_t;
|
||||
|
||||
void ringbufferInit(ringbuffer_t *handle, uint32_t bufferSize);
|
||||
void ringbufferFree(ringbuffer_t *handle);
|
||||
int ringbufferPut(ringbuffer_t *handle, uint8_t *data, uint32_t dataLen);
|
||||
uint8_t *ringbufferGet(ringbuffer_t *handle, uint32_t dataLen);
|
||||
bool ringbufferEmpty(ringbuffer_t *handle);
|
||||
int ringbufferGetOne(ringbuffer_t *handle); // if positive, cast to uint8_t and be happy, if negative error
|
||||
|
||||
|
||||
#endif // _RINGBUFFER_H_
|
Reference in New Issue
Block a user