summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/uart.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-09-07 20:57:18 +0100
committerDamien George <damien.p.george@gmail.com>2014-09-07 20:57:18 +0100
commit5c00757a5cac767ee30fa25bbf720e85477f899d (patch)
tree519b0f227d020fe3fe4256ade0bdce8c04d79b8d /stmhal/uart.c
parent013d53c0b48cd22ef9476f048c2f944a86d5ce67 (diff)
downloadmicropython-5c00757a5cac767ee30fa25bbf720e85477f899d.tar.gz
micropython-5c00757a5cac767ee30fa25bbf720e85477f899d.zip
stmhal: uart ioctl uses EINVAL, and checks TXE bit for write-ability.
Diffstat (limited to 'stmhal/uart.c')
-rw-r--r--stmhal/uart.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/stmhal/uart.c b/stmhal/uart.c
index 884490a5f4..84ea22fd58 100644
--- a/stmhal/uart.c
+++ b/stmhal/uart.c
@@ -27,6 +27,7 @@
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
+#include <errno.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)) {
ret |= MP_IOCTL_POLL_RD;
}
- if (flags & MP_IOCTL_POLL_WR) {
- // TODO can we always write?
+ if ((flags & MP_IOCTL_POLL_WR) && __HAL_UART_GET_FLAG(&self->uart, UART_FLAG_TXE)) {
ret |= MP_IOCTL_POLL_WR;
}
} else {
- *errcode = 1; // EPERM, operation not permitted
+ *errcode = EINVAL;
ret = -1;
}
va_end(vargs);