summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/modselect.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-08-21 22:48:23 +0100
committerDamien George <damien.p.george@gmail.com>2014-09-07 20:40:32 +0100
commita2f55fe12bac3e33d0c97f834b7f0a0382e969f5 (patch)
treed6ef93a71ed61fab30b33a0e378883ffd5a2aa66 /stmhal/modselect.c
parent6c9c7bc75a48e71b31dfce4ec55cbd0d308771fd (diff)
downloadmicropython-a2f55fe12bac3e33d0c97f834b7f0a0382e969f5.tar.gz
micropython-a2f55fe12bac3e33d0c97f834b7f0a0382e969f5.zip
stmhal: Add polling ability to UART object.
Diffstat (limited to 'stmhal/modselect.c')
-rw-r--r--stmhal/modselect.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/stmhal/modselect.c b/stmhal/modselect.c
index 6b58c04bb8..6ae3585352 100644
--- a/stmhal/modselect.c
+++ b/stmhal/modselect.c
@@ -35,16 +35,10 @@
#include "qstr.h"
#include "obj.h"
#include "objlist.h"
+#include "pybioctl.h"
/// \moduleref select
-#define MP_IOCTL_POLL (0x100 | 1)
-
-#define MP_IOCTL_POLL_RD (0x0001)
-#define MP_IOCTL_POLL_WR (0x0002)
-#define MP_IOCTL_POLL_HUP (0x0004)
-#define MP_IOCTL_POLL_ERR (0x0008)
-
typedef struct _poll_obj_t {
mp_uint_t (*ioctl)(mp_obj_t obj, mp_uint_t request, int *errcode, ...);
mp_uint_t flags;
@@ -85,13 +79,13 @@ STATIC mp_uint_t poll_map_poll(mp_map_t *poll_map, mp_uint_t *rwx_num) {
}
poll_obj_t *poll_obj = (poll_obj_t*)poll_map->table[i].value;
- int errno;
- mp_int_t ret = poll_obj->ioctl(poll_map->table[i].key, MP_IOCTL_POLL, &errno, poll_obj->flags);
+ int errcode;
+ mp_int_t ret = poll_obj->ioctl(poll_map->table[i].key, MP_IOCTL_POLL, &errcode, poll_obj->flags);
poll_obj->flags_ret = ret;
if (ret == -1) {
// error doing ioctl
- nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno)));
+ nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errcode)));
}
if (ret != 0) {