Browse Source

stm32: Rename machine I2C and SPI types consistently across ports.

This renames:
- machine_hard_i2c_type -> machine_i2c_type
- machine_hard_spi_type -> machine_spi_type
pull/9699/head
iabdalkader 2 years ago
committed by Damien George
parent
commit
af4ba6d1b4
  1. 18
      ports/stm32/machine_i2c.c
  2. 14
      ports/stm32/machine_spi.c
  3. 4
      ports/stm32/modmachine.c
  4. 4
      ports/stm32/modmachine.h
  5. 4
      ports/stm32/spi.c
  6. 2
      ports/stm32/spi.h

18
ports/stm32/machine_i2c.c

@ -49,16 +49,16 @@ typedef struct _machine_hard_i2c_obj_t {
STATIC const machine_hard_i2c_obj_t machine_hard_i2c_obj[MICROPY_HW_MAX_I2C] = {
#if defined(MICROPY_HW_I2C1_SCL)
[0] = {{&machine_hard_i2c_type}, I2C1, MICROPY_HW_I2C1_SCL, MICROPY_HW_I2C1_SDA},
[0] = {{&machine_i2c_type}, I2C1, MICROPY_HW_I2C1_SCL, MICROPY_HW_I2C1_SDA},
#endif
#if defined(MICROPY_HW_I2C2_SCL)
[1] = {{&machine_hard_i2c_type}, I2C2, MICROPY_HW_I2C2_SCL, MICROPY_HW_I2C2_SDA},
[1] = {{&machine_i2c_type}, I2C2, MICROPY_HW_I2C2_SCL, MICROPY_HW_I2C2_SDA},
#endif
#if defined(MICROPY_HW_I2C3_SCL)
[2] = {{&machine_hard_i2c_type}, I2C3, MICROPY_HW_I2C3_SCL, MICROPY_HW_I2C3_SDA},
[2] = {{&machine_i2c_type}, I2C3, MICROPY_HW_I2C3_SCL, MICROPY_HW_I2C3_SDA},
#endif
#if defined(MICROPY_HW_I2C4_SCL)
[3] = {{&machine_hard_i2c_type}, I2C4, MICROPY_HW_I2C4_SCL, MICROPY_HW_I2C4_SDA},
[3] = {{&machine_i2c_type}, I2C4, MICROPY_HW_I2C4_SCL, MICROPY_HW_I2C4_SDA},
#endif
};
@ -140,16 +140,16 @@ typedef mp_machine_soft_i2c_obj_t machine_hard_i2c_obj_t;
STATIC machine_hard_i2c_obj_t machine_hard_i2c_obj[MICROPY_HW_MAX_I2C] = {
#if defined(MICROPY_HW_I2C1_SCL)
[0] = {{&machine_hard_i2c_type}, 1, I2C_POLL_DEFAULT_TIMEOUT_US, MICROPY_HW_I2C1_SCL, MICROPY_HW_I2C1_SDA},
[0] = {{&machine_i2c_type}, 1, I2C_POLL_DEFAULT_TIMEOUT_US, MICROPY_HW_I2C1_SCL, MICROPY_HW_I2C1_SDA},
#endif
#if defined(MICROPY_HW_I2C2_SCL)
[1] = {{&machine_hard_i2c_type}, 1, I2C_POLL_DEFAULT_TIMEOUT_US, MICROPY_HW_I2C2_SCL, MICROPY_HW_I2C2_SDA},
[1] = {{&machine_i2c_type}, 1, I2C_POLL_DEFAULT_TIMEOUT_US, MICROPY_HW_I2C2_SCL, MICROPY_HW_I2C2_SDA},
#endif
#if defined(MICROPY_HW_I2C3_SCL)
[2] = {{&machine_hard_i2c_type}, 1, I2C_POLL_DEFAULT_TIMEOUT_US, MICROPY_HW_I2C3_SCL, MICROPY_HW_I2C3_SDA},
[2] = {{&machine_i2c_type}, 1, I2C_POLL_DEFAULT_TIMEOUT_US, MICROPY_HW_I2C3_SCL, MICROPY_HW_I2C3_SDA},
#endif
#if defined(MICROPY_HW_I2C4_SCL)
[3] = {{&machine_hard_i2c_type}, 1, I2C_POLL_DEFAULT_TIMEOUT_US, MICROPY_HW_I2C4_SCL, MICROPY_HW_I2C4_SDA},
[3] = {{&machine_i2c_type}, 1, I2C_POLL_DEFAULT_TIMEOUT_US, MICROPY_HW_I2C4_SCL, MICROPY_HW_I2C4_SDA},
#endif
};
@ -237,7 +237,7 @@ STATIC const mp_machine_i2c_p_t machine_hard_i2c_p = {
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_hard_i2c_type,
machine_i2c_type,
MP_QSTR_I2C,
MP_TYPE_FLAG_NONE,
make_new, machine_hard_i2c_make_new,

14
ports/stm32/machine_spi.c

@ -32,12 +32,12 @@
// Implementation of hard SPI for machine module
STATIC const machine_hard_spi_obj_t machine_hard_spi_obj[] = {
{{&machine_hard_spi_type}, &spi_obj[0]},
{{&machine_hard_spi_type}, &spi_obj[1]},
{{&machine_hard_spi_type}, &spi_obj[2]},
{{&machine_hard_spi_type}, &spi_obj[3]},
{{&machine_hard_spi_type}, &spi_obj[4]},
{{&machine_hard_spi_type}, &spi_obj[5]},
{{&machine_spi_type}, &spi_obj[0]},
{{&machine_spi_type}, &spi_obj[1]},
{{&machine_spi_type}, &spi_obj[2]},
{{&machine_spi_type}, &spi_obj[3]},
{{&machine_spi_type}, &spi_obj[4]},
{{&machine_spi_type}, &spi_obj[5]},
};
STATIC void machine_hard_spi_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
@ -136,7 +136,7 @@ STATIC const mp_machine_spi_p_t machine_hard_spi_p = {
};
MP_DEFINE_CONST_OBJ_TYPE(
machine_hard_spi_type,
machine_spi_type,
MP_QSTR_SPI,
MP_TYPE_FLAG_NONE,
make_new, machine_hard_spi_make_new,

4
ports/stm32/modmachine.c

@ -424,14 +424,14 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_ADC), MP_ROM_PTR(&machine_adc_type) },
#if MICROPY_PY_MACHINE_I2C
#if MICROPY_HW_ENABLE_HW_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) },
#else
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&mp_machine_soft_i2c_type) },
#endif
{ MP_ROM_QSTR(MP_QSTR_SoftI2C), MP_ROM_PTR(&mp_machine_soft_i2c_type) },
#endif
#if MICROPY_PY_MACHINE_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) },
{ MP_ROM_QSTR(MP_QSTR_SoftSPI), MP_ROM_PTR(&mp_machine_soft_spi_type) },
#endif
#if MICROPY_HW_ENABLE_I2S

