Skip to content

Commit a4e9e19

Browse files
committed
Fix compile errors: untested
1 parent ca9c03c commit a4e9e19

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

examples/i2s-in/i2s-in.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void writeFromReceive(uint8_t *buffer, uint16_t byteCount, void*){
1313
void setup() {
1414
Serial.begin(115200);
1515
i2s_settings.sample_rate = I2S_AUDIOFREQ_8K;
16-
if (!I2s.beginReadDMA(i2s_settings, writeFromReceive){
16+
if (!I2S.beginReadDMA(i2s_settings, writeFromReceive)){
1717
Serial.println("I2S Error");
1818
}
1919
}

src/stm32-i2s.h

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ struct I2SPin {
8484
pwm_stop(p);
8585
}
8686
#endif // HAL_TIM_MODULE_ENABLED && !HAL_TIM_MODULE_ONLY
87-
{ reset_pin_configured(p, g_anOutputPinConfigured); }
87+
{
88+
reset_pin_configured(p, g_anOutputPinConfigured);
89+
}
8890
}
8991
#endif
9092
}
@@ -492,10 +494,16 @@ class Stm32I2sClass {
492494
}
493495

494496
/* Peripheral clock enable */
495-
__HAL_RCC_SPI3_CLK_ENABLE();
497+
if (hi2s->Instance == SPI1)
498+
__HAL_RCC_SPI1_CLK_ENABLE();
499+
else if (hi2s->Instance == SPI2)
500+
__HAL_RCC_SPI2_CLK_ENABLE();
501+
else if (hi2s->Instance == SPI3)
502+
__HAL_RCC_SPI3_CLK_ENABLE();
503+
else
504+
STM32_LOG("error: invalid hi2s->Instance");
496505

497506
if (use_dma) {
498-
499507
/* I2S3 DMA Init */
500508
if (dma_buffer_rx != nullptr) {
501509
setupDMA(hdma_i2s3_ext_rx, hw.rx_instance, hw.rx_channel,
@@ -542,14 +550,20 @@ class Stm32I2sClass {
542550
* @retval None
543551
*/
544552
virtual void cb_i2s_MspDeInit(I2S_HandleTypeDef *hi2s) {
545-
if (hi2s->Instance == SPI3) {
546-
/* Peripheral clock disable */
553+
if (hi2s->Instance == SPI1)
554+
__HAL_RCC_SPI1_CLK_DISABLE();
555+
else if (hi2s->Instance == SPI2)
556+
__HAL_RCC_SPI2_CLK_DISABLE();
557+
else if (hi2s->Instance == SPI3)
547558
__HAL_RCC_SPI3_CLK_DISABLE();
559+
else
560+
STM32_LOG("error: invalid hi2s->Instance");
548561

549-
/* I2S3 DMA DeInit */
550-
HAL_DMA_DeInit(hi2s->hdmarx);
551-
HAL_DMA_DeInit(hi2s->hdmatx);
552-
}
562+
/* Peripheral clock disable */
563+
564+
/* I2S3 DMA DeInit */
565+
HAL_DMA_DeInit(hi2s->hdmarx);
566+
HAL_DMA_DeInit(hi2s->hdmatx);
553567
}
554568
};
555569

0 commit comments

Comments
 (0)