feat(vs1053b): use callbacks for RST & MUTE pins (#5836)

This commit is contained in:
Raphael Coeffic
2025-01-30 12:14:43 +10:00
committed by GitHub
parent 8256688268
commit 21012d3136
4 changed files with 51 additions and 39 deletions
+33 -18
View File
@@ -85,26 +85,41 @@ static uint8_t boardGetPcbRev()
}
}
stm32_spi_t audioSpi =
static void audio_set_rst_pin(bool set)
{
.SPIx = AUDIO_SPI,
.SCK = AUDIO_SPI_SCK_GPIO,
.MISO = AUDIO_SPI_MISO_GPIO,
.MOSI = AUDIO_SPI_MOSI_GPIO,
.CS = AUDIO_CS_GPIO,
};
gpio_write(AUDIO_RST_GPIO, set);
}
vs1053b_t audioConfig =
static void audio_set_mute_pin(bool set)
{
.spi = &audioSpi,
.XDCS = AUDIO_XDCS_GPIO,
.DREQ = AUDIO_DREQ_GPIO,
.RST = AUDIO_RST_GPIO,
.MUTE = AUDIO_MUTE_GPIO,
.flags = AUDIO_MUTE_POL,
.mute_delay_ms = AUDIO_MUTE_DELAY,
.unmute_delay_ms = AUDIO_UNMUTE_DELAY,
};
gpio_write(AUDIO_MUTE_GPIO, !set);
}
static void audioInit()
{
static stm32_spi_t spi_dev = {
.SPIx = AUDIO_SPI,
.SCK = AUDIO_SPI_SCK_GPIO,
.MISO = AUDIO_SPI_MISO_GPIO,
.MOSI = AUDIO_SPI_MOSI_GPIO,
.CS = AUDIO_CS_GPIO,
};
static vs1053b_t vs1053 = {
.spi = &spi_dev,
.XDCS = AUDIO_XDCS_GPIO,
.DREQ = AUDIO_DREQ_GPIO,
.set_rst_pin = audio_set_rst_pin,
.set_mute_pin = audio_set_mute_pin,
.mute_delay_ms = AUDIO_MUTE_DELAY,
.unmute_delay_ms = AUDIO_UNMUTE_DELAY,
};
gpio_init(AUDIO_RST_GPIO, GPIO_OUT, 0);
gpio_init(AUDIO_MUTE_GPIO, GPIO_OUT, 0);
vs1053b_init(&vs1053);
}
void boardBLEarlyInit()
{
@@ -194,7 +209,7 @@ void boardInit()
keysInit();
switchInit();
vs1053b_init(&audioConfig);
audioInit();
monitorInit();
adcInit(&_adc_driver);
hapticInit();