RISC-V/V203/usb/usart/test/usart.h
2024-10-15 19:26:19 +02:00

32 lines
850 B
C++

#ifndef USARTCLASS_H
#define USARTCLASS_H
#include <pthread.h>
#include "../common/baselayer.h"
static constexpr unsigned BUFLEN = 1024u;
// Bottom
class UsartClass : public BaseLayer {
public:
UsartClass (const char* name, const int baudrate);
uint32_t Up (const char* data, uint32_t len);
uint32_t Down(const char* data, uint32_t len);
virtual ~UsartClass ();
protected:
void ReadLoop (void);
static void* UsartHandler (void* p) {
UsartClass* inst = (UsartClass*) p;
inst->ReadLoop();
return nullptr;
};
void setBaud (int baud);
public:
bool running;
private:
const char * id; //!< Identifikátor třídy pro ladění
char rxbuf[BUFLEN];
int fd;
int timeout;
pthread_t rc;
};
#endif // USARTCLASS_H