Skip to content

Commit ebc426d

Browse files
committed
Remove debug prints, improve docs
1 parent b128f18 commit ebc426d

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

ports/raspberrypi/bindings/rp2pio/StateMachine.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,19 +426,20 @@ STATIC mp_obj_t rp2pio_statemachine_write(size_t n_args, const mp_obj_t *pos_arg
426426
}
427427
MP_DEFINE_CONST_FUN_OBJ_KW(rp2pio_statemachine_write_obj, 2, rp2pio_statemachine_write);
428428

429-
//| def continuous_write(self, buffer: Optional[ReadableBuffer], *, start: int = 0, end: Optional[int] = None) -> None:
429+
//| def start_continuous_write(self, buffer: Optional[ReadableBuffer], *, start: int = 0, end: Optional[int] = None) -> None:
430430
//| """Write the data contained in ``buffer`` to the state machine repeatedly until stopped. If the buffer is empty or None, an existing continuous_write is canceled.
431431
//|
432432
//| Writes to the FIFO will match the input buffer's element size. For example, bytearray elements
433433
//| will perform 8 bit writes to the PIO FIFO. The RP2040's memory bus will duplicate the value into
434434
//| the other byte positions. So, pulling more data in the PIO assembly will read the duplicated values.
435435
//|
436436
//| To perform 16 or 32 bits writes into the FIFO use an `array.array` with a type code of the desired
437-
//| size.
437+
//| size, or use `memoryview.cast` to change the interpretation of an existing buffer.
438438
//|
439439
//| To atomically change from one buffer to another, simply call
440-
//| `StateMachine.continuous_write` again with a different buffer.
441-
//| The call will only return once outputting the new buffer has started.
440+
//| `StateMachine.continuous_write` again with a different buffer with the same element size.
441+
//| The call will only return once DMA has started putting the previous
442+
//| buffer's data into the PIO FIFO.
442443
//|
443444
//| If the buffer is modified while it is being written out, the updated
444445
//| values will be used. However, because of interactions between CPU

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -877,14 +877,11 @@ uint8_t rp2pio_statemachine_program_offset(rp2pio_statemachine_obj_t *self) {
877877
return _current_program_offset[pio_index][sm];
878878
}
879879

880-
#define HERE(fmt, ...) (mp_printf(&mp_plat_print, "%s: %d: " fmt "\n", __FILE__, __LINE__,##__VA_ARGS__))
881-
882880
bool common_hal_rp2pio_statemachine_start_continuous_write(rp2pio_statemachine_obj_t *self, mp_obj_t buf_obj, const uint8_t *data, size_t len, uint8_t stride_in_bytes) {
883881
uint8_t pio_index = pio_get_index(self->pio);
884882
uint8_t sm = self->state_machine;
885883

886884
if (SM_DMA_ALLOCATED(pio_index, sm) && stride_in_bytes == self->continuous_stride_in_bytes) {
887-
HERE("updating channel pending=%d\n", self->pending_set_data);
888885
while (self->pending_set_data) {
889886
RUN_BACKGROUND_TASKS;
890887
if (self->user_interruptible && mp_hal_is_interrupted()) {
@@ -906,13 +903,10 @@ bool common_hal_rp2pio_statemachine_start_continuous_write(rp2pio_statemachine_o
906903

907904
common_hal_rp2pio_statemachine_end_continuous_write(self);
908905

909-
HERE("allocating dma channel");
910906
int channel = dma_claim_unused_channel(false);
911907
if (channel == -1) {
912-
HERE("allocating DMA channel failed");
913908
return false;
914909
}
915-
HERE("got channel %d", channel);
916910

917911
SM_DMA_SET_CHANNEL(pio_index, sm, channel);
918912

@@ -940,7 +934,6 @@ bool common_hal_rp2pio_statemachine_start_continuous_write(rp2pio_statemachine_o
940934
data,
941935
len / stride_in_bytes,
942936
false);
943-
HERE("OK let's go");
944937

945938
common_hal_mcu_disable_interrupts();
946939
MP_STATE_PORT(continuous_pio)[channel] = self;
@@ -949,14 +942,10 @@ bool common_hal_rp2pio_statemachine_start_continuous_write(rp2pio_statemachine_o
949942
dma_start_channel_mask(1u << channel);
950943
common_hal_mcu_enable_interrupts();
951944

952-
HERE("mark");
953945
return true;
954946
}
955947

956948
void rp2pio_statemachine_dma_complete(rp2pio_statemachine_obj_t *self, int channel) {
957-
HERE("dma complete[%d] pending set data=%d %sbusy %d@%p", channel, self->pending_set_data, dma_channel_is_busy(channel) ? "not " : "",
958-
self->next_size, self->next_buffer);
959-
960949
dma_channel_set_read_addr(channel, self->next_buffer, false);
961950
dma_channel_set_trans_count(channel, self->next_size, true);
962951

0 commit comments

Comments
 (0)