Skip to content

Commit 1171e0d

Browse files
committed
fixup: F407-DISCO I2S support
1 parent e6fdd7b commit 1171e0d

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/modm/board/disco_f407vg/board.hpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <modm/platform.hpp>
1919
#include <modm/architecture/interface/clock.hpp>
2020
#include <modm/driver/inertial/lis3dsh.hpp>
21+
#include <modm/math/units.hpp>
2122

2223
using namespace modm::platform;
2324

@@ -154,12 +155,16 @@ using Mclk = GpioOutputC7; // I2S3_MCK
154155
using Sclk = GpioOutputC10; // I2S3_SCK
155156
using Sdin = GpioOutputC12; // I2S3_SD
156157

158+
using DmaTx = Dma1::Channel5;
159+
157160
using Reset = GpioOutputD4; // Audio_RST
158161
using Scl = GpioB6; // Audio_SCL
159162
using Sda = GpioB9; // Audio_SDA
160163

161164
using I2cMaster = I2cMaster1;
162-
using I2sMaster = I2sMaster3;
165+
using I2sMaster = I2sMaster3<DmaTx>;
166+
167+
static constexpr uint8_t I2CAddress = 0x4a; // (0x94 >> 1)
163168
/// @}
164169
}
165170

@@ -215,13 +220,13 @@ initializeLis3()
215220
lis3::SpiMaster::setDataMode(lis3::SpiMaster::DataMode::Mode3);
216221
}
217222

218-
/// not supported yet, due to missing I2S driver
223+
template< modm::frequency_t samplerate=48_kHz, modm::percent_t tolerance=modm::pct(0.019) >
219224
inline void
220225
initializeCs43()
221226
{
222227
cs43::I2sMaster::connect<cs43::Mclk::Mck, cs43::Sclk::Ck,
223228
cs43::Lrck::Ws, cs43::Sdin::Sd>();
224-
cs43::I2sMaster::initialize<SystemClock, 48_kHz>();
229+
cs43::I2sMaster::initialize<SystemClock, samplerate, tolerance>();
225230
cs43::Reset::setOutput(modm::Gpio::High);
226231

227232
cs43::I2cMaster::connect<cs43::Scl::Scl, cs43::Sda::Sda>();
@@ -230,7 +235,7 @@ initializeCs43()
230235
cs43::Reset::setOutput(modm::Gpio::Low);
231236
modm::delay_ms(2);
232237
cs43::Reset::setOutput(modm::Gpio::High);
233-
238+
234239
}
235240

236241
/// not supported yet, due to missing I2S driver

src/modm/board/disco_f407vg/module.lb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ def prepare(module, options):
2626
module.depends(
2727
":architecture:clock",
2828
":driver:lis3dsh",
29+
":driver:cs43l22",
2930
":platform:clock",
3031
":platform:core",
32+
":platform:dma",
3133
":platform:gpio",
3234
":platform:i2c:1",
3335
":platform:spi:1",

0 commit comments

Comments
 (0)