Skip to content

Commit 93f3910

Browse files
iabdalkaderdpgeorge
authored andcommitted
nrf: Rename machine I2C, PWM, SPI, UART types consistently across ports.
This renames: - machine_hard_i2c_type -> machine_i2c_type - machine_hard_pwm_type -> machine_pwm_type - machine_hard_spi_type -> machine_spi_type - machine_hard_uart_type -> machine_uart_type
1 parent 5e90ec2 commit 93f3910

File tree

11 files changed

+30
-30
lines changed

11 files changed

+30
-30
lines changed

ports/nrf/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ int main(int argc, char **argv) {
170170
MP_OBJ_NEW_SMALL_INT(0),
171171
MP_OBJ_NEW_SMALL_INT(115200),
172172
};
173-
MP_STATE_PORT(board_stdio_uart) = MP_OBJ_TYPE_GET_SLOT(&machine_hard_uart_type, make_new)((mp_obj_t)&machine_hard_uart_type, MP_ARRAY_SIZE(args), 0, args);
173+
MP_STATE_PORT(board_stdio_uart) = MP_OBJ_TYPE_GET_SLOT(&machine_uart_type, make_new)((mp_obj_t)&machine_uart_type, MP_ARRAY_SIZE(args), 0, args);
174174
}
175175
#endif
176176

ports/nrf/modules/machine/i2c.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ typedef struct _machine_hard_i2c_obj_t {
6969
} machine_hard_i2c_obj_t;
7070

7171
STATIC const machine_hard_i2c_obj_t machine_hard_i2c_obj[] = {
72-
{{&machine_hard_i2c_type}, .p_twi = NRFX_TWI_INSTANCE(0)},
73-
{{&machine_hard_i2c_type}, .p_twi = NRFX_TWI_INSTANCE(1)},
72+
{{&machine_i2c_type}, .p_twi = NRFX_TWI_INSTANCE(0)},
73+
{{&machine_i2c_type}, .p_twi = NRFX_TWI_INSTANCE(1)},
7474
};
7575

7676
void i2c_init0(void) {
@@ -162,7 +162,7 @@ STATIC const mp_machine_i2c_p_t machine_hard_i2c_p = {
162162
};
163163

164164
MP_DEFINE_CONST_OBJ_TYPE(
165-
machine_hard_i2c_type,
165+
machine_i2c_type,
166166
MP_QSTR_I2C,
167167
MP_TYPE_FLAG_NONE,
168168
make_new, machine_hard_i2c_make_new,

ports/nrf/modules/machine/i2c.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#include "extmod/machine_i2c.h"
3131

32-
extern const mp_obj_type_t machine_hard_i2c_type;
32+
extern const mp_obj_type_t machine_i2c_type;
3333

3434
void i2c_init0(void);
3535

ports/nrf/modules/machine/modmachine.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,13 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
217217
{ MP_ROM_QSTR(MP_QSTR_mem32), MP_ROM_PTR(&machine_mem32_obj) },
218218

219219
#if MICROPY_PY_MACHINE_UART
220-
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&machine_hard_uart_type) },
220+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&machine_uart_type) },
221221
#endif
222222
#if MICROPY_PY_MACHINE_HW_SPI
223-
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&machine_hard_spi_type) },
223+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&machine_spi_type) },
224224
#endif
225225
#if MICROPY_PY_MACHINE_I2C
226-
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&machine_hard_i2c_type) },
226+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&machine_i2c_type) },
227227
{ MP_ROM_QSTR(MP_QSTR_SoftI2C), MP_ROM_PTR(&mp_machine_soft_i2c_type) },
228228
#endif
229229
#if MICROPY_PY_MACHINE_ADC
@@ -236,7 +236,7 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
236236
{ MP_ROM_QSTR(MP_QSTR_Timer), MP_ROM_PTR(&machine_timer_type) },
237237
#endif
238238
#if MICROPY_PY_MACHINE_HW_PWM
239-
{ MP_ROM_QSTR(MP_QSTR_PWM), MP_ROM_PTR(&machine_hard_pwm_type) },
239+
{ MP_ROM_QSTR(MP_QSTR_PWM), MP_ROM_PTR(&machine_pwm_type) },
240240
#endif
241241
#if MICROPY_PY_MACHINE_TEMP
242242
{ MP_ROM_QSTR(MP_QSTR_Temp), MP_ROM_PTR(&machine_temp_type) },

