Skip to content

Commit 23c292a

Browse files
committed
Add native_uart calls
1 parent 4809c92 commit 23c292a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

shared-bindings/busio/UART.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ busio_uart_obj_t* native_uart(mp_obj_t uart_obj) {
160160
//| ...
161161
//|
162162
STATIC mp_obj_t busio_uart_obj_deinit(mp_obj_t self_in) {
163-
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
163+
busio_uart_obj_t *self = native_uart(self_in);
164164
common_hal_busio_uart_deinit(self);
165165
return mp_const_none;
166166
}
@@ -236,7 +236,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_
236236
// These three methods are used by the shared stream methods.
237237
STATIC mp_uint_t busio_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, int *errcode) {
238238
STREAM_DEBUG("busio_uart_read stream %d\n", size);
239-
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
239+
busio_uart_obj_t *self = native_uart(self_in);
240240
check_for_deinit(self);
241241
byte *buf = buf_in;
242242

@@ -249,15 +249,15 @@ STATIC mp_uint_t busio_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t size,
249249
}
250250

251251
STATIC mp_uint_t busio_uart_write(mp_obj_t self_in, const void *buf_in, mp_uint_t size, int *errcode) {
252-
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
252+
busio_uart_obj_t *self = native_uart(self_in);
253253
check_for_deinit(self);
254254
const byte *buf = buf_in;
255255

256256
return common_hal_busio_uart_write(self, buf, size, errcode);
257257
}
258258

259259
STATIC mp_uint_t busio_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) {
260-
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
260+
busio_uart_obj_t *self = native_uart(self_in);
261261
check_for_deinit(self);
262262
mp_uint_t ret;
263263
if (request == MP_IOCTL_POLL) {
@@ -280,14 +280,14 @@ STATIC mp_uint_t busio_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t
280280
//| """The current baudrate."""
281281
//|
282282
STATIC mp_obj_t busio_uart_obj_get_baudrate(mp_obj_t self_in) {
283-
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
283+
busio_uart_obj_t *self = native_uart(self_in);
284284
check_for_deinit(self);
285285
return MP_OBJ_NEW_SMALL_INT(common_hal_busio_uart_get_baudrate(self));
286286
}
287287
MP_DEFINE_CONST_FUN_OBJ_1(busio_uart_get_baudrate_obj, busio_uart_obj_get_baudrate);
288288

289289
STATIC mp_obj_t busio_uart_obj_set_baudrate(mp_obj_t self_in, mp_obj_t baudrate) {
290-
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
290+
busio_uart_obj_t *self = native_uart(self_in);
291291
check_for_deinit(self);
292292
common_hal_busio_uart_set_baudrate(self, mp_obj_get_int(baudrate));
293293
return mp_const_none;
@@ -306,7 +306,7 @@ const mp_obj_property_t busio_uart_baudrate_obj = {
306306
//| """The number of bytes in the input buffer, available to be read"""
307307
//|
308308
STATIC mp_obj_t busio_uart_obj_get_in_waiting(mp_obj_t self_in) {
309-
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
309+
busio_uart_obj_t *self = native_uart(self_in);
310310
check_for_deinit(self);
311311
return MP_OBJ_NEW_SMALL_INT(common_hal_busio_uart_rx_characters_available(self));
312312
}
@@ -323,14 +323,14 @@ const mp_obj_property_t busio_uart_in_waiting_obj = {
323323
//| """The current timeout, in seconds (float)."""
324324
//|
325325
STATIC mp_obj_t busio_uart_obj_get_timeout(mp_obj_t self_in) {
326-
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
326+
busio_uart_obj_t *self = native_uart(self_in);
327327
check_for_deinit(self);
328328
return mp_obj_new_float(common_hal_busio_uart_get_timeout(self));
329329
}
330330
MP_DEFINE_CONST_FUN_OBJ_1(busio_uart_get_timeout_obj, busio_uart_obj_get_timeout);
331331

332332
STATIC mp_obj_t busio_uart_obj_set_timeout(mp_obj_t self_in, mp_obj_t timeout) {
333-
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
333+
busio_uart_obj_t *self = native_uart(self_in);
334334
check_for_deinit(self);
335335
mp_float_t timeout_float = mp_obj_get_float(timeout);
336336
validate_timeout(timeout_float);
@@ -352,7 +352,7 @@ const mp_obj_property_t busio_uart_timeout_obj = {
352352
//| ...
353353
//|
354354
STATIC mp_obj_t busio_uart_obj_reset_input_buffer(mp_obj_t self_in) {
355-
busio_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
355+
busio_uart_obj_t *self = native_uart(self_in);
356356
check_for_deinit(self);
357357
common_hal_busio_uart_clear_rx_buffer(self);
358358
return mp_const_none;

0 commit comments

Comments
 (0)