stmhal: uart ioctl uses EINVAL, and checks TXE bit for write-ability.
This commit is contained in:
parent
013d53c0b4
commit
5c00757a5c
@ -27,6 +27,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include "stm32f4xx_hal.h"
|
#include "stm32f4xx_hal.h"
|
||||||
|
|
||||||
@ -488,12 +489,11 @@ mp_uint_t uart_ioctl(mp_obj_t self_in, mp_uint_t request, int *errcode, ...) {
|
|||||||
if ((flags & MP_IOCTL_POLL_RD) && uart_rx_any(self)) {
|
if ((flags & MP_IOCTL_POLL_RD) && uart_rx_any(self)) {
|
||||||
ret |= MP_IOCTL_POLL_RD;
|
ret |= MP_IOCTL_POLL_RD;
|
||||||
}
|
}
|
||||||
if (flags & MP_IOCTL_POLL_WR) {
|
if ((flags & MP_IOCTL_POLL_WR) && __HAL_UART_GET_FLAG(&self->uart, UART_FLAG_TXE)) {
|
||||||
// TODO can we always write?
|
|
||||||
ret |= MP_IOCTL_POLL_WR;
|
ret |= MP_IOCTL_POLL_WR;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*errcode = 1; // EPERM, operation not permitted
|
*errcode = EINVAL;
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
va_end(vargs);
|
va_end(vargs);
|
||||||
|
Loading…
Reference in New Issue
Block a user