@@ -160,7 +160,7 @@ busio_uart_obj_t* native_uart(mp_obj_t uart_obj) {
160
160
//| ...
161
161
//|
162
162
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 );
164
164
common_hal_busio_uart_deinit (self );
165
165
return mp_const_none ;
166
166
}
@@ -236,7 +236,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_uart___exit___obj, 4, 4, busio_
236
236
// These three methods are used by the shared stream methods.
237
237
STATIC mp_uint_t busio_uart_read (mp_obj_t self_in , void * buf_in , mp_uint_t size , int * errcode ) {
238
238
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 );
240
240
check_for_deinit (self );
241
241
byte * buf = buf_in ;
242
242
@@ -249,15 +249,15 @@ STATIC mp_uint_t busio_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t size,
249
249
}
250
250
251
251
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 );
253
253
check_for_deinit (self );
254
254
const byte * buf = buf_in ;
255
255
256
256
return common_hal_busio_uart_write (self , buf , size , errcode );
257
257
}
258
258
259
259
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 );
261
261
check_for_deinit (self );
262
262
mp_uint_t ret ;
263
263
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
280
280
//| """The current baudrate."""
281
281
//|
282
282
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 );
284
284
check_for_deinit (self );
285
285
return MP_OBJ_NEW_SMALL_INT (common_hal_busio_uart_get_baudrate (self ));
286
286
}
287
287
MP_DEFINE_CONST_FUN_OBJ_1 (busio_uart_get_baudrate_obj , busio_uart_obj_get_baudrate );
288
288
289
289
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 );
291
291
check_for_deinit (self );
292
292
common_hal_busio_uart_set_baudrate (self , mp_obj_get_int (baudrate ));
293
293
return mp_const_none ;
@@ -306,7 +306,7 @@ const mp_obj_property_t busio_uart_baudrate_obj = {
306
306
//| """The number of bytes in the input buffer, available to be read"""
307
307
//|
308
308
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 );
310
310
check_for_deinit (self );
311
311
return MP_OBJ_NEW_SMALL_INT (common_hal_busio_uart_rx_characters_available (self ));
312
312
}
@@ -323,14 +323,14 @@ const mp_obj_property_t busio_uart_in_waiting_obj = {
323
323
//| """The current timeout, in seconds (float)."""
324
324
//|
325
325
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 );
327
327
check_for_deinit (self );
328
328
return mp_obj_new_float (common_hal_busio_uart_get_timeout (self ));
329
329
}
330
330
MP_DEFINE_CONST_FUN_OBJ_1 (busio_uart_get_timeout_obj , busio_uart_obj_get_timeout );
331
331
332
332
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 );
334
334
check_for_deinit (self );
335
335
mp_float_t timeout_float = mp_obj_get_float (timeout );
336
336
validate_timeout (timeout_float );
@@ -352,7 +352,7 @@ const mp_obj_property_t busio_uart_timeout_obj = {
352
352
//| ...
353
353
//|
354
354
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 );
356
356
check_for_deinit (self );
357
357
common_hal_busio_uart_clear_rx_buffer (self );
358
358
return mp_const_none ;
0 commit comments