From 81c19da89f6055ee19ebcb7c5fc786bd82dadbe8 Mon Sep 17 00:00:00 2001 From: inmarket Date: Tue, 29 Apr 2014 16:35:57 +1000 Subject: First version vs1053 audio play driver. Compiles but not tested yet. --- boards/base/Mikromedia-STM32-M4-ILI9341/board.mk | 1 + .../gaudio_play_board.h | 97 ++++++++++++++++++++++ boards/base/Mikromedia-STM32-M4-ILI9341/readme.txt | 3 +- 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 boards/base/Mikromedia-STM32-M4-ILI9341/gaudio_play_board.h (limited to 'boards') diff --git a/boards/base/Mikromedia-STM32-M4-ILI9341/board.mk b/boards/base/Mikromedia-STM32-M4-ILI9341/board.mk index e466621c..b18bf8f5 100644 --- a/boards/base/Mikromedia-STM32-M4-ILI9341/board.mk +++ b/boards/base/Mikromedia-STM32-M4-ILI9341/board.mk @@ -3,3 +3,4 @@ GFXSRC += GFXDEFS += -DGFX_USE_OS_CHIBIOS=TRUE include $(GFXLIB)/drivers/gdisp/ILI9341/gdisp_lld.mk include $(GFXLIB)/drivers/ginput/touch/MCU/ginput_lld.mk +include $(GFXLIB)/drivers/gaudio/vs1053/driver.mk diff --git a/boards/base/Mikromedia-STM32-M4-ILI9341/gaudio_play_board.h b/boards/base/Mikromedia-STM32-M4-ILI9341/gaudio_play_board.h new file mode 100644 index 00000000..9b16b27a --- /dev/null +++ b/boards/base/Mikromedia-STM32-M4-ILI9341/gaudio_play_board.h @@ -0,0 +1,97 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +#ifndef GAUDIO_PLAY_BOARD_H +#define GAUDIO_PLAY_BOARD_H + +#define SET_CS palSetPad(GPIOC, GPIOC_MP3_CS) +#define CLR_CS palClearPad(GPIOC, GPIOC_MP3_CS) +#define SET_RST palSetPad(GPIOC, GPIOC_MP3_RST) +#define CLR_RST palClearPad(GPIOC, GPIOC_MP3_RST) +#define SET_DCS palSetPad(GPIOC, GPIOC_MP3_DCS) +#define CLR_DCS palClearPad(GPIOC, GPIOC_MP3_DCS) +#define GET_DREQ palReadPad(GPIOC, GPIOC_MP3_DREQ) +#define SPI_PORT &SPID3 + +static const SPIConfig spicfg_init = { + 0, + GPIOC, + GPIOC_MP3_CS, + SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0, +}; + +static const SPIConfig spicfg = { + 0, + GPIOC, + GPIOC_MP3_CS, + 0, +}; + +// Initialise the board +static inline void board_init(void) { + palSetPadMode(GPIOC, GPIOC_MP3_CS, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOC, GPIOC_MP3_RST, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOC, GPIOC_MP3_DCS, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOC, GPIOC_MP3_DREQ, PAL_MODE_INPUT); + SET_CS; SET_RST; SET_DCS; + spiStart(SPI_PORT, &spicfg_init); +} + +// Chip is initialised enough so we can talk fast to it +#define board_init_end() spiStart(SPI_PORT, &spicfg) + +// Reset the board +#define board_reset() { CLR_RST; gfxSleepMilliseconds(1); SET_RST; } + +// Returns the state of the dreq pin +#define board_dreq() GET_DREQ + +// Start a command write +static inline void board_startcmdwrite(void) { + #if SPI_USE_MUTUAL_EXCLUSION + spiAcquireBus(SPI_PORT); + #endif + CLR_CS; +} + +// End a command write +static inline void board_endcmdwrite(void) { + #if SPI_USE_MUTUAL_EXCLUSION + spiReleaseBus(SPI_PORT); + #endif + SET_CS; +} + +// Start a command read +#define board_startcmdread() board_startcmdwrite() + +// End a command read +#define board_endcmdread() board_endcmdwrite() + +// Start a data write +static inline void board_startdatawrite(void) { + #if SPI_USE_MUTUAL_EXCLUSION + spiAcquireBus(SPI_PORT); + #endif + CLR_DCS; +} + +// End a data write +static inline void board_enddatawrite(void) { + #if SPI_USE_MUTUAL_EXCLUSION + spiReleaseBus(SPI_PORT); + #endif + SET_DCS; +} + +// Write data to the SPI port +#define board_spiwrite(buf, len) spiSend(SPI_PORT, len, buf) + +// Read data from the SPI port +#define board_spiread(buf, len) spiReceive(SPI_PORT, len, buf) + +#endif /* GAUDIO_PLAY_BOARD_H */ diff --git a/boards/base/Mikromedia-STM32-M4-ILI9341/readme.txt b/boards/base/Mikromedia-STM32-M4-ILI9341/readme.txt index 961f9793..d37c58fb 100644 --- a/boards/base/Mikromedia-STM32-M4-ILI9341/readme.txt +++ b/boards/base/Mikromedia-STM32-M4-ILI9341/readme.txt @@ -3,7 +3,8 @@ running under ChibiOS with the ILI9341 display. On this board uGFX currently supports: - GDISP via the ILI9341 display - - GINPUT-touch via the MCU driver + - GINPUT-touch via the MCU driver + - GAUDIO (play only) via the vs1053 driver Note there are two variants of this board - one with the ILI9341 display and an older one with a different display. This one is for the ILI9341 display. -- cgit v1.2.3