Skip to content

Commit 74683ed

Browse files
committed
ports/rp2: DMA support for Pi Pico.
1 parent 42d1a16 commit 74683ed

File tree

6 files changed

+594
-0
lines changed

6 files changed

+594
-0
lines changed

ports/rp2/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ set(MICROPY_SOURCE_PORT
100100
mpthreadport.c
101101
rp2_flash.c
102102
rp2_pio.c
103+
rp2_dma.c
103104
tusb_port.c
104105
uart.c
105106
)
@@ -125,6 +126,7 @@ set(MICROPY_SOURCE_QSTR
125126
${PROJECT_SOURCE_DIR}/modutime.c
126127
${PROJECT_SOURCE_DIR}/rp2_flash.c
127128
${PROJECT_SOURCE_DIR}/rp2_pio.c
129+
${PROJECT_SOURCE_DIR}/rp2_dma.c
128130
)
129131

130132
set(PICO_SDK_COMPONENTS

ports/rp2/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ int main(int argc, char **argv) {
106106
readline_init0();
107107
machine_pin_init();
108108
rp2_pio_init();
109+
rp2_dma_init();
109110

110111
// Execute _boot.py to set up the filesystem.
111112
pyexec_frozen_module("_boot.py");
@@ -136,6 +137,7 @@ int main(int argc, char **argv) {
136137

137138
soft_reset_exit:
138139
mp_printf(MP_PYTHON_PRINTER, "MPY: soft reboot\n");
140+
rp2_dma_deinit();
139141
rp2_pio_deinit();
140142
machine_pin_deinit();
141143
#if MICROPY_PY_THREAD

ports/rp2/modrp2.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ STATIC const mp_rom_map_elem_t rp2_module_globals_table[] = {
3232
{ MP_ROM_QSTR(MP_QSTR_Flash), MP_ROM_PTR(&rp2_flash_type) },
3333
{ MP_ROM_QSTR(MP_QSTR_PIO), MP_ROM_PTR(&rp2_pio_type) },
3434
{ MP_ROM_QSTR(MP_QSTR_StateMachine), MP_ROM_PTR(&rp2_state_machine_type) },
35+
{ MP_ROM_QSTR(MP_QSTR_DMA), MP_ROM_PTR(&rp2_dma_type) },
36+
{ MP_ROM_QSTR(MP_QSTR_DMAConfig), MP_ROM_PTR(&rp2_dma_config_type) },
37+
{ MP_ROM_QSTR(MP_QSTR_buffer_address), MP_ROM_PTR(&rp2_dma_buffer_address_obj) },
3538
};
3639
STATIC MP_DEFINE_CONST_DICT(rp2_module_globals, rp2_module_globals_table);
3740

ports/rp2/modrp2.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,16 @@
3131
extern const mp_obj_type_t rp2_flash_type;
3232
extern const mp_obj_type_t rp2_pio_type;
3333
extern const mp_obj_type_t rp2_state_machine_type;
34+
extern const mp_obj_type_t rp2_dma_type;
35+
extern const mp_obj_type_t rp2_dma_config_type;
36+
37+
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(rp2_dma_buffer_address_obj);
38+
3439

3540
void rp2_pio_init(void);
3641
void rp2_pio_deinit(void);
3742

43+
void rp2_dma_init(void);
44+
void rp2_dma_deinit(void);
45+
3846
#endif // MICROPY_INCLUDED_RP2_MODRP2_H

ports/rp2/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ extern const struct _mp_obj_module_t mp_module_utime;
177177
void *rp2_state_machine_irq_obj[8]; \
178178
void *rp2_uart_rx_buffer[2]; \
179179
void *rp2_uart_tx_buffer[2]; \
180+
void *rp2_dma_irq_obj[NUM_DMA_CHANNELS]; \
180181

181182
#define MP_STATE_PORT MP_STATE_VM
182183

0 commit comments

Comments
 (0)