Skip to content

Commit cd56399

Browse files
oddstr13dpgeorge
authored andcommitted
esp32/machine_uart: Rename pyb to machine.
1 parent f950769 commit cd56399

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

esp32/machine_uart.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
// UartDev is defined and initialized in rom code.
4040
extern UartDevice UartDev;
4141

42-
typedef struct _pyb_uart_obj_t {
42+
typedef struct _machine_uart_obj_t {
4343
mp_obj_base_t base;
4444
uint8_t uart_id;
4545
uint8_t bits;
@@ -48,21 +48,21 @@ typedef struct _pyb_uart_obj_t {
4848
uint32_t baudrate;
4949
uint16_t timeout; // timeout waiting for first char (in ms)
5050
uint16_t timeout_char; // timeout waiting between chars (in ms)
51-
} pyb_uart_obj_t;
51+
} machine_uart_obj_t;
5252

5353
STATIC const char *_parity_name[] = {"None", "1", "0"};
5454

5555
/******************************************************************************/
5656
// MicroPython bindings for UART
5757

58-
STATIC void pyb_uart_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
59-
pyb_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
58+
STATIC void machine_uart_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
59+
machine_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
6060
mp_printf(print, "UART(%u, baudrate=%u, bits=%u, parity=%s, stop=%u, timeout=%u, timeout_char=%u)",
6161
self->uart_id, self->baudrate, self->bits, _parity_name[self->parity],
6262
self->stop, self->timeout, self->timeout_char);
6363
}
6464

65-
STATIC void pyb_uart_init_helper(pyb_uart_obj_t *self, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
65+
STATIC void machine_uart_init_helper(machine_uart_obj_t *self, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
6666
enum { ARG_baudrate, ARG_bits, ARG_parity, ARG_stop, ARG_timeout, ARG_timeout_char };
6767
static const mp_arg_t allowed_args[] = {
6868
{ MP_QSTR_baudrate, MP_ARG_INT, {.u_int = 0} },
@@ -159,7 +159,7 @@ STATIC void pyb_uart_init_helper(pyb_uart_obj_t *self, size_t n_args, const mp_o
159159
uart_setup(self->uart_id);
160160
}
161161

162-
STATIC mp_obj_t pyb_uart_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
162+
STATIC mp_obj_t machine_uart_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
163163
mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);
164164

165165
// get uart id
@@ -169,8 +169,8 @@ STATIC mp_obj_t pyb_uart_make_new(const mp_obj_type_t *type, size_t n_args, size
169169
}
170170

171171
// create instance
172-
pyb_uart_obj_t *self = m_new_obj(pyb_uart_obj_t);
173-
self->base.type = &pyb_uart_type;
172+
machine_uart_obj_t *self = m_new_obj(machine_uart_obj_t);
173+
self->base.type = &machine_uart_type;
174174
self->uart_id = uart_id;
175175
self->baudrate = 115200;
176176
self->bits = 8;
@@ -182,30 +182,30 @@ STATIC mp_obj_t pyb_uart_make_new(const mp_obj_type_t *type, size_t n_args, size
182182
// init the peripheral
183183
mp_map_t kw_args;
184184
mp_map_init_fixed_table(&kw_args, n_kw, args + n_args);
185-
pyb_uart_init_helper(self, n_args - 1, args + 1, &kw_args);
185+
machine_uart_init_helper(self, n_args - 1, args + 1, &kw_args);
186186

187187
return MP_OBJ_FROM_PTR(self);
188188
}
189189

190-
STATIC mp_obj_t pyb_uart_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
191-
pyb_uart_init_helper(args[0], n_args - 1, args + 1, kw_args);
190+
STATIC mp_obj_t machine_uart_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
191+
machine_uart_init_helper(args[0], n_args - 1, args + 1, kw_args);
192192
return mp_const_none;
193193
}
194-
MP_DEFINE_CONST_FUN_OBJ_KW(pyb_uart_init_obj, 1, pyb_uart_init);
194+
MP_DEFINE_CONST_FUN_OBJ_KW(machine_uart_init_obj, 1, machine_uart_init);
195195

196-
STATIC const mp_rom_map_elem_t pyb_uart_locals_dict_table[] = {
197-
{ MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&pyb_uart_init_obj) },
196+
STATIC const mp_rom_map_elem_t machine_uart_locals_dict_table[] = {
197+
{ MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&machine_uart_init_obj) },
198198

199199
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },
200200
{ MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) },
201201
{ MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
202202
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) },
203203
};
204204

205-
STATIC MP_DEFINE_CONST_DICT(pyb_uart_locals_dict, pyb_uart_locals_dict_table);
205+
STATIC MP_DEFINE_CONST_DICT(machine_uart_locals_dict, machine_uart_locals_dict_table);
206206

207-
STATIC mp_uint_t pyb_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, int *errcode) {
208-
pyb_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
207+
STATIC mp_uint_t machine_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, int *errcode) {
208+
machine_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
209209

210210
if (self->uart_id == 1) {
211211
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "UART(1) can't read"));
@@ -233,8 +233,8 @@ STATIC mp_uint_t pyb_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t size, i
233233
}
234234
}
235235

236-
STATIC mp_uint_t pyb_uart_write(mp_obj_t self_in, const void *buf_in, mp_uint_t size, int *errcode) {
237-
pyb_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
236+
STATIC mp_uint_t machine_uart_write(mp_obj_t self_in, const void *buf_in, mp_uint_t size, int *errcode) {
237+
machine_uart_obj_t *self = MP_OBJ_TO_PTR(self_in);
238238
const byte *buf = buf_in;
239239

240240
/* TODO implement non-blocking
@@ -254,8 +254,8 @@ STATIC mp_uint_t pyb_uart_write(mp_obj_t self_in, const void *buf_in, mp_uint_t
254254
return size;
255255
}
256256

257-
STATIC mp_uint_t pyb_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) {
258-
pyb_uart_obj_t *self = self_in;
257+
STATIC mp_uint_t machine_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t arg, int *errcode) {
258+
machine_uart_obj_t *self = self_in;
259259
mp_uint_t ret;
260260
if (request == MP_STREAM_POLL) {
261261
mp_uint_t flags = arg;
@@ -274,19 +274,19 @@ STATIC mp_uint_t pyb_uart_ioctl(mp_obj_t self_in, mp_uint_t request, mp_uint_t a
274274
}
275275

276276
STATIC const mp_stream_p_t uart_stream_p = {
277-
.read = pyb_uart_read,
278-
.write = pyb_uart_write,
279-
.ioctl = pyb_uart_ioctl,
277+
.read = machine_uart_read,
278+
.write = machine_uart_write,
279+
.ioctl = machine_uart_ioctl,
280280
.is_text = false,
281281
};
282282

283-
const mp_obj_type_t pyb_uart_type = {
283+
const mp_obj_type_t machine_uart_type = {
284284
{ &mp_type_type },
285285
.name = MP_QSTR_UART,
286-
.print = pyb_uart_print,
287-
.make_new = pyb_uart_make_new,
286+
.print = machine_uart_print,
287+
.make_new = machine_uart_make_new,
288288
.getiter = mp_identity_getiter,
289289
.iternext = mp_stream_unbuffered_iter,
290290
.protocol = &uart_stream_p,
291-
.locals_dict = (mp_obj_dict_t*)&pyb_uart_locals_dict,
291+
.locals_dict = (mp_obj_dict_t*)&machine_uart_locals_dict,
292292
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy