Skip to content

Commit 92344a8

Browse files
committed
working on being able to share the SPI Bus
1 parent 8ad00bb commit 92344a8

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

micropy_updates/rp2/machine_spi.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,19 @@ typedef struct _machine_hw_spi_obj_t {
125125
126126
*/
127127

128-
static machine_hw_spi_bus_obj_t machine_spi_bus_obj[] = {
128+
machine_hw_spi_bus_obj_t rp2_machine_spi_bus_obj[] = {
129129
{
130130
0,
131-
(const mp_obj_t)mp_obj_new_int_from_uint(MICROPY_HW_SPI0_SCK),
132-
(const mp_obj_t)mp_obj_new_int_from_uint(MICROPY_HW_SPI0_MOSI),
133-
(const mp_obj_t)mp_obj_new_int_from_uint(MICROPY_HW_SPI0_MISO),
131+
mp_obj_new_int_from_uint(MICROPY_HW_SPI0_SCK),
132+
mp_obj_new_int_from_uint(MICROPY_HW_SPI0_MOSI),
133+
mp_obj_new_int_from_uint(MICROPY_HW_SPI0_MISO),
134134
0, 0, (const void *)spi0
135135
},
136136
{
137137
1,
138-
(const mp_obj_t)mp_obj_new_int_from_uint(MICROPY_HW_SPI1_SCK),
139-
(const mp_obj_t)mp_obj_new_int_from_uint(MICROPY_HW_SPI1_MOSI),
140-
(const mp_obj_t)mp_obj_new_int_from_uint(MICROPY_HW_SPI1_MISO),
138+
mp_obj_new_int_from_uint(MICROPY_HW_SPI1_SCK),
139+
mp_obj_new_int_from_uint(MICROPY_HW_SPI1_MOSI),
140+
mp_obj_new_int_from_uint(MICROPY_HW_SPI1_MISO),
141141
0, 0, (const void *)spi1
142142
},
143143
};
@@ -164,14 +164,14 @@ mp_obj_t machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
164164

165165
// Get the SPI bus id.
166166
int spi_id = mp_obj_get_int(args[ARG_id].u_obj);
167-
if (spi_id < 0 || spi_id >= MP_ARRAY_SIZE(machine_spi_bus_obj)) {
167+
if (spi_id < 0 || spi_id >= MP_ARRAY_SIZE(rp2_machine_spi_bus_obj)) {
168168
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("SPI(%d) doesn't exist"), spi_id);
169169
}
170170

171171
machine_hw_spi_obj_t *self = m_new_obj(machine_hw_spi_obj_t);
172172
self->base.type = &machine_spi_type;
173173

174-
self->spi_bus = (machine_hw_spi_bus_obj_t *)&machine_spi_bus_obj[spi_id];
174+
self->spi_bus = (machine_hw_spi_bus_obj_t *)&rp2_machine_spi_bus_obj[spi_id];
175175

176176
self->baudrate = (uint32_t)args[ARG_baudrate].u_int;
177177
self->bits = (uint8_t)args[ARG_bits].u_int;

0 commit comments

Comments
 (0)