Skip to content

Commit af4ba6d

Browse files
iabdalkaderdpgeorge
authored andcommitted
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
1 parent 965a87b commit af4ba6d

File tree

6 files changed

+24
-22
lines changed

6 files changed

+24
-22
lines changed

ports/stm32/machine_i2c.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ typedef struct _machine_hard_i2c_obj_t {
4949

5050
STATIC const machine_hard_i2c_obj_t machine_hard_i2c_obj[MICROPY_HW_MAX_I2C] = {
5151
#if defined(MICROPY_HW_I2C1_SCL)
52-
[0] = {{&machine_hard_i2c_type}, I2C1, MICROPY_HW_I2C1_SCL, MICROPY_HW_I2C1_SDA},
52+
[0] = {{&machine_i2c_type}, I2C1, MICROPY_HW_I2C1_SCL, MICROPY_HW_I2C1_SDA},
5353
#endif
5454
#if defined(MICROPY_HW_I2C2_SCL)
55-
[1] = {{&machine_hard_i2c_type}, I2C2, MICROPY_HW_I2C2_SCL, MICROPY_HW_I2C2_SDA},
55+
[1] = {{&machine_i2c_type}, I2C2, MICROPY_HW_I2C2_SCL, MICROPY_HW_I2C2_SDA},
5656
#endif
5757
#if defined(MICROPY_HW_I2C3_SCL)
58-
[2] = {{&machine_hard_i2c_type}, I2C3, MICROPY_HW_I2C3_SCL, MICROPY_HW_I2C3_SDA},
58+
[2] = {{&machine_i2c_type}, I2C3, MICROPY_HW_I2C3_SCL, MICROPY_HW_I2C3_SDA},
5959
#endif
6060
#if defined(MICROPY_HW_I2C4_SCL)
61-
[3] = {{&machine_hard_i2c_type}, I2C4, MICROPY_HW_I2C4_SCL, MICROPY_HW_I2C4_SDA},
61+
[3] = {{&machine_i2c_type}, I2C4, MICROPY_HW_I2C4_SCL, MICROPY_HW_I2C4_SDA},
6262
#endif
6363
};
6464

@@ -140,16 +140,16 @@ typedef mp_machine_soft_i2c_obj_t machine_hard_i2c_obj_t;
140140

141141
STATIC machine_hard_i2c_obj_t machine_hard_i2c_obj[MICROPY_HW_MAX_I2C] = {
142142
#if defined(MICROPY_HW_I2C1_SCL)
143-
[0] = {{&machine_hard_i2c_type}, 1, I2C_POLL_DEFAULT_TIMEOUT_US, MICROPY_HW_I2C1_SCL, MICROPY_HW_I2C1_SDA},
143+
[0] = {{&machine_i2c_type}, 1, I2C_POLL_DEFAULT_TIMEOUT_US, MICROPY_HW_I2C1_SCL, MICROPY_HW_I2C1_SDA},
144144
#endif
145145
#if defined(MICROPY_HW_I2C2_SCL)
146-
[1] = {{&machine_hard_i2c_type}, 1, I2C_POLL_DEFAULT_TIMEOUT_US, MICROPY_HW_I2C2_SCL, MICROPY_HW_I2C2_SDA},
146+
[1] = {{&machine_i2c_type}, 1, I2C_POLL_DEFAULT_TIMEOUT_US, MICROPY_HW_I2C2_SCL, MICROPY_HW_I2C2_SDA},
147147
#endif
148148
#if defined(MICROPY_HW_I2C3_SCL)
149-
[2] = {{&machine_hard_i2c_type}, 1, I2C_POLL_DEFAULT_TIMEOUT_US, MICROPY_HW_I2C3_SCL, MICROPY_HW_I2C3_SDA},
149+
[2] = {{&machine_i2c_type}, 1, I2C_POLL_DEFAULT_TIMEOUT_US, MICROPY_HW_I2C3_SCL, MICROPY_HW_I2C3_SDA},
150150
#endif
151151
#if defined(MICROPY_HW_I2C4_SCL)
152-
[3] = {{&machine_hard_i2c_type}, 1, I2C_POLL_DEFAULT_TIMEOUT_US, MICROPY_HW_I2C4_SCL, MICROPY_HW_I2C4_SDA},
152+
[3] = {{&machine_i2c_type}, 1, I2C_POLL_DEFAULT_TIMEOUT_US, MICROPY_HW_I2C4_SCL, MICROPY_HW_I2C4_SDA},
153153
#endif
154154
};
155155

@@ -237,7 +237,7 @@ STATIC const mp_machine_i2c_p_t machine_hard_i2c_p = {
237237
};
238238

239239
MP_DEFINE_CONST_OBJ_TYPE(
240-
machine_hard_i2c_type,
240+
machine_i2c_type,
241241
MP_QSTR_I2C,
242242
MP_TYPE_FLAG_NONE,
243243
make_new, machine_hard_i2c_make_new,

ports/stm32/machine_spi.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
// Implementation of hard SPI for machine module
3333

3434
STATIC const machine_hard_spi_obj_t machine_hard_spi_obj[] = {
35-
{{&machine_hard_spi_type}, &spi_obj[0]},
36-
{{&machine_hard_spi_type}, &spi_obj[1]},
37-
{{&machine_hard_spi_type}, &spi_obj[2]},
38-
{{&machine_hard_spi_type}, &spi_obj[3]},
39-
{{&machine_hard_spi_type}, &spi_obj[4]},
40-
{{&machine_hard_spi_type}, &spi_obj[5]},
35+
{{&machine_spi_type}, &spi_obj[0]},
36+
{{&machine_spi_type}, &spi_obj[1]},
37+
{{&machine_spi_type}, &spi_obj[2]},
38+
{{&machine_spi_type}, &spi_obj[3]},
39+
{{&machine_spi_type}, &spi_obj[4]},
40+
{{&machine_spi_type}, &spi_obj[5]},
4141
};
4242

4343
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 = {
136136
};
137137

138138
MP_DEFINE_CONST_OBJ_TYPE(
139-
machine_hard_spi_type,
139+
machine_spi_type,
140140
MP_QSTR_SPI,
141141
MP_TYPE_FLAG_NONE,
142142
make_new, machine_hard_spi_make_new,

ports/stm32/modmachine.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,14 +424,14 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
424424
{ MP_ROM_QSTR(MP_QSTR_ADC), MP_ROM_PTR(&machine_adc_type) },
425425
#if MICROPY_PY_MACHINE_I2C
426426
#if MICROPY_HW_ENABLE_HW_I2C
427-
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&machine_hard_i2c_type) },
427+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&machine_i2c_type) },
428428
#else
429429
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&mp_machine_soft_i2c_type) },
430430
#endif
431431
{ MP_ROM_QSTR(MP_QSTR_SoftI2C), MP_ROM_PTR(&mp_machine_soft_i2c_type) },
432432
#endif
433433
#if MICROPY_PY_MACHINE_SPI
434-
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&machine_hard_spi_type) },
434+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&machine_spi_type) },
435435
{ MP_ROM_QSTR(MP_QSTR_SoftSPI), MP_ROM_PTR(&mp_machine_soft_spi_type) },
436436
#endif
437437
#if MICROPY_HW_ENABLE_I2S

