Skip to content

Commit 82d1898

Browse files
committed
set up pio audio parameters
1 parent b1381a0 commit 82d1898

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

ports/raspberrypi/bindings/rp2pio/StateMachine.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(rp2pio_statemachine_write_obj, 2, rp2pio_statemachine
506506
//| Then the ``once`` and/or ``loop`` buffers are queued. and the function returns.
507507
//| The ``once`` buffer (if specified) will be written just once.
508508
//| Finally, the ``loop`` and/or ``loop2`` buffer (if specified) will continue being looped indefinitely. If both ``loop`` and ``loop2`` are specified, they will alternate.
509-
//|
509+
//|
510510
//| Writes to the FIFO will match the input buffer's element size. For example, bytearray elements
511511
//| will perform 8 bit writes to the PIO FIFO. The RP2040's memory bus will duplicate the value into
512512
//| the other byte positions. So, pulling more data in the PIO assembly will read the duplicated values.
@@ -1181,6 +1181,8 @@ static const mp_rom_map_elem_t rp2pio_statemachine_locals_dict_table[] = {
11811181
{ MP_ROM_QSTR(MP_QSTR_last_read), MP_ROM_PTR(&rp2pio_statemachine_last_read_obj) },
11821182
{ MP_ROM_QSTR(MP_QSTR_last_write), MP_ROM_PTR(&rp2pio_statemachine_last_write_obj) },
11831183

1184+
{ MP_ROM_QSTR(MP_QSTR_write_audio), MP_ROM_PTR(&rp2pio_statemachine_write_audio_obj) },
1185+
{ MP_ROM_QSTR(MP_QSTR_read_audio), MP_ROM_PTR(&rp2pio_statemachine_read_audio_obj) },
11841186
};
11851187
static MP_DEFINE_CONST_DICT(rp2pio_statemachine_locals_dict, rp2pio_statemachine_locals_dict_table);
11861188

ports/raspberrypi/bindings/rp2pio/StateMachine.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ bool common_hal_rp2pio_statemachine_write_readinto(rp2pio_statemachine_obj_t *se
7575
uint32_t common_hal_rp2pio_statemachine_get_frequency(rp2pio_statemachine_obj_t *self);
7676
void common_hal_rp2pio_statemachine_set_frequency(rp2pio_statemachine_obj_t *self, uint32_t frequency);
7777

78+
mp_obj_t common_hal_rp2pio_statemachine_get_write_audio(rp2pio_statemachine_obj_t *self);
79+
void common_hal_rp2pio_statemachine_set_write_audio(rp2pio_statemachine_obj_t *self, mp_obj_t write_audio);
80+
81+
mp_obj_t common_hal_rp2pio_statemachine_get_read_audio(rp2pio_statemachine_obj_t *self);
82+
void common_hal_rp2pio_statemachine_set_read_audio(rp2pio_statemachine_obj_t *self, mp_obj_t read_audio);
83+
7884
bool common_hal_rp2pio_statemachine_get_rxstall(rp2pio_statemachine_obj_t *self);
7985
void common_hal_rp2pio_statemachine_clear_rxfifo(rp2pio_statemachine_obj_t *self);
8086

ports/raspberrypi/common-hal/rp2pio/StateMachine.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,9 @@ bool rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self,
449449

450450
sm_config_set_fifo_join(&c, join);
451451

452+
self->read_audio = mp_const_none;
453+
self->write_audio = mp_const_none;
454+
452455
// TODO: these arguments
453456
// int mov_status_type, int mov_status_n,
454457
// int set_count, int out_count
@@ -754,6 +757,22 @@ void common_hal_rp2pio_statemachine_set_frequency(rp2pio_statemachine_obj_t *sel
754757
pio_sm_clkdiv_restart(self->pio, self->state_machine);
755758
}
756759

760+
mp_obj_t common_hal_rp2pio_statemachine_get_write_audio(rp2pio_statemachine_obj_t *self) {
761+
return self->write_audio;
762+
}
763+
764+
void common_hal_rp2pio_statemachine_set_write_audio(rp2pio_statemachine_obj_t *self, mp_obj_t write_audio) {
765+
self->write_audio = write_audio;
766+
}
767+
768+
mp_obj_t common_hal_rp2pio_statemachine_get_read_audio(rp2pio_statemachine_obj_t *self) {
769+
return self->read_audio;
770+
}
771+
772+
void common_hal_rp2pio_statemachine_set_read_audio(rp2pio_statemachine_obj_t *self, mp_obj_t read_audio) {
773+
self->read_audio = read_audio;
774+
}
775+
757776
void rp2pio_statemachine_reset_ok(PIO pio, int sm) {
758777
uint8_t pio_index = pio_get_index(pio);
759778
_never_reset[pio_index][sm] = false;

ports/raspberrypi/common-hal/rp2pio/StateMachine.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ typedef struct {
6060
sm_buf_info once_write_buf_info, loop_write_buf_info, loop2_write_buf_info;
6161
sm_buf_info current_write_buf, next_write_buf_1, next_write_buf_2, next_write_buf_3;
6262

63+
mp_obj_t write_audio, read_audio;
64+
6365
bool switched_write_buffers, switched_read_buffers;
6466

6567
int background_stride_in_bytes;

0 commit comments

Comments
 (0)