Skip to content

Commit 4a4ad88

Browse files
committed
reworks the spi module
1 parent ed0d5eb commit 4a4ad88

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

ext_mod/esp32_additions/spi/src/esp32_spi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "esp_heap_caps.h"
1515

1616

17-
STATIC mp_obj_t esp32_hw_spi_get_dma_buffer(mp_obj_t size_in)
17+
mp_obj_t esp32_hw_spi_get_dma_buffer(mp_obj_t size_in)
1818
{
1919
uint16_t size = (uint16_t)mp_obj_get_int_truncated(size_in);
2020

@@ -37,7 +37,7 @@ STATIC mp_obj_t esp32_hw_spi_get_dma_buffer(mp_obj_t size_in)
3737
MP_DEFINE_CONST_FUN_OBJ_1(esp32_hw_spi_get_dma_buffer_obj, esp32_hw_spi_get_dma_buffer);
3838

3939

40-
STATIC mp_obj_t esp32_hw_spi_free_dma_buffer(mp_obj_t buf_in)
40+
mp_obj_t esp32_hw_spi_free_dma_buffer(mp_obj_t buf_in)
4141
{
4242
mp_buffer_info_t bufinfo;
4343
mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_RW);
@@ -54,7 +54,7 @@ STATIC const mp_map_elem_t esp32_module_spi_globals_table[] = {
5454
{ MP_ROM_QSTR(MP_QSTR_Bus), (mp_obj_t)&esp32_hw_spi_bus_type },
5555
{ MP_ROM_QSTR(MP_QSTR_Device), (mp_obj_t)&esp32_hw_spi_dev_type },
5656
{ MP_ROM_QSTR(MP_QSTR_get_dma_buffer), MP_ROM_PTR(&esp32_hw_spi_get_dma_buffer_obj) },
57-
{ MP_ROM_QSTR(MP_QSTR_free_dma_buffer), MP_ROM_PTR(&esp32_hw_spi_free_dma_buffer_obj) }
57+
{ MP_ROM_QSTR(MP_QSTR_free_dma_buffer), MP_ROM_PTR(&esp32_hw_spi_free_dma_buffer_obj) },
5858
};
5959

6060
STATIC MP_DEFINE_CONST_DICT(esp32_module_spi_globals, esp32_module_spi_globals_table);

ext_mod/esp32_additions/spi/src/esp32_spi_device.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static void _esp32_pre_cb(spi_transaction_t *trans)
7575

7676
static void _esp32_post_cb(spi_transaction_t *spi_trans)
7777
{
78-
esp32_hw_spi_dev_obj_t *self = (esp32_hw_spi_dev_obj_t *)trans->user;
78+
esp32_hw_spi_dev_obj_t *self = (esp32_hw_spi_dev_obj_t *)spi_trans->user;
7979

8080
spi_transaction_ext_t *spi_trans_ext = __containerof(spi_trans, spi_transaction_ext_t, base);
8181
esp32_spi_trans_descriptor_t *spi_trans_desc = __containerof(spi_trans_ext, esp32_spi_trans_descriptor_t, base);
@@ -257,7 +257,7 @@ mp_obj_t esp32_hw_spi_dev_comm(size_t n_args, const mp_obj_t *pos_args, mp_map_t
257257
uint8_t addr_bits;
258258

259259
if (args[ARG_addr].u_obj != mp_const_none && args[ARG_addr_bits].u_obj != mp_const_none) {
260-
addr = mp_obj_get_int_truncated(args[ARG_param].u_obj);
260+
addr = mp_obj_get_int_truncated(args[ARG_addr].u_obj);
261261
addr_bits = mp_obj_get_int_truncated(args[ARG_addr_bits].u_obj);
262262
} else {
263263
addr = 0;
@@ -285,7 +285,7 @@ mp_obj_t esp32_hw_spi_dev_comm(size_t n_args, const mp_obj_t *pos_args, mp_map_t
285285
tx_buf = (uint8_t *)tx_bufinfo.buf;
286286
}
287287

288-
size_t rx_size = 0
288+
size_t rx_size = 0;
289289
uint8_t *rx_buf = NULL;
290290

291291
if (args[ARG_rx_data].u_obj != mp_const_none) {
@@ -379,10 +379,10 @@ mp_obj_t esp32_hw_spi_dev_comm(size_t n_args, const mp_obj_t *pos_args, mp_map_t
379379
addr_bits = 0;
380380
}
381381

382-
spi_trans_desc.callback = args[ARG_callback].u_obj;
382+
spi_trans_desc->callback = args[ARG_callback].u_obj;
383383

384384
// data is usually large, using queue+blocking mode
385-
ret = spi_device_queue_trans(self->spi_dev, &spi_trans_desc->base, portMAX_DELAY);
385+
ret = spi_device_queue_trans(self->spi_dev, &spi_trans_desc->base.base, portMAX_DELAY);
386386
check_esp_err(ret);
387387
self->num_trans_inflight++;
388388

@@ -402,7 +402,7 @@ mp_obj_t esp32_hw_spi_dev_comm(size_t n_args, const mp_obj_t *pos_args, mp_map_t
402402
return mp_const_none;
403403
}
404404

405-
MP_DEFINE_CONST_FUN_OBJ_KW(esp32_hw_spi_dev_comm_obj, 3, esp32_hw_spi_dev_comm);
405+
MP_DEFINE_CONST_FUN_OBJ_KW(esp32_hw_spi_dev_comm_obj, 1, esp32_hw_spi_dev_comm);
406406

407407

408408
STATIC mp_obj_t esp32_hw_spi_dev_del(mp_obj_t self_in)

0 commit comments

Comments
 (0)