diff options
Diffstat (limited to 'drivers/ginput')
8 files changed, 1 insertions, 819 deletions
diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_firebull_stm32f103.h b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_firebull_stm32f103.h deleted file mode 100644 index ebcc26c7..00000000 --- a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_firebull_stm32f103.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_firebull_stm32f103.h
- * @brief GINPUT ouch low level driver source for the ADS7843 on the FireBull STM32F103-FB board.
- *
- * @defgroup Mouse Mouse
- * @ingroup GINPUT
- * @{
- */
-
-#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,
-};
-
-/**
- * @brief Initialise the board for the touch.
- *
- * @notapi
- */
-static inline void init_board(void) {
- spiStart(&SPID1, &spicfg);
-}
-
-/**
- * @brief Check whether the surface is currently touched
- * @return TRUE if the surface is currently touched
- *
- * @notapi
- */
-static inline bool_t getpin_pressed(void) {
- return (!palReadPad(GPIOC, 4));
-}
-/**
- * @brief Aquire the bus ready for readings
- *
- * @notapi
- */
-static inline void aquire_bus(void) {
- spiAcquireBus(&SPID1);
- //TOUCHSCREEN_SPI_PROLOGUE();
- palClearPad(GPIOC, 6);
-}
-
-/**
- * @brief Release the bus after readings
- *
- * @notapi
- */
-static inline void release_bus(void) {
- palSetPad(GPIOC, 6);
- spiReleaseBus(&SPID1);
- //TOUCHSCREEN_SPI_EPILOGUE();
-}
-
-/**
- * @brief Read a value from touch controller
- * @return The value read from the controller
- *
- * params[in] port The controller port to read.
- *
- * @notapi
- */
-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/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h deleted file mode 100644 index 01572f0d..00000000 --- a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 drivers/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
- * @{
- */
-
-#ifndef _GINPUT_LLD_MOUSE_BOARD_H
-#define _GINPUT_LLD_MOUSE_BOARD_H
-
-static const SPIConfig spicfg = {
- NULL,
- GPIOG,
- 10,
- /* SPI_CR1_BR_2 |*/ SPI_CR1_BR_1 | SPI_CR1_BR_0,
-};
-
-/**
- * @brief Initialise the board for the touch.
- *
- * @notapi
- */
-static inline void init_board(void) {
- spiStart(&SPID2, &spicfg);
-}
-
-/**
- * @brief Check whether the surface is currently touched
- * @return TRUE if the surface is currently touched
- *
- * @notapi
- */
-static inline bool_t getpin_pressed(void) {
- return (!palReadPad(GPIOG, 0));
-}
-/**
- * @brief Aquire the bus ready for readings
- *
- * @notapi
- */
-static inline void aquire_bus(void) {
- spiAcquireBus(&SPID2);
- //TOUCHSCREEN_SPI_PROLOGUE();
- palClearPad(GPIOG, 10);
-}
-
-/**
- * @brief Release the bus after readings
- *
- * @notapi
- */
-static inline void release_bus(void) {
- palSetPad(GPIOG, 10);
- spiReleaseBus(&SPID2);
- //TOUCHSCREEN_SPI_EPILOGUE();
-}
-
-/**
- * @brief Read a value from touch controller
- * @return The value read from the controller
- *
- * params[in] port The controller port to read.
- *
- * @notapi
- */
-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(&SPID2, 3, txbuf, rxbuf);
-
- ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3);
-
- return ret;
-}
-
-#endif /* _GINPUT_LLD_MOUSE_BOARD_H */
-/** @} */
diff --git a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_st_stm32f4_discovery.h b/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_st_stm32f4_discovery.h deleted file mode 100644 index 158934b6..00000000 --- a/drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_st_stm32f4_discovery.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 drivers/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 - * @{ - */ - -#ifndef _GINPUT_LLD_MOUSE_BOARD_H -#define _GINPUT_LLD_MOUSE_BOARD_H - -static const SPIConfig spicfg = { - NULL, - GPIOC, - 4, - /* SPI_CR1_BR_2 |*/ SPI_CR1_BR_1 | SPI_CR1_BR_0, -}; - -/** - * @brief Initialise the board for the touch. - * - * @notapi - */ -static inline void init_board(void) { - spiStart(&SPID2, &spicfg); -} - -/** - * @brief Check whether the surface is currently touched - * @return TRUE if the surface is currently touched - * - * @notapi - */ -static inline bool_t getpin_pressed(void) { - return (!palReadPad(GPIOC, 5)); -} -/** - * @brief Aquire the bus ready for readings - * - * @notapi - */ -static inline void aquire_bus(void) { - spiAcquireBus(&SPID2); - //TOUCHSCREEN_SPI_PROLOGUE(); - palClearPad(GPIOC, 4); -} - -/** - * @brief Release the bus after readings - * - * @notapi - */ -static inline void release_bus(void) { - palSetPad(GPIOC, 4); - spiReleaseBus(&SPID2); - //TOUCHSCREEN_SPI_EPILOGUE(); -} - -/** - * @brief Read a value from touch controller - * @return The value read from the controller - * - * params[in] port The controller port to read. - * - * @notapi - */ -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(&SPID2, 3, txbuf, rxbuf); - - ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3); - - return ret; -} - -#endif /* _GINPUT_LLD_MOUSE_BOARD_H */ -/** @} */ diff --git a/drivers/ginput/touch/FT5x06/ginput_lld_mouse_board_marlin.h b/drivers/ginput/touch/FT5x06/ginput_lld_mouse_board_marlin.h deleted file mode 100644 index e3e18c24..00000000 --- a/drivers/ginput/touch/FT5x06/ginput_lld_mouse_board_marlin.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * 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 drivers/ginput/touch/FT5x06/ginput_lld_mouse_board_marlin.h - * @brief GINPUT Touch low level driver source for the FT5x06. - * - * @defgroup Mouse Mouse - * @ingroup GINPUT - * @{ - */ - -#ifndef _GINPUT_LLD_MOUSE_BOARD_H -#define _GINPUT_LLD_MOUSE_BOARD_H - -/* I2C interface #2 - Touchscreen controller */ -static const I2CConfig i2ccfg2 = { - OPMODE_I2C, - 400000, - FAST_DUTY_CYCLE_2, -}; - -/** - * @brief Initialise the board for the touch. - * - * @notapi - */ -static void init_board(void) { - -} - - -/** - * @brief Write a value into a certain register - * - * @param[in] reg The register address - * @param[in] n The amount of bytes (one or two) - * @param[in] val The value - * - * @notapi - */ -static void write_reg(uint8_t reg, uint8_t n, uint16_t val) { - uint8_t txbuf[3]; - - i2cAcquireBus(&I2CD2); - - txbuf[0] = reg; - - if (n == 1) { - txbuf[1] = val; - i2cMasterTransmitTimeout(&I2CD2, FT5x06_ADDR, txbuf, 2, NULL, 0, MS2ST(FT5x06_TIMEOUT)); - } else if (n == 2) { - txbuf[1] = ((val & 0xFF00) >> 8); - txbuf[2] = (val & 0x00FF); - i2cMasterTransmitTimeout(&I2CD2, FT5x06_ADDR, txbuf, 3, NULL, 0, MS2ST(FT5x06_TIMEOUT)); - } - - i2cReleaseBus(&I2CD2); -} - -/** - * @brief Read the value of a certain register - * - * @param[in] reg The register address - * @param[in] n The amount of bytes (one or two) - * - * @return Data read from device (one byte or two depending on n param) - * - * @notapi - */ -static uint16_t read_reg(uint8_t reg, uint8_t n) { - uint8_t txbuf[1], rxbuf[2]; - uint16_t ret; - - rxbuf[0] = 0; - rxbuf[1] = 0; - - i2cAcquireBus(&I2CD2); - - txbuf[0] = reg; - i2cMasterTransmitTimeout(&I2CD2, FT5x06_ADDR, txbuf, 1, rxbuf, n, MS2ST(FT5x06_TIMEOUT)); - - if (n == 1) { - ret = rxbuf[0]; - } else if (n == 2) { - ret = ((rxbuf[0] << 8) | (rxbuf[1] & 0xFF)); - } - - i2cReleaseBus(&I2CD2); - - return ret; -} - -static void read_reg_n(uint8_t reg, uint8_t n, uint8_t *rxbuf) { - uint8_t txbuf[1]; - - i2cAcquireBus(&I2CD2); - - txbuf[0] = reg; - i2cMasterTransmitTimeout(&I2CD2, FT5x06_ADDR, txbuf, 1, rxbuf, n, MS2ST(FT5x06_TIMEOUT)); - - i2cReleaseBus(&I2CD2); -} - -#endif /* _GINPUT_LLD_MOUSE_BOARD_H */ -/** @} */ - diff --git a/drivers/ginput/touch/MCU/ginput_lld_mouse.c b/drivers/ginput/touch/MCU/ginput_lld_mouse.c index 1bb7cd50..a64bf6cb 100644 --- a/drivers/ginput/touch/MCU/ginput_lld_mouse.c +++ b/drivers/ginput/touch/MCU/ginput_lld_mouse.c @@ -21,15 +21,7 @@ #include "ginput/lld/mouse.h"
-#if defined(GINPUT_MOUSE_USE_CUSTOM_BOARD) && GINPUT_MOUSE_USE_CUSTOM_BOARD
- #include "ginput_lld_mouse_board.h"
-#elif defined(BOARD_OLIMEX_STM32_LCD)
- #include "ginput_lld_mouse_board_olimex_stm32_lcd.h"
-#elif defined(BOARD_OLIMEX_PIC32MX_LCD)
- #include "ginput_lld_mouse_board_olimex_pic32mx_lcd.h"
-#else
- #include "ginput_lld_mouse_board.h"
-#endif
+#include "ginput_lld_mouse_board.h"
static uint16_t sampleBuf[7];
static coord_t lastx, lasty;
diff --git a/drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_pic32mx_lcd.h b/drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_pic32mx_lcd.h deleted file mode 100644 index c4689ecb..00000000 --- a/drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_pic32mx_lcd.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - * 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 drivers/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
- *
- * @{
- */
-
-#ifndef _GINPUT_LLD_MOUSE_BOARD_H
-#define _GINPUT_LLD_MOUSE_BOARD_H
-
-static const ADCConfig ADCC = {
- .vref = ADC_VREF_CFG_AVDD_AVSS,
- .stime = 15,
- .irq = EIC_IRQ_ADC,
- .base = _ADC10_BASE_ADDRESS,
-};
-static struct ADCDriver ADCD;
-
-#define YNEG 13 // U
-#define XNEG 15 // R
-#define XPOS 12 // L
-#define YPOS 11 // D
-
-#define ADC_MAX 1023
-
-#define TOUCH_THRESHOULD 50
-
-static const ADCConversionGroup ADC_X_CG = {
- .circular = FALSE,
- .num_channels = 1,
- .channels = 1 << XNEG,
-};
-
-static const ADCConversionGroup ADC_Y_CG = {
- .circular = FALSE,
- .num_channels = 1,
- .channels = 1 << YPOS,
-};
-
-/**
- * @brief Initialise the board for the touch.
- *
- * @notapi
- */
-static inline void init_board(void) {
- adcObjectInit(&ADCD);
- adcStart(&ADCD, &ADCC);
-}
-
-/**
- * @brief Check whether the surface is currently touched
- * @return TRUE if the surface is currently touched
- *
- * @notapi
- */
-static inline bool_t getpin_pressed(void) {
- adcsample_t samples[2] = {0, };
-
- // Set X+ to ground
- palSetPadMode(IOPORTB, XPOS, PAL_MODE_OUTPUT);
- palClearPad(IOPORTB, XPOS);
-
- // Set Y- to VCC
- palSetPadMode(IOPORTB, YNEG, PAL_MODE_OUTPUT);
- palSetPad(IOPORTB, YNEG);
-
- palSetPadMode(IOPORTB, XNEG, PAL_MODE_INPUT_ANALOG);
- palSetPadMode(IOPORTB, YPOS, PAL_MODE_INPUT_ANALOG);
-
- adcConvert(&ADCD, &ADC_X_CG, &samples[0], 1);
- adcConvert(&ADCD, &ADC_Y_CG, &samples[1], 1);
-
- return (ADC_MAX - (samples[1] - samples[0])) > TOUCH_THRESHOULD;
-}
-
-/**
- * @brief Aquire the bus ready for readings
- *
- * @notapi
- */
-static inline void aquire_bus(void) {
-}
-
-/**
- * @brief Release the bus after readings
- *
- * @notapi
- */
-static inline void release_bus(void) {
-}
-
-/**
- * @brief Read an x value from touch controller
- * @return The value read from the controller
- *
- * @notapi
- */
-static inline uint16_t read_x_value(void) {
- adcsample_t sample;
-
- palSetPadMode(IOPORTB, XPOS, PAL_MODE_OUTPUT);
- palSetPad(IOPORTB, XPOS);
-
- palSetPadMode(IOPORTB, XNEG, PAL_MODE_OUTPUT);
- palClearPad(IOPORTB, XNEG);
-
- palSetPadMode(IOPORTB, YNEG, PAL_MODE_INPUT);
-
- palSetPadMode(IOPORTB, YPOS, PAL_MODE_INPUT_ANALOG);
-
- adcConvert(&ADCD, &ADC_Y_CG, &sample, 1);
-
- return ADC_MAX - sample;
-}
-
-/**
- * @brief Read an y value from touch controller
- * @return The value read from the controller
- *
- * @notapi
- */
-static inline uint16_t read_y_value(void) {
- adcsample_t sample;
-
- palSetPadMode(IOPORTB, YNEG, PAL_MODE_OUTPUT);
- palClearPad(IOPORTB, YNEG);
-
- palSetPadMode(IOPORTB, YPOS, PAL_MODE_OUTPUT);
- palSetPad(IOPORTB, YPOS);
-
- palSetPadMode(IOPORTB, XPOS, PAL_MODE_INPUT);
-
- palSetPadMode(IOPORTB, XNEG, PAL_MODE_INPUT_ANALOG);
-
- adcConvert(&ADCD, &ADC_X_CG, &sample, 1);
-
- return ADC_MAX - sample;
-}
-
-#endif /* _GINPUT_LLD_MOUSE_BOARD_H */
-/** @} */
diff --git a/drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h b/drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h deleted file mode 100644 index 2cc58f3c..00000000 --- a/drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h +++ /dev/null @@ -1,152 +0,0 @@ -/*
- * 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 drivers/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
- *
- * @{
- */
-
-#ifndef _GINPUT_LLD_MOUSE_BOARD_H
-#define _GINPUT_LLD_MOUSE_BOARD_H
-
-#define ADC_NUM_CHANNELS 2
-#define ADC_BUF_DEPTH 1
-
-static const ADCConversionGroup adc_y_config = {
- FALSE,
- ADC_NUM_CHANNELS,
- NULL,
- NULL,
- 0, 0,
- 0, 0,
- ADC_SQR1_NUM_CH(ADC_NUM_CHANNELS),
- 0,
- ADC_SQR3_SQ2_N(ADC_CHANNEL_IN12) | ADC_SQR3_SQ1_N(ADC_CHANNEL_IN13)
-};
-
-static const ADCConversionGroup adc_x_config = {
- FALSE,
- ADC_NUM_CHANNELS,
- NULL,
- NULL,
- 0, 0,
- 0, 0,
- ADC_SQR1_NUM_CH(ADC_NUM_CHANNELS),
- 0,
- ADC_SQR3_SQ2_N(ADC_CHANNEL_IN10) | ADC_SQR3_SQ1_N(ADC_CHANNEL_IN11)
-};
-
-/**
- * @brief Initialise the board for the touch.
- *
- * @notapi
- */
-static inline void init_board(void) {
- adcStart(&ADCD1, NULL);
-}
-
-/**
- * @brief Check whether the surface is currently touched
- * @return TRUE if the surface is currently touched
- *
- * @notapi
- */
-static inline bool_t getpin_pressed(void) {
- palSetPadMode(GPIOC, 0, PAL_MODE_INPUT_PULLDOWN);
- palSetPadMode(GPIOC, 1, PAL_MODE_INPUT);
- palSetPadMode(GPIOC, 2, PAL_MODE_INPUT);
- palSetPadMode(GPIOC, 3, PAL_MODE_OUTPUT_PUSHPULL);
- palSetPad(GPIOC, 3);
-
- return palReadPad(GPIOC, 0);
-}
-
-/**
- * @brief Aquire the bus ready for readings
- *
- * @notapi
- */
-static inline void aquire_bus(void) {
-
-}
-
-/**
- * @brief Release the bus after readings
- *
- * @notapi
- */
-static inline void release_bus(void) {
-
-}
-
-/**
- * @brief Read an x value from touch controller
- * @return The value read from the controller
- *
- * @notapi
- */
-static inline uint16_t read_x_value(void) {
- uint16_t val1, val2;
- adcsample_t samples[ADC_NUM_CHANNELS * ADC_BUF_DEPTH];
-
- palSetPadMode(GPIOC, 0, PAL_MODE_INPUT_ANALOG);
- palSetPadMode(GPIOC, 1, PAL_MODE_INPUT_ANALOG);
- palSetPadMode(GPIOC, 2, PAL_MODE_OUTPUT_PUSHPULL);
- palSetPadMode(GPIOC, 3, PAL_MODE_OUTPUT_PUSHPULL);
-
- palSetPad(GPIOC, 2);
- palClearPad(GPIOC, 3);
- gfxSleepMilliseconds(1);
- adcConvert(&ADCD1, &adc_x_config, samples, ADC_BUF_DEPTH);
- val1 = ((samples[0] + samples[1])/2);
-
- palClearPad(GPIOC, 2);
- palSetPad(GPIOC, 3);
- gfxSleepMilliseconds(1);
- adcConvert(&ADCD1, &adc_x_config, samples, ADC_BUF_DEPTH);
- val2 = ((samples[0] + samples[1])/2);
-
- return ((val1+((1<<12)-val2))/4);
-}
-
-/**
- * @brief Read an y value from touch controller
- * @return The value read from the controller
- *
- * @notapi
- */
-static inline uint16_t read_y_value(void) {
- uint16_t val1, val2;
- adcsample_t samples[ADC_NUM_CHANNELS * ADC_BUF_DEPTH];
-
- palSetPadMode(GPIOC, 2, PAL_MODE_INPUT_ANALOG);
- palSetPadMode(GPIOC, 3, PAL_MODE_INPUT_ANALOG);
- palSetPadMode(GPIOC, 0, PAL_MODE_OUTPUT_PUSHPULL);
- palSetPadMode(GPIOC, 1, PAL_MODE_OUTPUT_PUSHPULL);
-
- palSetPad(GPIOC, 1);
- palClearPad(GPIOC, 0);
- gfxSleepMilliseconds(1);
- adcConvert(&ADCD1, &adc_y_config, samples, ADC_BUF_DEPTH);
- val1 = ((samples[0] + samples[1])/2);
-
- palClearPad(GPIOC, 1);
- palSetPad(GPIOC, 0);
- gfxSleepMilliseconds(1);
- adcConvert(&ADCD1, &adc_y_config, samples, ADC_BUF_DEPTH);
- val2 = ((samples[0] + samples[1])/2);
-
- return ((val1+((1<<12)-val2))/4);
-}
-
-#endif /* _GINPUT_LLD_MOUSE_BOARD_H */
-/** @} */
diff --git a/drivers/ginput/touch/STMPE811/ginput_lld_mouse_board_embest_dmstf4bb.h b/drivers/ginput/touch/STMPE811/ginput_lld_mouse_board_embest_dmstf4bb.h deleted file mode 100644 index 7246378d..00000000 --- a/drivers/ginput/touch/STMPE811/ginput_lld_mouse_board_embest_dmstf4bb.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * 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 drivers/ginput/touch/STMPE811/ginput_lld_mouse_board_embest_dmstf4bb.h
- * @brief GINPUT Touch low level driver source for the STMPE811 on the Embest DM-STF4BB board.
- *
- * @defgroup Mouse Mouse
- * @ingroup GINPUT
- * @{
- */
-
-#ifndef _GINPUT_LLD_MOUSE_BOARD_H
-#define _GINPUT_LLD_MOUSE_BOARD_H
-
-static const I2CConfig i2ccfg = {
- OPMODE_I2C,
- 400000,
- FAST_DUTY_CYCLE_2,
-};
-
-/**
- * @brief Initialise the board for the touch.
- *
- * @notapi
- */
-static void init_board(void)
-{
- palSetPadMode(GPIOC, 13, PAL_MODE_INPUT | PAL_STM32_PUDR_FLOATING); /* TP IRQ */
- palSetPadMode(GPIOB, 8, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN); /* SCL */
- palSetPadMode(GPIOB, 9, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN); /* SDA */
-
- i2cStart(&I2CD1, &i2ccfg);
-}
-
-/**
- * @brief Check whether an interrupt is raised
- * @return TRUE if there is an interrupt signal present
- *
- * @notapi
- */
-static inline bool_t getpin_irq(void) {
- return (!(palReadPad(GPIOC, 13)));
-}
-
-/**
- * @brief Write a value into a certain register
- *
- * @param[in] reg The register address
- * @param[in] n The amount of bytes (one or two)
- * @param[in] val The value
- *
- * @notapi
- */
-static void write_reg(uint8_t reg, uint8_t n, uint16_t val)
-{
- uint8_t txbuf[3];
-
- i2cAcquireBus(&I2CD1);
-
- txbuf[0] = reg;
-
- if (n == 1) {
- txbuf[1] = val;
- i2cMasterTransmitTimeout(&I2CD1, STMPE811_ADDR, txbuf, 2, NULL, 0, MS2ST(STMPE811_TIMEOUT));
- } else if (n == 2) {
- txbuf[1] = ((val & 0xFF00) >> 8);
- txbuf[2] = (val & 0x00FF);
- i2cMasterTransmitTimeout(&I2CD1, STMPE811_ADDR, txbuf, 3, NULL, 0, MS2ST(STMPE811_TIMEOUT));
- }
-
- i2cReleaseBus(&I2CD1);
-}
-
-/**
- * @brief Read the value of a certain register
- *
- * @param[in] reg The register address
- * @param[in] n The amount of bytes (one or two)
- *
- * @return Data read from device (one byte or two depending on n param)
- *
- * @notapi
- */
-static uint16_t read_reg(uint8_t reg, uint8_t n)
-{
- uint8_t txbuf[1], rxbuf[2];
- uint16_t ret;
-
- rxbuf[0] = 0;
- rxbuf[1] = 0;
-
- i2cAcquireBus(&I2CD1);
-
- txbuf[0] = reg;
- i2cMasterTransmitTimeout(&I2CD1, STMPE811_ADDR, txbuf, 1, rxbuf, n, MS2ST(STMPE811_TIMEOUT));
-
- if (n == 1) {
- ret = rxbuf[0];
- } else if (n == 2) {
- ret = ((rxbuf[0] << 8) | (rxbuf[1] & 0xFF));
- }
-
- i2cReleaseBus(&I2CD1);
-
- return ret;
-}
-
-static void read_reg_n(uint8_t reg, uint8_t n, uint8_t *rxbuf)
-{
- uint8_t txbuf[1];
-
- i2cAcquireBus(&I2CD1);
-
- txbuf[0] = reg;
- i2cMasterTransmitTimeout(&I2CD1, STMPE811_ADDR, txbuf, 1, rxbuf, n, MS2ST(STMPE811_TIMEOUT));
-
- i2cReleaseBus(&I2CD1);
-}
-
-#endif /* _GINPUT_LLD_MOUSE_BOARD_H */
-/** @} */
|