Browse Source

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
pull/9699/head
iabdalkader 2 years ago
committed by Damien George
parent
commit
93f3910fe7
  1. 2
      ports/nrf/main.c
  2. 6
      ports/nrf/modules/machine/i2c.c
  3. 2
      ports/nrf/modules/machine/i2c.h
  4. 8
      ports/nrf/modules/machine/modmachine.c
  5. 16
      ports/nrf/modules/machine/pwm.c
  6. 2
      ports/nrf/modules/machine/pwm.h
  7. 14
      ports/nrf/modules/machine/spi.c
  8. 2
      ports/nrf/modules/machine/spi.h
  9. 4
      ports/nrf/modules/machine/uart.c
  10. 2
      ports/nrf/modules/machine/uart.h
  11. 2
      ports/nrf/modules/uos/moduos.c

2
ports/nrf/main.c

@ -170,7 +170,7 @@ soft_reset:
MP_OBJ_NEW_SMALL_INT(0), MP_OBJ_NEW_SMALL_INT(0),
MP_OBJ_NEW_SMALL_INT(115200), MP_OBJ_NEW_SMALL_INT(115200),
}; };
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); 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);
} }
#endif #endif

6
ports/nrf/modules/machine/i2c.c

@ -69,8 +69,8 @@ typedef struct _machine_hard_i2c_obj_t {
} machine_hard_i2c_obj_t; } machine_hard_i2c_obj_t;
STATIC const machine_hard_i2c_obj_t machine_hard_i2c_obj[] = { STATIC const machine_hard_i2c_obj_t machine_hard_i2c_obj[] = {
{{&machine_hard_i2c_type}, .p_twi = NRFX_TWI_INSTANCE(0)}, {{&machine_i2c_type}, .p_twi = NRFX_TWI_INSTANCE(0)},
{{&machine_hard_i2c_type}, .p_twi = NRFX_TWI_INSTANCE(1)}, {{&machine_i2c_type}, .p_twi = NRFX_TWI_INSTANCE(1)},
}; };
void i2c_init0(void) { void i2c_init0(void) {
@ -162,7 +162,7 @@ STATIC const mp_machine_i2c_p_t machine_hard_i2c_p = {
}; };
MP_DEFINE_CONST_OBJ_TYPE( MP_DEFINE_CONST_OBJ_TYPE(
machine_hard_i2c_type, machine_i2c_type,
MP_QSTR_I2C, MP_QSTR_I2C,
MP_TYPE_FLAG_NONE, MP_TYPE_FLAG_NONE,
make_new, machine_hard_i2c_make_new, make_new, machine_hard_i2c_make_new,

2
ports/nrf/modules/machine/i2c.h

@ -29,7 +29,7 @@
#include "extmod/machine_i2c.h" #include "extmod/machine_i2c.h"
extern const mp_obj_type_t machine_hard_i2c_type; extern const mp_obj_type_t machine_i2c_type;
void i2c_init0(void); void i2c_init0(void);

8
ports/nrf/modules/machine/modmachine.c

@ -217,13 +217,13 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_mem32), MP_ROM_PTR(&machine_mem32_obj) }, { MP_ROM_QSTR(MP_QSTR_mem32), MP_ROM_PTR(&machine_mem32_obj) },
#if MICROPY_PY_MACHINE_UART #if MICROPY_PY_MACHINE_UART
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&machine_hard_uart_type) }, { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&machine_uart_type) },
#endif #endif
#if MICROPY_PY_MACHINE_HW_SPI #if MICROPY_PY_MACHINE_HW_SPI
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&machine_hard_spi_type) }, { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&machine_spi_type) },
#endif #endif
#if MICROPY_PY_MACHINE_I2C #if MICROPY_PY_MACHINE_I2C
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&machine_hard_i2c_type) }, { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&machine_i2c_type) },
{ MP_ROM_QSTR(MP_QSTR_SoftI2C), MP_ROM_PTR(&mp_machine_soft_i2c_type) }, { MP_ROM_QSTR(MP_QSTR_SoftI2C), MP_ROM_PTR(&mp_machine_soft_i2c_type) },
#endif #endif
#if MICROPY_PY_MACHINE_ADC #if MICROPY_PY_MACHINE_ADC
@ -236,7 +236,7 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_Timer), MP_ROM_PTR(&machine_timer_type) }, { MP_ROM_QSTR(MP_QSTR_Timer), MP_ROM_PTR(&machine_timer_type) },
#endif #endif
#if MICROPY_PY_MACHINE_HW_PWM #if MICROPY_PY_MACHINE_HW_PWM
{ MP_ROM_QSTR(MP_QSTR_PWM), MP_ROM_PTR(&machine_hard_pwm_type) }, { MP_ROM_QSTR(MP_QSTR_PWM), MP_ROM_PTR(&machine_pwm_type) },
#endif #endif
#if MICROPY_PY_MACHINE_TEMP #if MICROPY_PY_MACHINE_TEMP
{ MP_ROM_QSTR(MP_QSTR_Temp), MP_ROM_PTR(&machine_temp_type) }, { MP_ROM_QSTR(MP_QSTR_Temp), MP_ROM_PTR(&machine_temp_type) },

