Skip to content

Commit 7d5cb82

Browse files
committed
zephyr: Remove irq locking since ringbuf is inherently thread safe.
Signed-off-by: Daniel Campora <[email protected]>
1 parent ab1f622 commit 7d5cb82

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

ports/zephyr/machine_uart.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
#include <zephyr/kernel.h>
3333
#include <zephyr/drivers/uart.h>
34-
#include <zephyr/irq.h>
3534

3635
#include "py/mperrno.h"
3736
#include "py/obj.h"
@@ -189,7 +188,7 @@ static mp_int_t mp_machine_uart_any(machine_uart_obj_t *self) {
189188
}
190189

191190
static bool mp_machine_uart_txdone(machine_uart_obj_t *self) {
192-
return (ringbuf_avail(&self->tx_ringbuffer) || (self->tx_complete == false)) ? false : true;
191+
return self->tx_complete && !ringbuf_avail(&self->tx_ringbuffer) ? true : false;
193192
}
194193

195194
static mp_uint_t mp_machine_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, int *errcode) {
@@ -202,9 +201,7 @@ static mp_uint_t mp_machine_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t
202201
do {
203202
int _rx_len = MIN(ringbuf_avail(&self->rx_ringbuffer), size - bytes_read);
204203
if (_rx_len > 0) {
205-
uint32_t key = irq_lock();
206204
ringbuf_get_bytes(&self->rx_ringbuffer, &buffer[bytes_read], _rx_len);
207-
irq_unlock(key);
208205
bytes_read += _rx_len;
209206
elapsed_ms = 0;
210207
time_to_wait = self->timeout_char;

0 commit comments

Comments
 (0)