4
ports/stm32/modmachine.h

@ -30,8 +30,10 @@
extern const mp_obj_type_t machine_adc_type;
extern const mp_obj_type_t machine_timer_type;
extern const mp_obj_type_t machine_hard_i2c_type;
extern const mp_obj_type_t machine_i2c_type;
extern const mp_obj_type_t machine_i2s_type;
extern const mp_obj_type_t machine_spi_type;
extern const mp_obj_type_t machine_timer_type;
void machine_init(void);
void machine_deinit(void);

4
ports/stm32/spi.c

@ -678,7 +678,7 @@ const spi_t *spi_from_mp_obj(mp_obj_t o) {
if (mp_obj_is_type(o, &pyb_spi_type)) {
pyb_spi_obj_t *self = MP_OBJ_TO_PTR(o);
return self->spi;
} else if (mp_obj_is_type(o, &machine_hard_spi_type)) {
} else if (mp_obj_is_type(o, &machine_spi_type)) {
machine_hard_spi_obj_t *self = MP_OBJ_TO_PTR(o);
return self->spi;
} else {
@ -687,7 +687,7 @@ const spi_t *spi_from_mp_obj(mp_obj_t o) {
}
mp_obj_base_t *mp_hal_get_spi_obj(mp_obj_t o) {
if (mp_obj_is_type(o, &machine_hard_spi_type)) {
if (mp_obj_is_type(o, &machine_spi_type)) {
return MP_OBJ_TO_PTR(o);
}
#if MICROPY_PY_MACHINE_SOFTSPI

2
ports/stm32/spi.h

@ -65,7 +65,7 @@ extern const spi_t spi_obj[6];
extern const mp_spi_proto_t spi_proto;
extern const mp_obj_type_t pyb_spi_type;
extern const mp_obj_type_t machine_hard_spi_type;
extern const mp_obj_type_t machine_spi_type;
// A transfer of "len" bytes should take len*8*1000/baudrate milliseconds.
// To simplify the calculation we assume the baudrate is never less than 8kHz

Loading…
Cancel
Save