From 75a6dd8404fe693f6002a56efa8b649b013226cc Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sun, 10 Nov 2013 22:09:09 +0100 Subject: added FireBull-STM32F103-FB board --- boards/base/FireBull-STM32F103-FB/board.mk | 8 ++ .../board_SSD1289_firebullstm32f103.h | 124 +++++++++++++++++++++ .../FireBull-STM32F103-FB/chibios_board/board.c | 49 ++++++++ .../FireBull-STM32F103-FB/chibios_board/board.h | 100 +++++++++++++++++ .../FireBull-STM32F103-FB/chibios_board/board.mk | 6 + .../ginput_lld_mouse_board_firebull_stm32f103.h | 56 ++++++++++ .../ginput_lld_mouse_config.h | 22 ++++ boards/base/FireBull-STM32F103-FB/readme.txt | 6 + 8 files changed, 371 insertions(+) create mode 100644 boards/base/FireBull-STM32F103-FB/board.mk create mode 100644 boards/base/FireBull-STM32F103-FB/board_SSD1289_firebullstm32f103.h create mode 100755 boards/base/FireBull-STM32F103-FB/chibios_board/board.c create mode 100755 boards/base/FireBull-STM32F103-FB/chibios_board/board.h create mode 100755 boards/base/FireBull-STM32F103-FB/chibios_board/board.mk create mode 100644 boards/base/FireBull-STM32F103-FB/ginput_lld_mouse_board_firebull_stm32f103.h create mode 100644 boards/base/FireBull-STM32F103-FB/ginput_lld_mouse_config.h create mode 100644 boards/base/FireBull-STM32F103-FB/readme.txt (limited to 'boards') diff --git a/boards/base/FireBull-STM32F103-FB/board.mk b/boards/base/FireBull-STM32F103-FB/board.mk new file mode 100644 index 00000000..8f3e43c0 --- /dev/null +++ b/boards/base/FireBull-STM32F103-FB/board.mk @@ -0,0 +1,8 @@ +GFXINC += $(GFXLIB)/boards/base/FireBull-STM32F103-FB +GFXSRC += +GFXDEFS += -DGFX_USE_CHIBIOS=TRUE + +include $(GFXLIB)/boards/base/FireBull-STM32F103-FB/chibios_board/board.mk +include $(GFXLIB)/drivers/gdisp/SSD1289/gdisp_lld.mk +include $(GFXLIB)/drivers/ginput/touch/ADS7843/ginput_lld.mk + diff --git a/boards/base/FireBull-STM32F103-FB/board_SSD1289_firebullstm32f103.h b/boards/base/FireBull-STM32F103-FB/board_SSD1289_firebullstm32f103.h new file mode 100644 index 00000000..99001e07 --- /dev/null +++ b/boards/base/FireBull-STM32F103-FB/board_SSD1289_firebullstm32f103.h @@ -0,0 +1,124 @@ +/* + * 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 _GDISP_LLD_BOARD_H +#define _GDISP_LLD_BOARD_H + +// For a multiple display configuration we would put all this in a structure and then +// set g->board to that structure. +#define SET_CS palSetPad(GPIOD, 12); +#define CLR_CS palClearPad(GPIOD, 12); +#define SET_RS palSetPad(GPIOD, 13); +#define CLR_RS palClearPad(GPIOD, 13); +#define SET_WR palSetPad(GPIOD, 14); +#define CLR_WR palClearPad(GPIOD, 14); +#define SET_RD palSetPad(GPIOD, 15); +#define CLR_RD palClearPad(GPIOD, 15); + +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; + + switch(g->controllerdisplay) { + case 0: // Set up for Display 0 + palSetGroupMode(GPIOE, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOD, 12, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOD, 13, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOD, 14, PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(GPIOD, 15, PAL_MODE_OUTPUT_PUSHPULL); + + // Configure the pins to a well know state + SET_RS; + SET_RD; + SET_WR; + CLR_CS; + + break; + } +} + +static inline void post_init_board(GDisplay *g) +{ + (void) g; +} + +static inline void setpin_reset(GDisplay *g, bool_t state) +{ + (void) g; + (void) state; + + /* Nothing to do here - reset pin tied to Vcc */ +} + +static inline void set_backlight(GDisplay *g, uint8_t percent) +{ + (void) g; + (void) percent; + + /* Nothing to do here - Backlight always on */ +} + +static inline void acquire_bus(GDisplay *g) +{ + (void) g; +} + +static inline void release_bus(GDisplay *g) +{ + (void) g; +} + +static inline void write_index(GDisplay *g, uint16_t index) +{ + (void) g; + + palWritePort(GPIOE, index); + CLR_RS; + CLR_WR; + SET_WR; + SET_RS; +} + +static inline void write_data(GDisplay *g, uint16_t data) +{ + (void) g; + + palWritePort(GPIOE, data); + CLR_WR; + SET_WR; +} + +static inline void setreadmode(GDisplay *g) +{ + (void) g; + + // change pin mode to digital input + palSetGroupMode(GPIOE, PAL_WHOLE_PORT, 0, PAL_MODE_INPUT); + CLR_RD; +} + +static inline void setwritemode(GDisplay *g) +{ + (void) g; + + // change pin mode back to digital output + SET_RD; + palSetGroupMode(GPIOE, PAL_WHOLE_PORT, 0, PAL_MODE_OUTPUT_PUSHPULL); +} + +static inline uint16_t read_data(GDisplay *g) { + return palReadPort(GPIOE); +} + +#if defined(GDISP_USE_DMA) + #error "GDISP - SSD1289: The GPIO interface does not support DMA" +#endif + +#endif /* _GDISP_LLD_BOARD_H */ + diff --git a/boards/base/FireBull-STM32F103-FB/chibios_board/board.c b/boards/base/FireBull-STM32F103-FB/chibios_board/board.c new file mode 100755 index 00000000..b5dc0354 --- /dev/null +++ b/boards/base/FireBull-STM32F103-FB/chibios_board/board.c @@ -0,0 +1,49 @@ +#include "ch.h" +#include "hal.h" + +/** +* @brief PAL setup. +* @details Digital I/O ports static configuration as defined in @p board.h. +* This variable is used by the HAL when initializing the PAL driver. +*/ +#if HAL_USE_PAL || defined(__DOXYGEN__) +const PALConfig pal_default_config = { + {VAL_GPIOAODR, VAL_GPIOACRL, VAL_GPIOACRH}, + {VAL_GPIOBODR, VAL_GPIOBCRL, VAL_GPIOBCRH}, + {VAL_GPIOCODR, VAL_GPIOCCRL, VAL_GPIOCCRH}, + {VAL_GPIODODR, VAL_GPIODCRL, VAL_GPIODCRH}, + {VAL_GPIOEODR, VAL_GPIOECRL, VAL_GPIOECRH}, +}; +#endif + +#if HAL_USE_MMC_SPI +/* Board-related functions related to the MMC_SPI driver.*/ +bool_t mmc_lld_is_card_inserted(MMCDriver *mmcp) { + (void)mmcp; + + return !palReadPad(GPIOA, GPIOA_MMCCP); +} + +bool_t mmc_lld_is_write_protected(MMCDriver *mmcp) { + (void)mmcp; + + return 0; +} +#endif + +/* + * Early initialization code. + * This initialization must be performed just after stack setup and before + * any other initialization. + */ +void __early_init(void) { + stm32_clock_init(); +} + +void boardInit(void) { + palClearPad(GPIOD, GPIOD_LED1); + palClearPad(GPIOD, GPIOD_LED2); + palClearPad(GPIOD, GPIOD_LED3); + palClearPad(GPIOD, GPIOD_LED4); +} + diff --git a/boards/base/FireBull-STM32F103-FB/chibios_board/board.h b/boards/base/FireBull-STM32F103-FB/chibios_board/board.h new file mode 100755 index 00000000..0cfe134a --- /dev/null +++ b/boards/base/FireBull-STM32F103-FB/chibios_board/board.h @@ -0,0 +1,100 @@ +#ifndef _BOARD_H_ +#define _BOARD_H_ + +// Board identifier. +#define BOARD_FIREBULL_STM32_F103 +#define BOARD_NAME "FireBull STM32F103-FB" + +// Board frequencies. +#define STM32_LSECLK 32768 +#define STM32_HSECLK 8000000 + +// MCU type, supported types are defined in ./os/hal/platforms/hal_lld.h. +#define STM32F10X_HD + +// IO pins assignments. +#define GPIOA_BUTTON 8 + +#define GPIOD_LED1 8 +#define GPIOD_LED2 9 +#define GPIOD_LED3 10 +#define GPIOD_LED4 11 + +#define GPIOA_SPI1NSS 4 +#define GPIOB_SPI2NSS 12 +#define GPIOA_SPI3NSS 15 +#define GPIOA_MMCCP 4 +#define GPIOC_SDPWR 8 +#define GPIOC_USB_EN 9 + +#define TP_CS_PORT GPIOC +#define TP_IRQ_PORT GPIOC +#define TP_IRQ 4 +#define TP_CS 6 + +#define GDISP_DATA_PORT GPIOE +#define GDISP_CMD_PORT GPIOD +#define GDISP_CS 12 +#define GDISP_RS 13 +#define GDISP_WR 14 +#define GDISP_RD 15 + + /* + * I/O ports initial setup, this configuration is established soon after reset + * in the initialization code. + * + * The digits have the following meaning: + * 0 - Analog input. + * 1 - Push Pull output 10MHz. + * 2 - Push Pull output 2MHz. + * 3 - Push Pull output 50MHz. + * 4 - Digital input. + * 5 - Open Drain output 10MHz. + * 6 - Open Drain output 2MHz. + * 7 - Open Drain output 50MHz. + * 8 - Digital input with PullUp or PullDown resistor depending on ODR. + * 9 - Alternate Push Pull output 10MHz. + * A - Alternate Push Pull output 2MHz. + * B - Alternate Push Pull output 50MHz. + * C - Reserved. + * D - Alternate Open Drain output 10MHz. + * E - Alternate Open Drain output 2MHz. + * F - Alternate Open Drain output 50MHz. + * Please refer to the STM32 Reference Manual for details. + */ + +#define VAL_GPIOACRL 0xB4B44B34 /* PA7...PA0 */ +#define VAL_GPIOACRH 0x444334B4 /* PA15...PA8 */ +#define VAL_GPIOAODR 0xFFFFFFFF + +#define VAL_GPIOBCRL 0x88888888 /* PB7...PB0 */ +#define VAL_GPIOBCRH 0xB4B88888 /* PB15...PB8 */ +#define VAL_GPIOBODR 0xFFFFFFFF + +#define VAL_GPIOCCRL 0x33048888 /* PC7...PC0 */ +#define VAL_GPIOCCRH 0x88833383 /* PC15...PC8 */ +#define VAL_GPIOCODR 0xFFFFFFFF + +#define VAL_GPIODCRL 0x33388888 /* PD7...PD0 */ +#define VAL_GPIODCRH 0x33333333 /* PD15...PD8 */ +#define VAL_GPIODODR 0xFFFFFFFF + +#define VAL_GPIOECRL 0x33333333 /* PE7...PE0 */ +#define VAL_GPIOECRH 0x33333333 /* PE15...PE8 */ +#define VAL_GPIOEODR 0xFFFFFFFF + +#define usb_lld_connect_bus(usbp) palClearPad(GPIOC, GPIOC_USB_EN) +#define usb_lld_disconnect_bus(usbp) palSetPad(GPIOC, GPIOC_USB_EN) + +#if !defined(_FROM_ASM_) +#ifdef __cplusplus +extern "C" { + #endif + void boardInit(void); + #ifdef __cplusplus +} +#endif +#endif /* _FROM_ASM_ */ + +#endif /* _BOARD_H_ */ + diff --git a/boards/base/FireBull-STM32F103-FB/chibios_board/board.mk b/boards/base/FireBull-STM32F103-FB/chibios_board/board.mk new file mode 100755 index 00000000..0258db77 --- /dev/null +++ b/boards/base/FireBull-STM32F103-FB/chibios_board/board.mk @@ -0,0 +1,6 @@ +# List of all the board related files. +BOARDSRC = ${CHIBIOS}/boards/FIREBULL_STM32_F103/board.c + +# Required include directories +BOARDINC = ${CHIBIOS}/boards/FIREBULL_STM32_F103 + diff --git a/boards/base/FireBull-STM32F103-FB/ginput_lld_mouse_board_firebull_stm32f103.h b/boards/base/FireBull-STM32F103-FB/ginput_lld_mouse_board_firebull_stm32f103.h new file mode 100644 index 00000000..102bd834 --- /dev/null +++ b/boards/base/FireBull-STM32F103-FB/ginput_lld_mouse_board_firebull_stm32f103.h @@ -0,0 +1,56 @@ +/* + * 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 _GINPUT_LLD_MOUSE_BOARD_H +#define _GINPUT_LLD_MOUSE_BOARD_H + +static const SPIConfig spicfg = { + NULL, + GPIOC, + 6, + /* SPI_CR1_BR_2 |*/ SPI_CR1_BR_1 | SPI_CR1_BR_0, +}; + +static inline void init_board(void) +{ + spiStart(&SPID1, &spicfg); +} + +static inline bool_t getpin_pressed(void) +{ + return (!palReadPad(GPIOC, 4)); +} + +static inline void aquire_bus(void) +{ + spiAcquireBus(&SPID1); + palClearPad(GPIOC, 6); +} + +static inline void release_bus(void) +{ + palSetPad(GPIOC, 6); + spiReleaseBus(&SPID1); +} + +static inline uint16_t read_value(uint16_t port) +{ + static uint8_t txbuf[3] = {0}; + static uint8_t rxbuf[3] = {0}; + uint16_t ret; + + txbuf[0] = port; + + spiExchange(&SPID1, 3, txbuf, rxbuf); + + ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3); + + return ret; +} + +#endif /* _GINPUT_LLD_MOUSE_BOARD_H */ + diff --git a/boards/base/FireBull-STM32F103-FB/ginput_lld_mouse_config.h b/boards/base/FireBull-STM32F103-FB/ginput_lld_mouse_config.h new file mode 100644 index 00000000..f3a89208 --- /dev/null +++ b/boards/base/FireBull-STM32F103-FB/ginput_lld_mouse_config.h @@ -0,0 +1,22 @@ +/* + * 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 _LLD_GINPUT_MOUSE_CONFIG_H +#define _LLD_GINPUT_MOUSE_CONFIG_H + +#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH +#define GINPUT_MOUSE_NEED_CALIBRATION TRUE +#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE +#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 12 +#define GINPUT_MOUSE_READ_CYCLES 4 +#define GINPUT_MOUSE_POLL_PERIOD 3 +#define GINPUT_MOUSE_MAX_CLICK_JITTER 2 +#define GINPUT_MOUSE_MAX_MOVE_JITTER 2 +#define GINPUT_MOUSE_CLICK_TIME 500 + +#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */ + diff --git a/boards/base/FireBull-STM32F103-FB/readme.txt b/boards/base/FireBull-STM32F103-FB/readme.txt new file mode 100644 index 00000000..a80dd461 --- /dev/null +++ b/boards/base/FireBull-STM32F103-FB/readme.txt @@ -0,0 +1,6 @@ +This directory contains the interface for the FireBull-FB-STM32F103 board +running ChibiOS/RT. + +As this is not a standard ChibiOS/RT supported board, the necessary board files have +also been provided in the chibios_board directory + -- cgit v1.2.3