Skip to content

Commit 9afddf8

Browse files
committed
some coding correction in the spi module
1 parent 1c6f970 commit 9afddf8

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

ext_mod/esp32_additions/spi/src/esp32_spi.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ mp_obj_t esp32_hw_spi_dev_make_new(const mp_obj_type_t *type, size_t n_args, siz
191191
return MP_OBJ_FROM_PTR(self);
192192
}
193193

194-
195194
mp_obj_t esp32_hw_spi_dev_trans_start_cb(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)
196195
{
197196
enum { ARG_self, ARG_callback, ARG_user_data };
@@ -1015,16 +1014,18 @@ mp_obj_t esp32_hw_spi_bus_make_new(const mp_obj_type_t *type, size_t n_args, siz
10151014
}
10161015

10171016

1017+
STATIC void machine_hw_spi_deinit_internal(machine_hw_spi_obj_t *self) {
1018+
1019+
1020+
10181021
STATIC mp_obj_t esp32_hw_spi_bus_deinit(mp_obj_t self_in)
10191022
{
10201023
esp32_hw_spi_bus_obj_t *self = (esp32_hw_spi_bus_obj_t *)self_in;
10211024

1022-
esp_err_t ret = spi_bus_free(self->host);
1023-
check_esp_err(ret);
1024-
10251025
if (self->state == MACHINE_HW_SPI_STATE_INIT) {
10261026
self->state = MACHINE_HW_SPI_STATE_DEINIT;
1027-
machine_hw_spi_deinit_internal(self);
1027+
esp_err_t ret = spi_bus_free(self->host);
1028+
check_esp_err(ret);
10281029
}
10291030

10301031
return mp_const_none;
@@ -1097,10 +1098,10 @@ MP_DEFINE_CONST_FUN_OBJ_1(esp32_hw_spi_free_dma_buffer_obj, esp32_hw_spi_free_dm
10971098

10981099
STATIC const mp_map_elem_t esp32_module_spi_globals_table[] = {
10991100
{ MP_ROM_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_spi) },
1100-
{ MP_ROM_QSTR(MP_QSTR_Bus) (mp_obj_t)&esp32_hw_spi_bus_type },
1101+
{ MP_ROM_QSTR(MP_QSTR_Bus), (mp_obj_t)&esp32_hw_spi_bus_type },
11011102
{ MP_ROM_QSTR(MP_QSTR_Device), (mp_obj_t)&esp32_hw_spi_dev_type },
11021103
{ MP_ROM_QSTR(MP_QSTR_get_dma_buffer), MP_ROM_PTR(&esp32_hw_spi_get_dma_buffer_obj) },
1103-
{ MP_ROM_QSTR(MP_QSTR_free_dma_buffer), MP_ROM_PTR(&esp32_hw_spi_free_dma_buffer_obj) },
1104+
{ MP_ROM_QSTR(MP_QSTR_free_dma_buffer), MP_ROM_PTR(&esp32_hw_spi_free_dma_buffer_obj) }
11041105
};
11051106

11061107
STATIC MP_DEFINE_CONST_DICT(esp32_module_spi_globals, esp32_module_spi_globals_table);

0 commit comments

Comments
 (0)