10 #define MAX_KNX_TELEGRAM_SIZE 263
12 #ifndef MAX_RX_QUEUE_BYTES
13 #define MAX_RX_QUEUE_BYTES MAX_KNX_TELEGRAM_SIZE + 50
17 #define MAX_TX_QUEUE 50
21 #ifndef ARDUINO_ARCH_RP2040
22 #define __time_critical_func(X) X
50 void stop(
bool state);
62 #ifdef USE_TP_RX_QUEUE
79 struct knx_tx_queue_entry_t
82 knx_tx_queue_entry_t* next =
nullptr;
84 knx_tx_queue_entry_t(
TpFrame* tpFrame)
93 knx_tx_queue_entry_t* front =
nullptr;
94 knx_tx_queue_entry_t* back =
nullptr;
100 volatile bool _stopped =
false;
101 volatile bool _connected =
false;
102 volatile bool _monitoring =
false;
103 volatile bool _busy =
false;
104 volatile bool _initialized =
false;
106 volatile uint8_t _rxState = 0;
107 volatile uint8_t _txState = 0;
108 volatile uint32_t _rxProcessdFrameCounter = 0;
109 volatile uint32_t _rxInvalidFrameCounter = 0;
110 volatile uint32_t _rxIgnoredFrameCounter = 0;
111 volatile uint32_t _rxUnkownControlCounter = 0;
112 volatile uint32_t _txFrameCounter = 0;
113 volatile uint32_t _txProcessdFrameCounter = 0;
114 volatile bool _rxMarker =
false;
115 volatile bool _rxOverflow =
false;
116 volatile uint8_t _tpState = 0x0;
117 volatile uint32_t _txLastTime = 0;
118 volatile uint32_t _rxLastTime = 0;
119 volatile bool _forceAck =
false;
120 uint8_t _txQueueCount = 0;
122 inline bool markerMode();
130 volatile uint8_t _repetitions = 0b00110011;
133 volatile bool _rxProcessing =
false;
135 volatile uint32_t _lastStateRequest = 0;
138 inline bool processTxFrameBytes();
140 void rxFrameReceived(
TpFrame* frame);
141 void dataConBytesReceived(uint8_t* buffer, uint16_t length,
bool success);
143 void processRx(
bool isr =
false);
144 void checkConnected();
145 void processRxByte();
146 void processTxQueue();
147 void clearTxFrameQueue();
148 void processRxFrameComplete();
149 inline void processRxFrame(
TpFrame* tpFrame);
150 void pushTxFrameQueue(
TpFrame* tpFrame);
151 void requestState(
bool force =
false);
152 void requestConfig();
153 inline void processRxFrameByte(uint8_t
byte);
155 #ifdef USE_TP_RX_QUEUE
157 volatile uint8_t _rxBuffer[MAX_RX_QUEUE_BYTES] = {};
158 volatile uint16_t _rxBufferFront = 0;
159 volatile uint16_t _rxBufferRear = 0;
160 volatile uint8_t _rxBufferCount = 0;
162 void pushByteToRxQueue(uint8_t
byte);
163 uint8_t pullByteFromRxQueue();
164 uint16_t availableInRxQueue();
165 void pushRxFrameQueue();
166 void processRxQueue();
169 inline bool isrLock(
bool blocking =
false);
170 inline void isrUnlock();
171 inline void clearUartBuffer();
172 inline void connected(
bool state =
true);
174 void clearOutdatedTxFrame();
175 void processTxFrameComplete(
bool success);
DeviceObject & _deviceObject
virtual ~ITpUartCallBacks()=default
virtual TPAckType isAckRequired(uint16_t address, bool isGrpAddr)=0
void setRepetitions(uint8_t nack, uint8_t busy)
uint32_t getRxInvalidFrameCounter()
uint32_t getRxProcessdFrameCounter()
uint32_t getRxIgnoredFrameCounter()
DptMedium mediumType() const override
void powerControl(bool state)
uint32_t getTxProcessedFrameCounter()
void forceAck(bool state)
uint32_t getRxUnknownControlCounter()
uint32_t getTxFrameCounter()
void requestBusy(bool state)
void setFrameRepetition(uint8_t nack, uint8_t busy)
TpUartDataLinkLayer(DeviceObject &devObj, NetworkLayerEntity &netLayerEntity, Platform &platform, ITpUartCallBacks &cb, DataLinkLayerCallbacks *dllcb=nullptr)
void printFrame(TpFrame *tpframe)