Skip to content

Commit 6d97d57

Browse files
committed
Do flow control update when clearing the ring buffer as well
1 parent 946ff27 commit 6d97d57

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/sequans_controller.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,10 @@ void SequansControllerClass::setRetryConfiguration(const uint8_t num_retries,
370370
}
371371

372372
bool SequansControllerClass::isTxReady(void) {
373-
return (tx_num_elements != TX_BUFFER_SIZE);
373+
return tx_num_elements != TX_BUFFER_SIZE;
374374
}
375375

376-
bool SequansControllerClass::isRxReady(void) { return (rx_num_elements != 0); }
376+
bool SequansControllerClass::isRxReady(void) { return rx_num_elements > 0; }
377377

378378
bool SequansControllerClass::writeByte(const uint8_t data) {
379379

@@ -388,10 +388,9 @@ bool SequansControllerClass::writeByte(const uint8_t data) {
388388
_delay_ms(sleep_between_retries_ms);
389389
}
390390

391+
cli();
391392
tx_head_index = (tx_head_index + 1) & TX_BUFFER_MASK;
392393
tx_buffer[tx_head_index] = data;
393-
394-
cli();
395394
tx_num_elements++;
396395
sei();
397396

@@ -441,7 +440,7 @@ bool SequansControllerClass::writeBytes(const uint8_t *data,
441440
return writeByte('\r');
442441
}
443442

444-
int16_t SequansControllerClass::readByte() {
443+
int16_t SequansControllerClass::readByte(void) {
445444
if (!isRxReady()) {
446445
return -1;
447446
}
@@ -541,6 +540,8 @@ void SequansControllerClass::clearReceiveBuffer(void) {
541540
rx_num_elements = 0;
542541
rx_tail_index = rx_head_index;
543542
sei();
543+
544+
flowControlUpdate();
544545
}
545546

546547
bool SequansControllerClass::extractValueFromCommandResponse(
@@ -752,12 +753,12 @@ uint8_t SequansControllerClass::waitForByte(uint8_t byte, uint32_t timeout) {
752753
return SEQUANS_CONTROLLER_READ_BYTE_OK;
753754
}
754755

755-
void SequansControllerClass::startCriticalSection() {
756+
void SequansControllerClass::startCriticalSection(void) {
756757
critical_section_enabled = true;
757758
RTS_PORT.OUTSET = RTS_PIN_bm;
758759
}
759760

760-
void SequansControllerClass::stopCriticalSection() {
761+
void SequansControllerClass::stopCriticalSection(void) {
761762
critical_section_enabled = false;
762763
RTS_PORT.OUTCLR = RTS_PIN_bm;
763764
}

src/sequans_controller.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ class SequansControllerClass {
209209
*/
210210
uint8_t waitForByte(uint8_t byte, uint32_t timeout_ms);
211211

212-
void startCriticalSection();
212+
void startCriticalSection(void);
213213

214-
void stopCriticalSection();
214+
void stopCriticalSection(void);
215215
};
216216

217217
extern SequansControllerClass SequansController;

0 commit comments

Comments
 (0)