16
ports/nrf/modules/machine/pwm.c

@ -77,11 +77,11 @@ STATIC machine_pwm_config_t hard_configs[MP_ARRAY_SIZE(machine_hard_pwm_instance
STATIC const machine_hard_pwm_obj_t machine_hard_pwm_obj[] = { STATIC const machine_hard_pwm_obj_t machine_hard_pwm_obj[] = {
#if defined(NRF52_SERIES) #if defined(NRF52_SERIES)
{{&machine_hard_pwm_type}, .p_pwm = &machine_hard_pwm_instances[0], .p_config = &hard_configs[0]}, {{&machine_pwm_type}, .p_pwm = &machine_hard_pwm_instances[0], .p_config = &hard_configs[0]},
{{&machine_hard_pwm_type}, .p_pwm = &machine_hard_pwm_instances[1], .p_config = &hard_configs[1]}, {{&machine_pwm_type}, .p_pwm = &machine_hard_pwm_instances[1], .p_config = &hard_configs[1]},
{{&machine_hard_pwm_type}, .p_pwm = &machine_hard_pwm_instances[2], .p_config = &hard_configs[2]}, {{&machine_pwm_type}, .p_pwm = &machine_hard_pwm_instances[2], .p_config = &hard_configs[2]},
#if NRF52840 #if NRF52840
{{&machine_hard_pwm_type}, .p_pwm = &machine_hard_pwm_instances[3], .p_config = &hard_configs[3]}, {{&machine_pwm_type}, .p_pwm = &machine_hard_pwm_instances[3], .p_config = &hard_configs[3]},
#endif #endif
#endif #endif
}; };
@ -155,7 +155,7 @@ STATIC mp_obj_t machine_pwm_init(size_t n_args, const mp_obj_t *pos_args, mp_map
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
// dispatch to specific implementation // dispatch to specific implementation
if (mp_obj_get_type(self) == &machine_hard_pwm_type) { if (mp_obj_get_type(self) == &machine_pwm_type) {
machine_hard_pwm_init(self, args); machine_hard_pwm_init(self, args);
} }
@ -165,7 +165,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_pwm_init_obj, 1, machine_pwm_init);
STATIC mp_obj_t machine_pwm_deinit(mp_obj_t self) { STATIC mp_obj_t machine_pwm_deinit(mp_obj_t self) {
// dispatch to specific implementation // dispatch to specific implementation
if (mp_obj_get_type(self) == &machine_hard_pwm_type) { if (mp_obj_get_type(self) == &machine_pwm_type) {
machine_hard_pwm_deinit(self); machine_hard_pwm_deinit(self);
} }
return mp_const_none; 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
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
if (mp_obj_get_type(self) == &machine_hard_pwm_type) { if (mp_obj_get_type(self) == &machine_pwm_type) {
machine_hard_pwm_freq(self, args); machine_hard_pwm_freq(self, args);
} else { } else {
// soft pwm // soft pwm
@ -340,7 +340,7 @@ STATIC mp_obj_t machine_hard_pwm_freq(mp_obj_t self_in, mp_arg_val_t *args) {
} }
MP_DEFINE_CONST_OBJ_TYPE( MP_DEFINE_CONST_OBJ_TYPE(
machine_hard_pwm_type, machine_pwm_type,
MP_QSTR_PWM, MP_QSTR_PWM,
MP_TYPE_FLAG_NONE, MP_TYPE_FLAG_NONE,
make_new, machine_pwm_make_new, make_new, machine_pwm_make_new,

2
ports/nrf/modules/machine/pwm.h

@ -26,4 +26,4 @@
void pwm_init0(void); void pwm_init0(void);
extern const mp_obj_type_t machine_hard_pwm_type; extern const mp_obj_type_t machine_pwm_type;

14
ports/nrf/modules/machine/spi.c

@ -117,12 +117,12 @@ STATIC const nrfx_spi_t machine_spi_instances[] = {
STATIC nrfx_spi_config_t configs[MP_ARRAY_SIZE(machine_spi_instances)]; STATIC nrfx_spi_config_t configs[MP_ARRAY_SIZE(machine_spi_instances)];
STATIC const machine_hard_spi_obj_t machine_hard_spi_obj[] = { STATIC const machine_hard_spi_obj_t machine_hard_spi_obj[] = {
{{&machine_hard_spi_type}, .p_spi = &machine_spi_instances[0], .p_config = &configs[0]}, {{&machine_spi_type}, .p_spi = &machine_spi_instances[0], .p_config = &configs[0]},
{{&machine_hard_spi_type}, .p_spi = &machine_spi_instances[1], .p_config = &configs[1]}, {{&machine_spi_type}, .p_spi = &machine_spi_instances[1], .p_config = &configs[1]},
#if defined(NRF52_SERIES) #if defined(NRF52_SERIES)
{{&machine_hard_spi_type}, .p_spi = &machine_spi_instances[2], .p_config = &configs[2]}, {{&machine_spi_type}, .p_spi = &machine_spi_instances[2], .p_config = &configs[2]},
#if defined(NRF52840_XXAA) && NRFX_SPIM_ENABLED #if defined(NRF52840_XXAA) && NRFX_SPIM_ENABLED
{{&machine_hard_spi_type}, .p_spi = &machine_spi_instances[3], .p_config = &configs[3]}, {{&machine_spi_type}, .p_spi = &machine_spi_instances[3], .p_config = &configs[3]},
#endif // NRF52840_XXAA && NRFX_SPIM_ENABLED #endif // NRF52840_XXAA && NRFX_SPIM_ENABLED
#endif // NRF52_SERIES #endif // NRF52_SERIES
}; };
@ -235,7 +235,7 @@ STATIC mp_obj_t machine_spi_init(size_t n_args, const mp_obj_t *pos_args, mp_map
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
// dispatch to specific implementation // dispatch to specific implementation
if (mp_obj_get_type(self) == &machine_hard_spi_type) { if (mp_obj_get_type(self) == &machine_spi_type) {
machine_hard_spi_init(self, args); machine_hard_spi_init(self, args);
} }
@ -245,7 +245,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_spi_init_obj, 1, machine_spi_init);
STATIC mp_obj_t machine_spi_deinit(mp_obj_t self) { STATIC mp_obj_t machine_spi_deinit(mp_obj_t self) {
// dispatch to specific implementation // dispatch to specific implementation
if (mp_obj_get_type(self) == &machine_hard_spi_type) { if (mp_obj_get_type(self) == &machine_spi_type) {
machine_hard_spi_deinit(self); machine_hard_spi_deinit(self);
} }
return mp_const_none; return mp_const_none;
@ -428,7 +428,7 @@ STATIC const mp_machine_spi_p_t machine_hard_spi_p = {
}; };
MP_DEFINE_CONST_OBJ_TYPE( MP_DEFINE_CONST_OBJ_TYPE(
machine_hard_spi_type, machine_spi_type,
MP_QSTR_SPI, MP_QSTR_SPI,
MP_TYPE_FLAG_NONE, MP_TYPE_FLAG_NONE,
make_new, machine_spi_make_new, make_new, machine_spi_make_new,

2
ports/nrf/modules/machine/spi.h

@ -27,7 +27,7 @@
#include "py/obj.h" #include "py/obj.h"
typedef struct _machine_hard_spi_obj_t machine_hard_spi_obj_t; typedef struct _machine_hard_spi_obj_t machine_hard_spi_obj_t;
extern const mp_obj_type_t machine_hard_spi_type; extern const mp_obj_type_t machine_spi_type;
void spi_init0(void); void spi_init0(void);
void spi_transfer(const machine_hard_spi_obj_t * self, void spi_transfer(const machine_hard_spi_obj_t * self,

4
ports/nrf/modules/machine/uart.c

@ -106,7 +106,7 @@ static const nrfx_uart_t instance0 = NRFX_UART_INSTANCE(0);
STATIC machine_hard_uart_buf_t machine_hard_uart_buf[1]; STATIC machine_hard_uart_buf_t machine_hard_uart_buf[1];
STATIC const machine_hard_uart_obj_t machine_hard_uart_obj[] = { STATIC const machine_hard_uart_obj_t machine_hard_uart_obj[] = {
{{&machine_hard_uart_type}, .p_uart = &instance0, .buf = &machine_hard_uart_buf[0]}, {{&machine_uart_type}, .p_uart = &instance0, .buf = &machine_hard_uart_buf[0]},
}; };
void uart_init0(void) { void uart_init0(void) {
@ -371,7 +371,7 @@ STATIC const mp_stream_p_t uart_stream_p = {
}; };
MP_DEFINE_CONST_OBJ_TYPE( MP_DEFINE_CONST_OBJ_TYPE(
machine_hard_uart_type, machine_uart_type,
MP_QSTR_UART, MP_QSTR_UART,
MP_TYPE_FLAG_ITER_IS_STREAM, MP_TYPE_FLAG_ITER_IS_STREAM,
make_new, machine_hard_uart_make_new, make_new, machine_hard_uart_make_new,

2
ports/nrf/modules/machine/uart.h

@ -32,7 +32,7 @@
#include "genhdr/pins.h" #include "genhdr/pins.h"
typedef struct _machine_hard_uart_obj_t machine_hard_uart_obj_t; typedef struct _machine_hard_uart_obj_t machine_hard_uart_obj_t;
extern const mp_obj_type_t machine_hard_uart_type; extern const mp_obj_type_t machine_uart_type;
void uart_init0(void); void uart_init0(void);
void uart_deinit(void); void uart_deinit(void);

2
ports/nrf/modules/uos/moduos.c

@ -126,7 +126,7 @@ STATIC mp_obj_t os_dupterm(mp_uint_t n_args, const mp_obj_t *args) {
} else { } else {
if (args[0] == mp_const_none) { if (args[0] == mp_const_none) {
MP_STATE_PORT(board_stdio_uart) = NULL; MP_STATE_PORT(board_stdio_uart) = NULL;
} else if (mp_obj_get_type(args[0]) == &machine_hard_uart_type) { } else if (mp_obj_get_type(args[0]) == &machine_uart_type) {
MP_STATE_PORT(board_stdio_uart) = args[0]; MP_STATE_PORT(board_stdio_uart) = args[0];
} else { } else {
mp_raise_ValueError(MP_ERROR_TEXT("need a UART object")); mp_raise_ValueError(MP_ERROR_TEXT("need a UART object"));

Loading…
Cancel
Save