Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WM8731 Audio Codec #104

Closed
JoniDS opened this issue May 24, 2018 · 6 comments
Closed

WM8731 Audio Codec #104

JoniDS opened this issue May 24, 2018 · 6 comments

Comments

@JoniDS
Copy link

JoniDS commented May 24, 2018

Anyone knows what is required to make Android Things work with this board?
e.g https://www.mikroe.com/audio-codec-proto-board

Thank you

@Fleker
Copy link
Contributor

Fleker commented May 24, 2018

According to the user manual:

Data transfer between the microcontroller and additional board is performed via the Serial Peripheral Interface (SPI), whereas the operation of the board is controlled by the microcontroller via I2C communication

This link isn't the datasheet, so it doesn't seem to go into specific detail how this is accomplished. But you should be able to connect your Android Things board to this peripheral over I2C and then send commands to it. If you want to transfer data, you can also connect an SPI line and read/write data.

@JoniDS
Copy link
Author

JoniDS commented May 25, 2018

@Fleker I can see the device as an SPI interface and set it up as an audio device output.
However I can't turn the DAC on.
From their spec docs this is how it should be done -> https://www.rockbox.org/wiki/pub/Main/DataSheets/WM8731_8731L.pdf (page 42)
Yet I don't really understand how I can do this from https://developer.android.com/things/sdk/pio/i2c

@Fleker
Copy link
Contributor

Fleker commented May 25, 2018

So if 15:9 are the addresses, and you have 9 bits (8:0) of data, you'll need to use the generic write method. So you may want to start with something like this:

byte byte1 = i2cAddress << 1; // Need to shift address 1 to the left
byte byte2 = data && 0xFF; // Need to mask so only first 8 bits are used
byte1 |= (data >> 8) && 0xFF; // Need to shift and mask so you can get the 9th bit
i2cDevice.write([byte1, byte2], 2);

@JoniDS
Copy link
Author

JoniDS commented May 26, 2018

So, if I want to avoid manipulating bits I could do something like this?

device.write(byteArrayOf(0x12, 0x1), 2) // R9 (12h)
doc_save

@Fleker
Copy link
Contributor

Fleker commented May 29, 2018

I'm not sure if that will work, as sending [0x12, 0x01] wouldn't correspond to register 0x12. Bits 15 - 8 must be your first byte, and bits 7 - 0 must be your second byte.

@JoniDS
Copy link
Author

JoniDS commented May 31, 2018

It does work. Turns out my problem was that the board was not powering the DAC.
The register 0x12 accounts for the first 8 bits (not 7), so it's 0001 0010 which is correct.
Thanks for your help.

@JoniDS JoniDS closed this as completed May 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants