diff options
Diffstat (limited to 'boards')
26 files changed, 485 insertions, 35 deletions
diff --git a/boards/addons/gdisp/board_ED060SC4_example.h b/boards/addons/gdisp/board_ED060SC4_example.h index cb5a92b8..008e85d4 100644 --- a/boards/addons/gdisp/board_ED060SC4_example.h +++ b/boards/addons/gdisp/board_ED060SC4_example.h @@ -5,8 +5,10 @@ * http://ugfx.org/license.html */ -/* Board interface definitions for ED060SC4 PrimeView E-ink panel. - * +/** + * @file boards/addons/gdisp/board_ED060SC4_example.h + * @brief GDISP Graphic Driver subsystem board interface for the ED060SC4 display. + * * This file corresponds to the connections shown in example_schematics.png, * and is designed to interface with ChibiOS/RT. * diff --git a/boards/addons/gdisp/board_HX8347D_stm32f4discovery.h b/boards/addons/gdisp/board_HX8347D_stm32f4discovery.h index f486841b..341f4366 100644 --- a/boards/addons/gdisp/board_HX8347D_stm32f4discovery.h +++ b/boards/addons/gdisp/board_HX8347D_stm32f4discovery.h @@ -6,8 +6,11 @@ */ /** - * @file drivers/gdisp/HX8347D/board_HX8347D_stm32f4discovery.h + * @file boards/addons/gdisp/board_HX8347D_stm32f4discovery.h * @brief GDISP Graphic Driver subsystem board SPI interface for the HX8347D display. + * + * @note This file contains a mix of hardware specific and operating system specific + * code. You will need to change it for your CPU and/or operating system. */ #ifndef _GDISP_LLD_BOARD_H diff --git a/boards/addons/gdisp/board_ILI9320_olimex_pic32mx_lcd.h b/boards/addons/gdisp/board_ILI9320_olimex_pic32mx_lcd.h index 5315127b..0e399f1f 100644 --- a/boards/addons/gdisp/board_ILI9320_olimex_pic32mx_lcd.h +++ b/boards/addons/gdisp/board_ILI9320_olimex_pic32mx_lcd.h @@ -6,8 +6,11 @@ */ /** - * @file drivers/gdisp/ILI9320/board_ILI9320_olimex_pic32mx_lcd.h - * @brief GDISP Graphic Driver subsystem board interface for the ILI9325 display. + * @file boards/addons/gdisp/board_ILI9320_olimex_pic32mx_lcd.h + * @brief GDISP Graphic Driver subsystem board SPI interface for the ILI9325 display. + * + * @note This file contains a mix of hardware specific and operating system specific + * code. You will need to change it for your CPU and/or operating system. */ #ifndef GDISP_LLD_BOARD_H diff --git a/boards/addons/gdisp/board_ILI9325_hy_stm32_100p.h b/boards/addons/gdisp/board_ILI9325_hy_stm32_100p.h index 60508c1a..87c4530d 100644 --- a/boards/addons/gdisp/board_ILI9325_hy_stm32_100p.h +++ b/boards/addons/gdisp/board_ILI9325_hy_stm32_100p.h @@ -19,8 +19,11 @@ /** - * @file drivers/gdisp/ILI9325/board_ILI9325_hy_stm32_100p.h - * @brief GDISP Graphic Driver subsystem board interface for the ILI9325 display. + * @file boards/addons/gdisp/board_ILI9325_hy_stm32_100p.h + * @brief GDISP Graphic Driver subsystem board SPI interface for the ILI9325 display. + * + * @note This file contains a mix of hardware specific and operating system specific + * code. You will need to change it for your CPU and/or operating system. */ #ifndef GDISP_LLD_BOARD_H diff --git a/boards/addons/gdisp/board_ILI9341_spi.h b/boards/addons/gdisp/board_ILI9341_spi.h new file mode 100644 index 00000000..4b3b058d --- /dev/null +++ b/boards/addons/gdisp/board_ILI9341_spi.h @@ -0,0 +1,222 @@ +/* + * 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 + */ + +/** + * @file boards/addons/gdisp/board_ILI9341_spi.h + * @brief GDISP Graphic Driver subsystem board interface for the ILI9341 display. + * + * @note This file contains a mix of hardware specific and operating system specific + * code. You will need to change it for your CPU and/or operating system. + */ + +#ifndef _GDISP_LLD_BOARD_H +#define _GDISP_LLD_BOARD_H + +#define LCD_PORT GPIOB +#define LCD_MOSI 15 +#define LCD_MISO 14 +#define LCD_SCK 13 +#define LCD_CS 12 +#define LCD_DC 11 +#define LCD_RES 10 + +#define LCD_DC_CMD palClearPad(LCD_PORT, LCD_DC) +#define LCD_DC_DATA palSetPad(LCD_PORT, LCD_DC) +#define LCD_SCK_SET palSetPad(LCD_PORT, LCD_SCK) +#define LCD_SCK_RES palClearPad(LCD_PORT, LCD_SCK) +#define LCD_CS_RES palSetPad(LCD_PORT, LCD_CS) +#define LCD_CS_SET palClearPad(LCD_PORT, LCD_CS) + +/** + * SPI configuration structure. + * Speed 12 MHz, CPHA=0, CPOL=0, 8bits frames, MSb transmitted first. + * Soft slave select. + */ +static const SPIConfig spi2cfg = { + NULL, + LCD_PORT, + LCD_CS, + (SPI_CR1_MSTR | SPI_CR1_SPE | SPI_CR1_SSM | SPI_CR1_SSI) +}; + +static void send_data(uint16_t data); + +/** + * @brief Initialise the board for the display. + * + * @param[in] g The GDisplay structure + * + * @note Set the g->board member to whatever is appropriate. For multiple + * displays this might be a pointer to the appropriate register set. + * + * @notapi + */ +static inline void init_board(GDisplay *g) { + + // As we are not using multiple displays we set g->board to NULL as we don't use it. + g->board = 0; + + palSetPadMode(LCD_PORT, LCD_CS, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(LCD_PORT, LCD_DC, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(LCD_PORT, LCD_RES, PAL_MODE_OUTPUT_PUSHPULL); + + spiStart(&SPID2, &spi2cfg); + spiSelectI(&SPID2); +} + +/** + * @brief After the initialisation. + * + * @param[in] g The GDisplay structure + * + * @notapi + */ +static inline void post_init_board(GDisplay *g) { + (void) g; +} + +/** + * @brief Set or clear the lcd reset pin. + * + * @param[in] g The GDisplay structure + * @param[in] state TRUE = lcd in reset, FALSE = normal operation + * + * @notapi + */ +static inline void setpin_reset(GDisplay *g, bool_t state) { + (void) g; + + if (state == TRUE) { + palClearPad(LCD_PORT, LCD_RES); + } else { + palSetPad(LCD_PORT, LCD_RES); + } +} + +/** + * @brief Set the lcd back-light level. + * + * @param[in] g The GDisplay structure + * @param[in] percent 0 to 100% + * + * @notapi + */ +static inline void set_backlight(GDisplay *g, uint8_t percent) { + (void) g; + (void) percent; +} + +/** + * @brief Take exclusive control of the bus + * + * @param[in] g The GDisplay structure + * + * @notapi + */ +static inline void acquire_bus(GDisplay *g) { + (void) g; +} + +/** + * @brief Release exclusive control of the bus + * + * @param[in] g The GDisplay structure + * + * @notapi + */ +static inline void release_bus(GDisplay *g) { + (void) g; +} + +/** + * @brief Send data to the lcd. + * + * @param[in] data The data to send + * + * @notapi + */ +static inline void send_data(uint16_t data) { +// http://forum.easyelectronics.ru/viewtopic.php?p=262122#p262122 + while (!(SPI2->SR & SPI_SR_TXE)); // при входе на отправку проверяем - а пустой ли SPI_DR + SPI2->DR = data; // загрузили в SPI_DR код команды + +} + +/** + * @brief Send data to the index register. + * + * @param[in] g The GDisplay structure + * @param[in] index The index register to set + * + * @notapi + */ +static inline void write_index(GDisplay *g, uint16_t index) { + (void) g; + + while (SPI2->SR & SPI_SR_BSY); + LCD_CS_RES; + LCD_DC_CMD; // переводим дисплей в режим команд + LCD_CS_SET; + send_data(index); + while (SPI2->SR & SPI_SR_BSY); // пока флаг установлен (==1) -- модуль SPI занят + /* лишний цикл ожидания окончания передачи команды позволяет в дальнейшем слать + * байты данных без ненужных ожиданий и задержек. + */ + LCD_DC_DATA; // переводим дисплей в режим данных +} + +/** + * @brief Send data to the lcd with DC control. + * + * @param[in] g The GDisplay structure + * @param[in] data The data to send + * + * @notapi + */ +static inline void write_data(GDisplay *g, uint16_t data) { + (void) g; + + send_data(data); +} + +/** + * @brief Set the bus in read mode + * + * @param[in] g The GDisplay structure + * + * @notapi + */ +static inline void setreadmode(GDisplay *g) { + (void) g; +} + +/** + * @brief Set the bus back into write mode + * + * @param[in] g The GDisplay structure + * + * @notapi + */ +static inline void setwritemode(GDisplay *g) { + (void) g; +} + +/** + * @brief Read data from the lcd. + * @return The data from the lcd + * + * @param[in] g The GDisplay structure + * + * @notapi + */ +static inline uint16_t read_data(GDisplay *g) { + (void) g; + return 0; +} + +#endif /* _GDISP_LLD_BOARD_H */ + diff --git a/boards/addons/gdisp/board_ILI9481_firebullstm32f103.h b/boards/addons/gdisp/board_ILI9481_firebullstm32f103.h index 17bc554d..08cbaf3d 100644 --- a/boards/addons/gdisp/board_ILI9481_firebullstm32f103.h +++ b/boards/addons/gdisp/board_ILI9481_firebullstm32f103.h @@ -6,9 +6,11 @@ */ /** - * @file drivers/gdisp/ILI9481/board_ILI9481_firebullstm32f103.h - * @brief GDISP Graphics Driver subsystem low level driver source for - * the ILI9481 and compatible HVGA display + * @file boards/addons/gdisp/board_ILI9481_firebullstm32f103.h + * @brief GDISP Graphics Driver subsystem low level driver source for the ILI9481 and compatible HVGA display + * + * @note This file contains a mix of hardware specific and operating system specific + * code. You will need to change it for your CPU and/or operating system. */ #ifndef _GDISP_LLD_BOARD_H diff --git a/boards/addons/gdisp/board_S6D1121_olimex_e407.h b/boards/addons/gdisp/board_S6D1121_olimex_e407.h index e0bb8e26..1e2b53f7 100644 --- a/boards/addons/gdisp/board_S6D1121_olimex_e407.h +++ b/boards/addons/gdisp/board_S6D1121_olimex_e407.h @@ -6,8 +6,11 @@ */ /** - * @file drivers/gdisp/S6D1121/board_S6D1121_olimex_e407.h - * @brief GDISP Graphic Driver subsystem board interface for the S6D1121 display + * @file boards/addons/gdisp/board_S6D1121_olimex_e407.h + * @brief GDISP Graphic Driver subsystem board interface for the S6D1121 display. + * + * @note This file contains a mix of hardware specific and operating system specific + * code. You will need to change it for your CPU and/or operating system. */ #ifndef _GDISP_LLD_BOARD_H diff --git a/boards/addons/gdisp/board_SSD1289_stm32f4discovery.h b/boards/addons/gdisp/board_SSD1289_stm32f4discovery.h index 1d86a67e..acbe16c0 100644 --- a/boards/addons/gdisp/board_SSD1289_stm32f4discovery.h +++ b/boards/addons/gdisp/board_SSD1289_stm32f4discovery.h @@ -6,8 +6,11 @@ */ /** - * @file drivers/gdisp/SSD1289/board_SSD1289_stm32f4discovery.h + * @file boards/addons/gdisp/board_SSD1289_stm32f4discovery.h * @brief GDISP Graphic Driver subsystem board interface for the SSD1289 display. + * + * @note This file contains a mix of hardware specific and operating system specific + * code. You will need to change it for your CPU and/or operating system. */ #ifndef _GDISP_LLD_BOARD_H diff --git a/boards/addons/gdisp/board_SSD1306_i2c.h b/boards/addons/gdisp/board_SSD1306_i2c.h index 3f755f26..e147a918 100644 --- a/boards/addons/gdisp/board_SSD1306_i2c.h +++ b/boards/addons/gdisp/board_SSD1306_i2c.h @@ -6,8 +6,11 @@ */ /** - * @file drivers/gdisp/SSD1306/board_SSD1306_i2c.h + * @file boards/addons/gdisp/board_SSD1306_i2c.h * @brief GDISP Graphic Driver subsystem board interface for the SSD1306 display. + * + * @note This file contains a mix of hardware specific and operating system specific + * code. You will need to change it for your CPU and/or operating system. */ #ifndef _GDISP_LLD_BOARD_H diff --git a/boards/addons/gdisp/board_SSD1306_spi.h b/boards/addons/gdisp/board_SSD1306_spi.h index b476fec0..56e1abae 100644 --- a/boards/addons/gdisp/board_SSD1306_spi.h +++ b/boards/addons/gdisp/board_SSD1306_spi.h @@ -6,8 +6,11 @@ */ /** - * @file drivers/gdisp/SSD1306/board_SSD1306_spi.h + * @file boards/addons/gdisp/board_SSD1306_spi.h * @brief GDISP Graphic Driver subsystem board interface for the SSD1306 display. + * + * @note This file contains a mix of hardware specific and operating system specific + * code. You will need to change it for your CPU and/or operating system. */ #ifndef _GDISP_LLD_BOARD_H diff --git a/boards/addons/gdisp/board_SSD1963_fsmc.h b/boards/addons/gdisp/board_SSD1963_fsmc.h index 6c7119a4..55fabacc 100644 --- a/boards/addons/gdisp/board_SSD1963_fsmc.h +++ b/boards/addons/gdisp/board_SSD1963_fsmc.h @@ -6,8 +6,11 @@ */ /** - * @file drivers/gdisp/SSD1963/board_SSD1963_fsmc.h + * @file boards/addons/gdisp/board_SSD1963_fsmc.h * @brief GDISP Graphic Driver subsystem board interface for the SSD1963 display. + * + * @note This file contains a mix of hardware specific and operating system specific + * code. You will need to change it for your CPU and/or operating system. */ #ifndef _GDISP_LLD_BOARD_H diff --git a/boards/addons/gdisp/board_SSD1963_gpio.h b/boards/addons/gdisp/board_SSD1963_gpio.h index 0b9c0135..cc7d1579 100644 --- a/boards/addons/gdisp/board_SSD1963_gpio.h +++ b/boards/addons/gdisp/board_SSD1963_gpio.h @@ -6,8 +6,11 @@ */ /** - * @file drivers/gdisp/SSD1963/board_SSD1963_gpio.h + * @file boards/addons/gdisp/board_SSD1963_gpio.h * @brief GDISP Graphic Driver subsystem board interface for the SSD1963 display. + * + * @note This file contains a mix of hardware specific and operating system specific + * code. You will need to change it for your CPU and/or operating system. */ #ifndef _GDISP_LLD_BOARD_H diff --git a/boards/addons/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h b/boards/addons/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h index 73507f10..f17d6e8e 100644 --- a/boards/addons/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h +++ b/boards/addons/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h @@ -6,12 +6,11 @@ */ /** - * @file drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h + * @file boards/addons/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h * @brief GINPUT Touch low level driver source for the ADS7843 on an Olimex STM32E407. * - * @defgroup Mouse Mouse - * @ingroup GINPUT - * @{ + * @note This file contains a mix of hardware specific and operating system specific + * code. You will need to change it for your CPU and/or operating system. */ #ifndef _GINPUT_LLD_MOUSE_BOARD_H @@ -87,4 +86,4 @@ static inline uint16_t read_value(uint16_t port) { } #endif /* _GINPUT_LLD_MOUSE_BOARD_H */ -/** @} */ + diff --git a/boards/addons/ginput/touch/ADS7843/ginput_lld_mouse_board_st_stm32f4_discovery.h b/boards/addons/ginput/touch/ADS7843/ginput_lld_mouse_board_st_stm32f4_discovery.h index d4923c29..6c3e2124 100644 --- a/boards/addons/ginput/touch/ADS7843/ginput_lld_mouse_board_st_stm32f4_discovery.h +++ b/boards/addons/ginput/touch/ADS7843/ginput_lld_mouse_board_st_stm32f4_discovery.h @@ -5,6 +5,14 @@ * http://ugfx.org/license.html */ +/** + * @file boards/addons/ginput/touch/ADS7843/ginput_lld_mouse_board_st_stm32f4_discovery.h + * @brief GINPUT Touch low level driver source for the ADS7843 on an st_stm32f4_discovery. + * + * @note This file contains a mix of hardware specific and operating system specific + * code. You will need to change it for your CPU and/or operating system. + */ + #ifndef _GINPUT_LLD_MOUSE_BOARD_H #define _GINPUT_LLD_MOUSE_BOARD_H diff --git a/boards/addons/ginput/touch/MCU/ginput_lld_mouse_board_olimex_pic32mx_lcd.h b/boards/addons/ginput/touch/MCU/ginput_lld_mouse_board_olimex_pic32mx_lcd.h index a7435c95..87e2a93c 100644 --- a/boards/addons/ginput/touch/MCU/ginput_lld_mouse_board_olimex_pic32mx_lcd.h +++ b/boards/addons/ginput/touch/MCU/ginput_lld_mouse_board_olimex_pic32mx_lcd.h @@ -6,13 +6,11 @@ */ /** - * @file drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h + * @file boards/addons/ginput/touch/MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h * @brief GINPUT Touch low level driver source for the MCU on the example board. * - * @defgroup Mouse Mouse - * @ingroup GINPUT - * - * @{ + * @note This file contains a mix of hardware specific and operating system specific + * code. You will need to change it for your CPU and/or operating system. */ #ifndef _GINPUT_LLD_MOUSE_BOARD_H 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/example/Makefile b/boards/base/Mikromedia-STM32-M4-ILI9341/example/Makefile index 1c314543..0ca152c6 100644 --- a/boards/base/Mikromedia-STM32-M4-ILI9341/example/Makefile +++ b/boards/base/Mikromedia-STM32-M4-ILI9341/example/Makefile @@ -153,6 +153,7 @@ LD = $(TRGT)gcc CP = $(TRGT)objcopy AS = $(TRGT)gcc -x assembler-with-cpp OD = $(TRGT)objdump +SZ = $(TRGT)size HEX = $(CP) -O ihex BIN = $(CP) -O binary diff --git a/boards/base/Mikromedia-STM32-M4-ILI9341/example/mcuconf.h b/boards/base/Mikromedia-STM32-M4-ILI9341/example/mcuconf.h index 64895943..c92d2970 100644 --- a/boards/base/Mikromedia-STM32-M4-ILI9341/example/mcuconf.h +++ b/boards/base/Mikromedia-STM32-M4-ILI9341/example/mcuconf.h @@ -29,6 +29,10 @@ */ #define STM32F4xx_MCUCONF +#define STM32F40_41xxx + +// Define this if you are using an older ChibiOS version +//#define STM32_VOS STM32_VOS_HIGH /* * HAL driver system settings. @@ -57,7 +61,6 @@ #define STM32_I2SSRC STM32_I2SSRC_CKIN #define STM32_PLLI2SN_VALUE 192 #define STM32_PLLI2SR_VALUE 5 -#define STM32_VOS STM32_VOS_HIGH #define STM32_PVD_ENABLE FALSE #define STM32_PLS STM32_PLS_LEV0 #define STM32_BKPRAM_ENABLE FALSE 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. diff --git a/boards/base/Olimex-SAM7EX256-GE8/board.mk b/boards/base/Olimex-SAM7EX256-GE8/board.mk index 249cfc2d..98119565 100644 --- a/boards/base/Olimex-SAM7EX256-GE8/board.mk +++ b/boards/base/Olimex-SAM7EX256-GE8/board.mk @@ -6,3 +6,4 @@ include $(GFXLIB)/drivers/gadc/AT91SAM7/gadc_lld.mk include $(GFXLIB)/drivers/ginput/dial/GADC/ginput_lld.mk include $(GFXLIB)/drivers/ginput/toggle/Pal/ginput_lld.mk include $(GFXLIB)/drivers/gaudio/gadc/driver.mk +include $(GFXLIB)/drivers/gaudio/pwm/driver.mk diff --git a/boards/base/Olimex-SAM7EX256-GE8/example/Makefile b/boards/base/Olimex-SAM7EX256-GE8/example/Makefile index b7b4da1c..e9fdde2d 100644 --- a/boards/base/Olimex-SAM7EX256-GE8/example/Makefile +++ b/boards/base/Olimex-SAM7EX256-GE8/example/Makefile @@ -136,6 +136,7 @@ LD = $(TRGT)gcc CP = $(TRGT)objcopy AS = $(TRGT)gcc -x assembler-with-cpp OD = $(TRGT)objdump +SZ = $(TRGT)size HEX = $(CP) -O ihex BIN = $(CP) -O binary diff --git a/boards/base/Olimex-SAM7EX256-GE8/example/halconf.h b/boards/base/Olimex-SAM7EX256-GE8/example/halconf.h index db88d41b..3b60d923 100644 --- a/boards/base/Olimex-SAM7EX256-GE8/example/halconf.h +++ b/boards/base/Olimex-SAM7EX256-GE8/example/halconf.h @@ -80,7 +80,7 @@ * @brief Enables the GPT subsystem. */ #if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) -#define HAL_USE_GPT FALSE +#define HAL_USE_GPT TRUE #endif /** @@ -116,10 +116,6 @@ */ #if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) #define HAL_USE_PWM TRUE -#define PWM_USE_PWM1 FALSE -#define PWM_USE_PWM2 TRUE -#define PWM_USE_PWM3 FALSE -#define PWM_USE_PWM4 FALSE #endif /** diff --git a/boards/base/Olimex-SAM7EX256-GE8/example/mcuconf.h b/boards/base/Olimex-SAM7EX256-GE8/example/mcuconf.h index a9a0fea7..8acdd42d 100644 --- a/boards/base/Olimex-SAM7EX256-GE8/example/mcuconf.h +++ b/boards/base/Olimex-SAM7EX256-GE8/example/mcuconf.h @@ -52,6 +52,10 @@ /* * PWM driver system settings. */ +#define PWM_USE_PWM1 TRUE // used by audio-out +#define PWM_USE_PWM2 TRUE // used by back-light +#define PWM_USE_PWM3 FALSE +#define PWM_USE_PWM4 FALSE /* * SERIAL driver system settings. @@ -69,3 +73,10 @@ #define AT91SAM7_SPI_USE_SPI1 FALSE #define AT91SAM7_SPI0_PRIORITY (AT91C_AIC_PRIOR_HIGHEST - 1) #define AT91SAM7_SPI1_PRIORITY (AT91C_AIC_PRIOR_HIGHEST - 1) + +/* + * GPT driver system settings. + */ +#define AT91_GPT_USE_TC0 FALSE // used internally by ADC driver +#define AT91_GPT_USE_TC1 TRUE // uGFX used for audio-out +#define AT91_GPT_USE_TC2 FALSE diff --git a/boards/base/Olimex-SAM7EX256-GE8/gaudio_play_board.h b/boards/base/Olimex-SAM7EX256-GE8/gaudio_play_board.h new file mode 100644 index 00000000..bbbc48c6 --- /dev/null +++ b/boards/base/Olimex-SAM7EX256-GE8/gaudio_play_board.h @@ -0,0 +1,75 @@ +/* + * 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 + +/* Our timer callback */ +static void gptcallback(GPTDriver *gptp) { + (void) gptp; + gaudio_play_pwm_timer_callbackI(); +} + +/* PWM configuration structure. The speaker is on PWM0/PB19 ie PWM1/PIN1 in ChibiOS speak */ +static PWMConfig pwmcfg = { + 1000000, /* 1 MHz PWM clock frequency. Ignored as we are using PWM_MCK_DIV_n */ + 1024, /* PWM period is 1024 cycles (10 bits). */ + 0, + { + {PWM_MCK_DIV_1 | PWM_OUTPUT_CENTER | PWM_OUTPUT_ACTIVE_HIGH | PWM_OUTPUT_PIN1 | PWM_DISABLEPULLUP_PIN1, 0}, + }, +}; + +/* Timer configuration structure. We use Timer 2 (TC1) */ +static GPTConfig gptcfg = { + 8192, // frequency + gptcallback, // callback + GPT_CLOCK_FREQUENCY, // clocksource + GPT_GATE_NONE, // clockgate + GPT_TRIGGER_NONE, // trigger +}; + +static uint16_t lastvalue; + +static bool gaudio_play_pwm_setup(uint32_t frequency, ArrayDataFormat format) { + if (format == ARRAY_DATA_10BITUNSIGNED) + pwmcfg.period = 1024; + else if (format == ARRAY_DATA_8BITUNSIGNED) + pwmcfg.period = 256; + else + return FALSE; + gptcfg.frequency = frequency; + return TRUE; +} + +static void gaudio_play_pwm_start(void) { + /* Start the PWM */ + pwmStart(&PWMD1, &pwmcfg); + lastvalue = pwmcfg.period>>1; + pwmEnableChannelI(&PWMD1, 0, lastvalue); + + /* Start the timer interrupt */ + gptStart(&GPTD2, &gptcfg); + gptStartContinuous(&GPTD2, 0); +} + +static void gaudio_play_pwm_stop(void) { + /* Stop the timer interrupt */ + gptStopTimer(&GPTD2); + + /* Stop the PWM */ + pwmStop(&PWMD1); +} + +static void gaudio_play_pwm_setI(uint16_t value) { + if (value != lastvalue) { + lastvalue = value; + pwmEnableChannelI(&PWMD1, 0, value); + } +} + +#endif /* GAUDIO_PLAY_BOARD_H */ diff --git a/boards/base/Olimex-SAM7EX256-GE8/gaudio_record_board.h b/boards/base/Olimex-SAM7EX256-GE8/gaudio_record_board.h index cdea5e06..68063881 100644 --- a/boards/base/Olimex-SAM7EX256-GE8/gaudio_record_board.h +++ b/boards/base/Olimex-SAM7EX256-GE8/gaudio_record_board.h @@ -20,12 +20,17 @@ #define GAUDIO_RECORD_NUM_CHANNELS 1 /** + * @brief Whether each channel is mono or stereo + */ +#define GAUDIO_RECORD_CHANNEL0_IS_STEREO FALSE + +/** * The list of audio channels and their uses */ #define GAUDIO_RECORD_MICROPHONE 0 #ifdef GAUDIO_RECORD_IMPLEMENTATION - static uint32_t gaudin_lld_physdevs[GAUDIO_RECORD_NUM_CHANNELS] = { + static uint32_t gaudio_gadc_physdevs[GAUDIO_RECORD_NUM_CHANNELS] = { GADC_PHYSDEV_MICROPHONE, }; #endif |