ports/nrf/modules/machine/pwm.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ STATIC machine_pwm_config_t hard_configs[MP_ARRAY_SIZE(machine_hard_pwm_instance
7777

7878
STATIC const machine_hard_pwm_obj_t machine_hard_pwm_obj[] = {
7979
#if defined(NRF52_SERIES)
80-
{{&machine_hard_pwm_type}, .p_pwm = &machine_hard_pwm_instances[0], .p_config = &hard_configs[0]},
81-
{{&machine_hard_pwm_type}, .p_pwm = &machine_hard_pwm_instances[1], .p_config = &hard_configs[1]},
82-
{{&machine_hard_pwm_type}, .p_pwm = &machine_hard_pwm_instances[2], .p_config = &hard_configs[2]},
80+
{{&machine_pwm_type}, .p_pwm = &machine_hard_pwm_instances[0], .p_config = &hard_configs[0]},
81+
{{&machine_pwm_type}, .p_pwm = &machine_hard_pwm_instances[1], .p_config = &hard_configs[1]},
82+
{{&machine_pwm_type}, .p_pwm = &machine_hard_pwm_instances[2], .p_config = &hard_configs[2]},
8383
#if NRF52840
84-
{{&machine_hard_pwm_type}, .p_pwm = &machine_hard_pwm_instances[3], .p_config = &hard_configs[3]},
84+
{{&machine_pwm_type}, .p_pwm = &machine_hard_pwm_instances[3], .p_config = &hard_configs[3]},
8585
#endif
8686
#endif
8787
};
@@ -155,7 +155,7 @@ STATIC mp_obj_t machine_pwm_init(size_t n_args, const mp_obj_t *pos_args, mp_map
155155
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
156156

157157
// dispatch to specific implementation
158-
if (mp_obj_get_type(self) == &machine_hard_pwm_type) {
158+
if (mp_obj_get_type(self) == &machine_pwm_type) {
159159
machine_hard_pwm_init(self, args);
160160
}
161161

@@ -165,7 +165,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_pwm_init_obj, 1, machine_pwm_init);
165165

166166
STATIC mp_obj_t machine_pwm_deinit(mp_obj_t self) {
167167
// dispatch to specific implementation
168-
if (mp_obj_get_type(self) == &machine_hard_pwm_type) {
168+
if (mp_obj_get_type(self) == &machine_pwm_type) {
169169
machine_hard_pwm_deinit(self);
170170
}
171171
return mp_const_none;
@@ -182,7 +182,7 @@ STATIC mp_obj_t machine_pwm_freq(size_t n_args, const mp_obj_t *pos_args, mp_map
182182
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
183183
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
184184

185-
if (mp_obj_get_type(self) == &machine_hard_pwm_type) {
185+
if (mp_obj_get_type(self) == &machine_pwm_type) {
186186
machine_hard_pwm_freq(self, args);
187187
} else {
188188
// soft pwm
@@ -340,7 +340,7 @@ STATIC mp_obj_t machine_hard_pwm_freq(mp_obj_t self_in, mp_arg_val_t *args) {
340340
}
341341

342342
MP_DEFINE_CONST_OBJ_TYPE(
343-
machine_hard_pwm_type,
343+
machine_pwm_type,
344344
MP_QSTR_PWM,
345345
MP_TYPE_FLAG_NONE,
346346
make_new, machine_pwm_make_new,

ports/nrf/modules/machine/pwm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626

2727
void pwm_init0(void);
2828

29-
extern const mp_obj_type_t machine_hard_pwm_type;
29+
extern const mp_obj_type_t machine_pwm_type;

ports/nrf/modules/machine/spi.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ STATIC const nrfx_spi_t machine_spi_instances[] = {
117117
STATIC nrfx_spi_config_t configs[MP_ARRAY_SIZE(machine_spi_instances)];
118118

119119
STATIC const machine_hard_spi_obj_t machine_hard_spi_obj[] = {
120-
{{&machine_hard_spi_type}, .p_spi = &machine_spi_instances[0], .p_config = &configs[0]},
121-
{{&machine_hard_spi_type}, .p_spi = &machine_spi_instances[1], .p_config = &configs[1]},
120+
{{&machine_spi_type}, .p_spi = &machine_spi_instances[0], .p_config = &configs[0]},
121+
{{&machine_spi_type}, .p_spi = &machine_spi_instances[1], .p_config = &configs[1]},
122122
#if defined(NRF52_SERIES)
123-
{{&machine_hard_spi_type}, .p_spi = &machine_spi_instances[2], .p_config = &configs[2]},
123+
{{&machine_spi_type}, .p_spi = &machine_spi_instances[2], .p_config = &configs[2]},
124124
#if defined(NRF52840_XXAA) && NRFX_SPIM_ENABLED
125-
{{&machine_hard_spi_type}, .p_spi = &machine_spi_instances[3], .p_config = &configs[3]},
125+
{{&machine_spi_type}, .p_spi = &machine_spi_instances[3], .p_config = &configs[3]},
126126
#endif // NRF52840_XXAA && NRFX_SPIM_ENABLED
127127
#endif // NRF52_SERIES
128128
};
@@ -235,7 +235,7 @@ STATIC mp_obj_t machine_spi_init(size_t n_args, const mp_obj_t *pos_args, mp_map
235235
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
236236

237237
// dispatch to specific implementation
238-
if (mp_obj_get_type(self) == &machine_hard_spi_type) {
238+
if (mp_obj_get_type(self) == &machine_spi_type) {
239239
machine_hard_spi_init(self, args);
240240
}
241241

@@ -245,7 +245,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_spi_init_obj, 1, machine_spi_init);
245245

246246
STATIC mp_obj_t machine_spi_deinit(mp_obj_t self) {
247247
// dispatch to specific implementation
248-
if (mp_obj_get_type(self) == &machine_hard_spi_type) {
248+
if (mp_obj_get_type(self) == &machine_spi_type) {
249249
machine_hard_spi_deinit(self);
250250
}
251251
return mp_const_none;
@@ -428,7 +428,7 @@ STATIC const mp_machine_spi_p_t machine_hard_spi_p = {
428428
};
429429

430430
MP_DEFINE_CONST_OBJ_TYPE(
431-
machine_hard_spi_type,
431+
machine_spi_type,
432432
MP_QSTR_SPI,
433433
MP_TYPE_FLAG_NONE,
434434
make_new, machine_spi_make_new,

ports/nrf/modules/machine/spi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "py/obj.h"
2828

2929
typedef struct _machine_hard_spi_obj_t machine_hard_spi_obj_t;
30-
extern const mp_obj_type_t machine_hard_spi_type;
30+
extern const mp_obj_type_t machine_spi_type;
3131

3232
void spi_init0(void);
3333
void spi_transfer(const machine_hard_spi_obj_t * self,

ports/nrf/modules/machine/uart.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static const nrfx_uart_t instance0 = NRFX_UART_INSTANCE(0);
106106
STATIC machine_hard_uart_buf_t machine_hard_uart_buf[1];
107107

108108
STATIC const machine_hard_uart_obj_t machine_hard_uart_obj[] = {
109-
{{&machine_hard_uart_type}, .p_uart = &instance0, .buf = &machine_hard_uart_buf[0]},
109+
{{&machine_uart_type}, .p_uart = &instance0, .buf = &machine_hard_uart_buf[0]},
110110
};
111111

112112
void uart_init0(void) {
@@ -371,7 +371,7 @@ STATIC const mp_stream_p_t uart_stream_p = {
371371
};
372372

373373
MP_DEFINE_CONST_OBJ_TYPE(
374-
machine_hard_uart_type,
374+
machine_uart_type,
375375
MP_QSTR_UART,
376376
MP_TYPE_FLAG_ITER_IS_STREAM,
377377
make_new, machine_hard_uart_make_new,

ports/nrf/modules/machine/uart.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include "genhdr/pins.h"
3333

3434
typedef struct _machine_hard_uart_obj_t machine_hard_uart_obj_t;
35-
extern const mp_obj_type_t machine_hard_uart_type;
35+
extern const mp_obj_type_t machine_uart_type;
3636

3737
void uart_init0(void);
3838
void uart_deinit(void);

0 commit comments

Comments
 (0)