diff options
m--------- | laks | 0 | ||||
-rw-r--r-- | main.cpp | 18 |
2 files changed, 17 insertions, 1 deletions
diff --git a/laks b/laks -Subproject 0ca572bc7a0fbe26b216cab519d89187ae49a28 +Subproject eaf304f02a234171c2b994138f1bc54338dcd97 @@ -5,6 +5,12 @@ #include <usb/descriptor.h> #include <spi/spi.h> #include <dma/dma.h> +#include <i2c/i2c.h> + +Pin& dac_nreset = PD4; + +Pin& i2c_scl = PB6; +Pin& i2c_sda = PB9; Pin& i2s_mck = PC7; Pin& i2s_sck = PC10; @@ -130,7 +136,7 @@ class USB_Audio : public USB_class_driver { virtual void handle_set_configuration(uint8_t configuration) { if(configuration) { usb.register_out_handler(this, 1); - usb.hw_conf_ep(0x01, Isochronous, 256); + usb.hw_conf_ep(0x01, EPType::Isochronous, 256); } } @@ -166,6 +172,7 @@ int main() { RCC.enable(RCC.GPIOA); RCC.enable(RCC.GPIOB); RCC.enable(RCC.GPIOC); + RCC.enable(RCC.GPIOD); // Initialize I2S. i2s_mck.set_mode(Pin::AF); @@ -196,6 +203,15 @@ int main() { DMA1.reg.S[7].NDTR = audio_buf_size; DMA1.reg.S[7].CR |= 1; + // Initialize I2C. + I2C1.enable(i2c_scl, i2c_sda); + + // Configure CS43L22. + dac_nreset.set_mode(Pin::Output); + dac_nreset.on(); + + I2C1.write_reg(0x4a, 0x02, 0x9e); + // Initialize USB. usb_vbus.set_mode(Pin::Input); usb_dm.set_mode(Pin::AF); |