| 25 | spi = busio.SPI(board.GP18, MOSI=board.GP19, MISO=board.GP16) |
| 26 | |
| 27 | class Codec: |
| 28 | CODEC_ADDR = 0x1A |
| 29 | |
| 30 | LeftLineInputChannelVolumeControl = 0 |
| 31 | RightLineInputChannelVolumeControl = 1 |
| 32 | LeftChannelHeadphoneVolumeControl = 2 |
| 33 | RightChannelHeadphoneVolumeControl = 3 |
| 34 | AnalogAudioPathControl = 4 |
| 35 | DigitalAudioPathControl = 5 |
| 36 | PowerDownControl = 6 |
| 37 | DigitalAudioInterfaceFormat = 7 |
| 38 | SampleRateControl = 8 |
| 39 | DigitalInterfaceActivation = 9 |
| 40 | Reset = 15 |
| 41 | |
| 42 | def __init__(self, i2c): |
| 43 | self.dev = I2CDevice(i2c, self.CODEC_ADDR) |
| 44 | |
| 45 | |
| 46 | def write(self, reg_addr, value): |
| 47 | with self.dev: |
| 48 | data = bytearray([(reg_addr << 1) | (value >> 8) & 1, value & 0xFF]) |
| 49 | self.dev.write(data) |
| 50 | |
| 51 | print("Configuring CODEC") |
| 52 | codec = Codec(i2c) |