From f573d559a01ea322d3bfb9f618498fa0637a5f27 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sat, 22 Sep 2012 16:14:17 +0200 Subject: Enable I2C for configuring the DAC. --- laks | 2 +- main.cpp | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/laks b/laks index 0ca572b..eaf304f 160000 --- a/laks +++ b/laks @@ -1 +1 @@ -Subproject commit 0ca572bc7a0fbe26b216cab519d89187ae49a28b +Subproject commit eaf304f02a234171c2b994138f1bc54338dcd975 diff --git a/main.cpp b/main.cpp index 4b36241..c80a885 100644 --- a/main.cpp +++ b/main.cpp @@ -5,6 +5,12 @@ #include #include #include +#include + +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); -- cgit v1.2.3