mtthw-meyer / libdaisy-rust

Hardware Abstraction Layer implementation for Daisy boards
MIT License
51 stars 18 forks source link

Add support for Daisy Seed rev5 #29

Closed miselaytes-anton closed 2 years ago

miselaytes-anton commented 2 years ago

Context

Daisy Seed 1.1 uses a different audio codec (WM8731 instead of AK4556).

Notes

Unfortunately, I can not make it produce the sound when I run the passthru example. I suspect it might be because of the change below, but I am not sure how to change the direction in audio.rs.

sai_config.a_dir           = SaiHandle::Config::Direction::TRANSMIT;
sai_config.b_dir           = SaiHandle::Config::Direction::RECEIVE;

changing to:

sai_config.a_dir           = SaiHandle::Config::Direction::RECEIVE;
sai_config.b_dir           = SaiHandle::Config::Direction::TRANSMIT;

see here

mtthw-meyer commented 2 years ago

Did you get the sound working?

miselaytes-anton commented 2 years ago

@mtthw-meyer

Did you get the sound working?

Short answer is no.

Long answer is if I enable bypass from line in to line out then I hear audio. But if I disable bypass, then I do not. Based on that I assume that the codec is configured correctly.

I was also able to change SAI master direction from transmit to receive and it no longer hangs. So looks like SAI is also working:

22:31:09.825 INFO - Starting system init 
22:31:10.010 INFO - Setting up GPIOs...
22:31:10.010 INFO - Setting up SDRAM...
22:31:10.010 INFO - SDRAM Memory Size 0x19
22:31:10.010 INFO - Setup up Audio...
22:31:10.010 INFO - Setup up DMA...
22:31:10.010 INFO - Memory Size 0xe
22:31:10.010 INFO - Setup up SAI...
22:31:10.010 INFO - Sai1 fifo waiting to receive data.
22:31:10.010 INFO - Audio started!
22:31:10.010 INFO - Setup WM8731 audio codec...
22:31:10.058 INFO - 0x30000300, 0x30000000
22:31:10.058 INFO - System init done!
22:31:10.058 INFO - Startup done!

So my remaining suspect is DMA config. I checked SAI register values and I see that I get overrun error on SAI_ADR register, so looks like audio data arrives from codec but is not picked up by DMA. I also see underrun error on SAI_BDR register, so DMA never transmits data there.

Screenshot 2022-02-18 at 22 42 17
miselaytes-anton commented 2 years ago

I can not make this work unfortunately.