@@ -43,7 +43,7 @@ Uart::Uart(NRF_UARTE_Type *_nrfUart, IRQn_Type _IRQn, uint8_t _pinRX, uint8_t _p
43
43
uc_pinTX = g_ADigitalPinMap[_pinTX];
44
44
uc_hwFlow = 0 ;
45
45
46
- _mutex = NULL ;
46
+ _end_tx_sem = NULL ;
47
47
_begun = false ;
48
48
}
49
49
@@ -57,7 +57,7 @@ Uart::Uart(NRF_UARTE_Type *_nrfUart, IRQn_Type _IRQn, uint8_t _pinRX, uint8_t _p
57
57
uc_pinRTS = g_ADigitalPinMap[_pinRTS];
58
58
uc_hwFlow = 1 ;
59
59
60
- _mutex = NULL ;
60
+ _end_tx_sem = NULL ;
61
61
_begun = false ;
62
62
}
63
63
@@ -141,7 +141,8 @@ void Uart::begin(unsigned long baudrate, uint16_t config)
141
141
NVIC_SetPriority (IRQn, 3 );
142
142
NVIC_EnableIRQ (IRQn);
143
143
144
- _mutex = xSemaphoreCreateMutex ();
144
+ _end_tx_sem = xSemaphoreCreateBinary ();
145
+ xSemaphoreGive (_end_tx_sem);
145
146
_begun = true ;
146
147
}
147
148
@@ -164,16 +165,16 @@ void Uart::end()
164
165
165
166
rxBuffer.clear ();
166
167
167
- vSemaphoreDelete (_mutex );
168
- _mutex = NULL ;
168
+ vSemaphoreDelete (_end_tx_sem );
169
+ _end_tx_sem = NULL ;
169
170
_begun = false ;
170
171
}
171
172
172
173
void Uart::flush ()
173
174
{
174
175
if ( _begun ) {
175
- xSemaphoreTake (_mutex , portMAX_DELAY);
176
- xSemaphoreGive (_mutex );
176
+ xSemaphoreTake (_end_tx_sem , portMAX_DELAY);
177
+ xSemaphoreGive (_end_tx_sem );
177
178
}
178
179
}
179
180
@@ -192,7 +193,7 @@ void Uart::IrqHandler()
192
193
if (nrfUart->EVENTS_ENDTX )
193
194
{
194
195
nrfUart->EVENTS_ENDTX = 0x0UL ;
195
- xSemaphoreGiveFromISR (_mutex , NULL );
196
+ xSemaphoreGiveFromISR (_end_tx_sem , NULL );
196
197
}
197
198
}
198
199
@@ -227,7 +228,7 @@ size_t Uart::write(const uint8_t *buffer, size_t size)
227
228
size_t remaining = size - sent;
228
229
size_t txSize = min (remaining, (size_t )SERIAL_BUFFER_SIZE);
229
230
230
- xSemaphoreTake (_mutex , portMAX_DELAY);
231
+ xSemaphoreTake (_end_tx_sem , portMAX_DELAY);
231
232
232
233
memcpy (txBuffer, buffer + sent, txSize);
233
234
0 commit comments