diff options
author | inmarket <andrewh@inmarket.com.au> | 2014-11-10 14:39:59 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2014-11-10 14:39:59 +1000 |
commit | 2904cd326bd8996b2c9781bbc636dac57a602c31 (patch) | |
tree | 5bc0c27c498b1d93d55fb70f8e1a80dacb065f50 /boards/addons/ginput/touch/ADS7843/ginput_lld_mouse_board_st_stm32f4_discovery.h | |
parent | 069c791fc1be91464154327718bbd3a36d09661c (diff) | |
download | uGFX-2904cd326bd8996b2c9781bbc636dac57a602c31.tar.gz uGFX-2904cd326bd8996b2c9781bbc636dac57a602c31.tar.bz2 uGFX-2904cd326bd8996b2c9781bbc636dac57a602c31.zip |
Conversion of some addon board files to newmouse
Diffstat (limited to 'boards/addons/ginput/touch/ADS7843/ginput_lld_mouse_board_st_stm32f4_discovery.h')
-rw-r--r-- | boards/addons/ginput/touch/ADS7843/ginput_lld_mouse_board_st_stm32f4_discovery.h | 40 |
1 files changed, 30 insertions, 10 deletions
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 6c3e2124..b4478d2b 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 @@ -34,41 +34,61 @@ static const SPIConfig spicfg = { /* SPI_CR1_BR_2 |*/ SPI_CR1_BR_1 | SPI_CR1_BR_0, }; -static inline void init_board(void) { +// Resolution and Accuracy Settings +#define GMOUSE_ADS7843_PEN_CALIBRATE_ERROR 8 +#define GMOUSE_ADS7843_PEN_CLICK_ERROR 6 +#define GMOUSE_ADS7843_PEN_MOVE_ERROR 4 +#define GMOUSE_ADS7843_FINGER_CALIBRATE_ERROR 14 +#define GMOUSE_ADS7843_FINGER_CLICK_ERROR 18 +#define GMOUSE_ADS7843_FINGER_MOVE_ERROR 14 + +// How much extra data to allocate at the end of the GMouse structure for the board's use +#define GMOUSE_ADS7843_BOARD_DATA_SIZE 0 + +static bool_t init_board(GMouse* m, unsigned driverinstance) { + (void) m; + + if (driverinstance) + return FALSE; + palSetPadMode(GPIOB, 13, PAL_MODE_ALTERNATE(5) ); /* SCK */ palSetPadMode(GPIOB, 14, PAL_MODE_ALTERNATE(5) ); /* MISO */ palSetPadMode(GPIOB, 15, PAL_MODE_ALTERNATE(5) ); /* MOSI */ palSetPadMode(GPIOC, 4, PAL_MODE_OUTPUT_PUSHPULL); /* CS */ spiStart(&SPID2, &spicfg); + return TRUE; } -static inline bool_t getpin_pressed(void) { +static inline bool_t getpin_pressed(GMouse* m) { + (void) m; + return (!palReadPad(GPIOC, 5)); } -static inline void aquire_bus(void) { +static inline void aquire_bus(GMouse* m) { + (void) m; + spiAcquireBus(&SPID2); palClearPad(GPIOC, 4); } -static inline void release_bus(void) { +static inline void release_bus(GMouse* m) { + (void) m; + palSetPad(GPIOC, 4); spiReleaseBus(&SPID2); } -static inline uint16_t read_value(uint16_t port) { +static inline uint16_t read_value(GMouse* m, uint16_t port) { static uint8_t txbuf[3] = {0}; static uint8_t rxbuf[3] = {0}; - uint16_t ret; + (void) m; txbuf[0] = port; - spiExchange(&SPID2, 3, txbuf, rxbuf); - ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3); - - return ret; + return ((uint16_t)rxbuf[1] << 5) | (rxbuf[2] >> 3); } #endif /* _GINPUT_LLD_MOUSE_BOARD_H */ |