From e51e8f675cd9d82efb2542fb83677bc40edb6c24 Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Sat, 22 Jun 2024 09:50:41 +0200 Subject: [PATCH] HR_Cx000: added function to write audio samples to the DAC FIFO --- platform/drivers/baseband/HR_Cx000.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/platform/drivers/baseband/HR_Cx000.h b/platform/drivers/baseband/HR_Cx000.h index d3c76df2..74f50ae5 100644 --- a/platform/drivers/baseband/HR_Cx000.h +++ b/platform/drivers/baseband/HR_Cx000.h @@ -188,6 +188,24 @@ public: return readReg(M::CONFIG, reg); } + /** + * Send audio to the DAC FIFO for playback via the "OpenMusic" mode. + * This function assumes that audio chunk is composed of 64 bytes. + * + * @param audio: pointer to a 64 byte audio chunk. + */ + inline void sendAudio(const uint8_t *audio) + { + uint8_t cmd[2]; + + cmd[0] = 0x03; + cmd[1] = 0x00; + + ScopedChipSelect cs(uSpi, uCs); + spi_send(uSpi, cmd, 2); + spi_send(uSpi, audio, 64); + } + private: /**