ports/stm32/modmachine.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@
3030

3131
extern const mp_obj_type_t machine_adc_type;
3232
extern const mp_obj_type_t machine_timer_type;
33-
extern const mp_obj_type_t machine_hard_i2c_type;
33+
extern const mp_obj_type_t machine_i2c_type;
3434
extern const mp_obj_type_t machine_i2s_type;
35+
extern const mp_obj_type_t machine_spi_type;
36+
extern const mp_obj_type_t machine_timer_type;
3537

3638
void machine_init(void);
3739
void machine_deinit(void);

ports/stm32/spi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ const spi_t *spi_from_mp_obj(mp_obj_t o) {
678678
if (mp_obj_is_type(o, &pyb_spi_type)) {
679679
pyb_spi_obj_t *self = MP_OBJ_TO_PTR(o);
680680
return self->spi;
681-
} else if (mp_obj_is_type(o, &machine_hard_spi_type)) {
681+
} else if (mp_obj_is_type(o, &machine_spi_type)) {
682682
machine_hard_spi_obj_t *self = MP_OBJ_TO_PTR(o);
683683
return self->spi;
684684
} else {
@@ -687,7 +687,7 @@ const spi_t *spi_from_mp_obj(mp_obj_t o) {
687687
}
688688

689689
mp_obj_base_t *mp_hal_get_spi_obj(mp_obj_t o) {
690-
if (mp_obj_is_type(o, &machine_hard_spi_type)) {
690+
if (mp_obj_is_type(o, &machine_spi_type)) {
691691
return MP_OBJ_TO_PTR(o);
692692
}
693693
#if MICROPY_PY_MACHINE_SOFTSPI

ports/stm32/spi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ extern const spi_t spi_obj[6];
6565

6666
extern const mp_spi_proto_t spi_proto;
6767
extern const mp_obj_type_t pyb_spi_type;
68-
extern const mp_obj_type_t machine_hard_spi_type;
68+
extern const mp_obj_type_t machine_spi_type;
6969

7070
// A transfer of "len" bytes should take len*8*1000/baudrate milliseconds.
7171
// To simplify the calculation we assume the baudrate is never less than 8kHz

0 commit comments

Comments
 (0)