Skip to content

Commit

Permalink
ports/psoc6/machine_i2s.c: WIP for rx prepare.
Browse files Browse the repository at this point in the history
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
  • Loading branch information
jaenrig-ifx committed Apr 17, 2024
1 parent 0b7c335 commit 350ed86
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions ports/psoc6/machine_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,18 @@ static inline void i2s_dma_tx(machine_i2s_obj_t *self) {
i2s_assert_raise_val("I2S DMA write configure failed with return code %lx !", result);
}

static inline void toggle_led() {
static uint32_t a = 0;
if (a++ % sizeof(uint64_t) == 0) {
cyhal_gpio_toggle(CYBSP_USER_LED);
}
}
// static inline void toggle_led() {
// static uint32_t a = 0;
// if (a++ % sizeof(uint64_t) == 0) {
// cyhal_gpio_toggle(CYBSP_USER_LED);
// }
// }

static void i2s_dma_from_dmabuf_to_ringbuf(machine_i2s_obj_t *self) {
uint8_t dma_sample_size_in_bytes = (self->bits == 16? 2 : 4) * (self->format == STEREO ? 2: 1);
uint8_t *dma_buff_p = (uint8_t *)self->dma_idle_buf_p;
uint32_t num_bytes_needed_from_ringbuf = SIZEOF_HALF_DMA_BUFFER_IN_BYTES * (I2S_RX_FRAME_SIZE_IN_BYTES / dma_sample_size_in_bytes);
toggle_led();
// toggle_led();

// when space exists, copy samples into ring buffer
if (ringbuf_available_space(&self->ring_buffer) >= num_bytes_needed_from_ringbuf) {
Expand Down Expand Up @@ -440,8 +440,8 @@ static void mp_machine_i2s_init_helper(machine_i2s_obj_t *self, mp_arg_val_t *ar
self->io_mode = BLOCKING;


cyhal_gpio_init(CYBSP_USER_LED, CYHAL_GPIO_DIR_OUTPUT,
CYHAL_GPIO_DRIVE_STRONG, CYBSP_LED_STATE_OFF);
// cyhal_gpio_init(CYBSP_USER_LED, CYHAL_GPIO_DIR_OUTPUT,
// CYHAL_GPIO_DRIVE_STRONG, CYBSP_LED_STATE_OFF);

i2s_audio_clock_init(audio_clock_freq_hz);
i2s_init(self, &audio_clock);
Expand Down

0 comments on commit 350ed86

Please sign in to comment.