Skip to content

Commit 5c00757

Browse files
committed
stmhal: uart ioctl uses EINVAL, and checks TXE bit for write-ability.
1 parent 013d53c commit 5c00757

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

stmhal/uart.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <stdio.h>
2828
#include <string.h>
2929
#include <stdarg.h>
30+
#include <errno.h>
3031

3132
#include "stm32f4xx_hal.h"
3233

@@ -488,12 +489,11 @@ mp_uint_t uart_ioctl(mp_obj_t self_in, mp_uint_t request, int *errcode, ...) {
488489
if ((flags & MP_IOCTL_POLL_RD) && uart_rx_any(self)) {
489490
ret |= MP_IOCTL_POLL_RD;
490491
}
491-
if (flags & MP_IOCTL_POLL_WR) {
492-
// TODO can we always write?
492+
if ((flags & MP_IOCTL_POLL_WR) && __HAL_UART_GET_FLAG(&self->uart, UART_FLAG_TXE)) {
493493
ret |= MP_IOCTL_POLL_WR;
494494
}
495495
} else {
496-
*errcode = 1; // EPERM, operation not permitted
496+
*errcode = EINVAL;
497497
ret = -1;
498498
}
499499
va_end(vargs);

0 commit comments

Comments
 (0)