Skip to content

Commit 7ab6c7d

Browse files
committed
[I2S[ Reorganize code
Remove not used parameter from I2S PLL initializer function. Reorganize I2S DAC initializaiton to fit in the already existing code structure.
1 parent 6f8fc64 commit 7ab6c7d

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

src/modm/board/disco_f407vg/board.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct SystemClock {
9292
.pllN = 258, // 1 MHz * N=258 -> 258 MHz
9393
.pllR = 3 // 258 MHz / R=3 -> 86 MHz
9494
};
95-
Rcc::enablePllI2s(Rcc::PllSource::ExternalCrystal, pllI2sFactors, 2048);
95+
Rcc::enablePllI2s(pllI2sFactors, 2048);
9696
// set flash latency for 168MHz
9797
Rcc::setFlashLatency<Frequency>();
9898
// switch system clock to PLL output
@@ -148,7 +148,7 @@ using Scl = GpioB6; // Audio_SCL
148148
using Sda = GpioB9; // Audio_SDA
149149

150150
using I2cMaster = I2cMaster1;
151-
//using I2sMaster = I2sMaster3;
151+
using I2sMaster = I2sMaster3;
152152
}
153153

154154

@@ -207,10 +207,8 @@ initializeLis3()
207207
inline void
208208
initializeCs43()
209209
{
210-
// cs43::Lrck::connect(cs43::I2sMaster::Ws);
211-
// cs43::Mclk::connect(cs43::I2sMaster::Mck);
212-
// cs43::Sclk::connect(cs43::I2sMaster::Ck);
213-
// cs43::Sdin::connect(cs43::I2sMaster::Sd);
210+
cs43::I2sMaster::connect<cs43::Mclk::Mck, cs43::Sclk::Ck,
211+
cs43::Lrck::Ws, cs43::Sdin::Sd>();
214212

215213
cs43::Reset::setOutput(modm::Gpio::High);
216214

src/modm/platform/clock/stm32/rcc.cpp.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ modm::platform::Rcc::enablePll(PllSource source, const PllFactors& pllFactors, u
292292

293293
%% if target["family"] == "f4"
294294
bool
295-
modm::platform::Rcc::enablePllI2s(PllSource, const PllI2sFactors& pllFactors, uint32_t waitCycles)
295+
modm::platform::Rcc::enablePllI2s(const PllI2sFactors& pllFactors, uint32_t waitCycles)
296296
{
297297
// Read reserved and don't care values and clear all other values
298298
uint32_t tmp = RCC->PLLI2SCFGR & ~(RCC_PLLI2SCFGR_PLLI2SN | RCC_PLLI2SCFGR_PLLI2SR);

src/modm/platform/clock/stm32/rcc.hpp.in

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -561,18 +561,25 @@ public:
561561

562562
%% if target["family"] == "f4"
563563
/** TODO: comments
564+
* \code
564565
* input clock is the HSE or HSI divided by M
565566
* f(VCO clock) = f(PLLI2S clock input) × (PLLI2SN / PLLM)
566567
* f(PLL I2S clock output) = f(VCO clock) / PLLI2SR
568+
* \endcode
569+
*
567570
*
568571
* \param pllN
569-
* PLLI2S multiplication factor for VCO
570-
* 50 <= PLLI2SN <= 432
572+
* PLLI2S multiplication factor for VCO
573+
* Caution: The software has to set these bits correctly
574+
* to ensure that the VCO output frequency
575+
* is between 100 and 432 MHz.
576+
* 50 <= PLLI2SN <= 432
571577
*
572578
* \param pllR
573-
* PLLI2S division factor for I2S clocks
574-
* Caution: The I2Ss requires a frequency lower than or equal to 192 MHz to work correctly.
575-
* 2 <= PLLR <= 7
579+
* PLLI2S division factor for I2S clocks
580+
* Caution: The I2Ss requires a frequency lower than
581+
* or equal to 192 MHz to work correctly.
582+
* 2 <= PLLR <= 7
576583
*/
577584
struct PllI2sFactors
578585
{
@@ -582,7 +589,7 @@ public:
582589

583590
/* TODO: comments */
584591
static bool
585-
enablePllI2s(PllSource, const PllI2sFactors& pllFactors, uint32_t waitCycles);
592+
enablePllI2s(const PllI2sFactors& pllFactors, uint32_t waitCycles);
586593
%% endif
587594

588595
// sinks

0 commit comments

Comments
 (0)