CANTram Framework 1.0.1
Dieses Framework ermöglicht die Nutzung der CANTram Hardware, einer Mikrocontroller basierten mdoularen Steuerung.
Loading...
Searching...
No Matches
UARTInterface.h
1#ifndef UART_INTERFACE_H
2#define UART_INTERFACE_H
3
4#include "Interface.h"
5#include "UARTCore.h"
6
7class UARTInterface : public Interface{
8public:
9 UARTInterface() = default;
10
11 Interface::Type getType() const override {
12 return Interface::BUS;
13 }
14
15 //Set communication parameters
16 void setBaudrate(uint32_t baudrate)
17 {if(uartCore) uartCore->setBaudrate(baudrate);}
18 void setDataBits(UARTCore::DataBits dataBits)
19 {if(uartCore) uartCore->setDataBits(dataBits);}
20 void setParity(UARTCore::Parity parity)
21 {if(uartCore) uartCore->setParity(parity);}
22 void setStopBits(UARTCore::StopBits stopBits)
23 {if(uartCore) uartCore->setStopBits(stopBits);}
24
25 bool send(char data[], size_t length){
26 // Implement sending data over UART
27 return uartCore->send(data,length);
28 }
29
30 size_t read(char* buffer){
31 // Implement receiving data over UART
32 return uartCore->read(buffer);
33 }
34
35 size_t available(){
36 // Implement checking available data over UART
37 return uartCore->available();
38 }
39
40 void setUartCore(UARTCore* core){uartCore = core;}
41 UARTCore* getUartCore(){return uartCore;}
42
43
44private:
45 std::function<void(uint32_t, uint8_t, bool, uint8_t)> onBeginCallback;
46 uint32_t _baudrate;
47 UARTCore::DataBits _dataBits;
48 UARTCore::Parity _parity;
49 UARTCore::StopBits _stopBits;
50
51 UARTCore* uartCore;
52
53 char** txBuffer;
54 char** rxBuffer;
55
56
57
58
59
60
61};
62
63#endif
Abstract base for UART hardware cores and provider interface.
Base class for platform-specific UART implementations.
Definition UARTCore.h:22
DataBits
Possible data bit widths for UART communication.
Definition UARTCore.h:28
Parity
Parity configuration options.
Definition UARTCore.h:38
StopBits
Stop bit configuration options.
Definition UARTCore.h:47