aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ginput
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ginput')
-rw-r--r--drivers/ginput/toggle/Pal/ginput_lld_toggle.c6
-rw-r--r--drivers/ginput/toggle/Pal/ginput_lld_toggle_board_example.h57
-rw-r--r--drivers/ginput/toggle/Pal/ginput_lld_toggle_board_olimexsam7ex256.h26
-rw-r--r--drivers/ginput/toggle/Pal/ginput_lld_toggle_config.h5
-rw-r--r--drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h10
5 files changed, 49 insertions, 55 deletions
diff --git a/drivers/ginput/toggle/Pal/ginput_lld_toggle.c b/drivers/ginput/toggle/Pal/ginput_lld_toggle.c
index 560d11b9..a3a360d8 100644
--- a/drivers/ginput/toggle/Pal/ginput_lld_toggle.c
+++ b/drivers/ginput/toggle/Pal/ginput_lld_toggle.c
@@ -28,13 +28,13 @@
#include "ch.h"
#include "hal.h"
+#include "gfx.h"
#if (GFX_USE_GINPUT && GINPUT_NEED_TOGGLE) /*|| defined(__DOXYGEN__)*/
-// Declare the static members in the following include file
-#define GINPUT_TOGGLE_DECLARE_CONFIG
+#include "ginput/lld/toggle.h"
-#include "lld/ginput/toggle.h"
+GINPUT_TOGGLE_DECLARE_STRUCTURE();
/**
* @brief Initialise the port.
diff --git a/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_example.h b/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_example.h
index 46d32b47..a96178b0 100644
--- a/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_example.h
+++ b/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_example.h
@@ -29,37 +29,32 @@
#ifndef _GDISP_LLD_TOGGLE_BOARD_H
#define _GDISP_LLD_TOGGLE_BOARD_H
-#ifndef _GINPUT_LLD_TOGGLE_CONFIG_H
- // Visible in ginput.h
-
- #define GINPUT_TOGGLE_SW1 0 // Switch 1
- #define GINPUT_TOGGLE_SW2 1 // Switch 2
- #define GINPUT_TOGGLE_UP 2 // Joystick Up
- #define GINPUT_TOGGLE_DOWN 3 // Joystick Down
- #define GINPUT_TOGGLE_LEFT 4 // Joystick Left
- #define GINPUT_TOGGLE_RIGHT 5 // Joystick Right
- #define GINPUT_TOGGLE_CENTER 6 // Joystick Center
-
-#elif !defined(GINPUT_TOGGLE_DECLARE_CONFIG)
- // Visible in ginput_lld.h
-
- #define GINPUT_TOGGLE_NUM_PORTS 7 // The total number of toggle inputs
-
-#else
- // Visible in ginput_lld_toggle.c
-
- GToggleConfig GInputToggleConfigTable[] = {
- {AT91C_BASE_PIOB, // Switch 1 and Switch 2
- PIOB_SW1_MASK|PIOB_SW2_MASK,
- PIOB_SW1_MASK|PIOB_SW2_MASK,
- PAL_MODE_INPUT},
- {AT91C_BASE_PIOA, // B1..4 Joystick
- PIOA_B1_MASK|PIOA_B2_MASK|PIOA_B3_MASK|PIOA_B4_MASK|PIOA_B5_MASK,
- PIOA_B1_MASK|PIOA_B2_MASK|PIOA_B3_MASK|PIOA_B4_MASK|PIOA_B5_MASK,
- PAL_MODE_INPUT},
- };
-
-#endif
+#error "GINPUT Toggle Pal Driver: You need to define your board definitions"
+
+// The below are example values
+
+#define GINPUT_TOGGLE_NUM_PORTS 7 // The total number of toggle inputs
+#define GINPUT_TOGGLE_CONFIG_ENTRIES 2 // The total number of GToggleConfig entries
+
+#define GINPUT_TOGGLE_SW1 0 // Switch 1
+#define GINPUT_TOGGLE_SW2 1 // Switch 2
+#define GINPUT_TOGGLE_UP 2 // Joystick Up
+#define GINPUT_TOGGLE_DOWN 3 // Joystick Down
+#define GINPUT_TOGGLE_LEFT 4 // Joystick Left
+#define GINPUT_TOGGLE_RIGHT 5 // Joystick Right
+#define GINPUT_TOGGLE_CENTER 6 // Joystick Center
+
+#define GINPUT_TOGGLE_DECLARE_STRUCTURE() \
+ const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES] = { \
+ {AT91C_BASE_PIOB, /* Switch 1 and Switch 2 */ \
+ PIOB_SW1_MASK|PIOB_SW2_MASK, \
+ PIOB_SW1_MASK|PIOB_SW2_MASK, \
+ PAL_MODE_INPUT}, \
+ {AT91C_BASE_PIOA, /* B1..4 Joystick */ \
+ PIOA_B1_MASK|PIOA_B2_MASK|PIOA_B3_MASK|PIOA_B4_MASK|PIOA_B5_MASK, \
+ PIOA_B1_MASK|PIOA_B2_MASK|PIOA_B3_MASK|PIOA_B4_MASK|PIOA_B5_MASK, \
+ PAL_MODE_INPUT}, \
+ }
#endif /* _GDISP_LLD_TOGGLE_BOARD_H */
/** @} */
diff --git a/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_olimexsam7ex256.h b/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_olimexsam7ex256.h
index b767f32c..3ba5858d 100644
--- a/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_olimexsam7ex256.h
+++ b/drivers/ginput/toggle/Pal/ginput_lld_toggle_board_olimexsam7ex256.h
@@ -40,21 +40,17 @@
#define GINPUT_TOGGLE_RIGHT 5 // Joystick Right
#define GINPUT_TOGGLE_CENTER 6 // Joystick Center
-#ifdef GINPUT_TOGGLE_DECLARE_CONFIG
- // Visible in ginput_lld_toggle.c
-
- const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES] = {
- {AT91C_BASE_PIOB, // Switch 1 and Switch 2
- PIOB_SW1_MASK|PIOB_SW2_MASK,
- PIOB_SW1_MASK|PIOB_SW2_MASK,
- PAL_MODE_INPUT},
- {AT91C_BASE_PIOA, // B1..4 Joystick
- PIOA_B1_MASK|PIOA_B2_MASK|PIOA_B3_MASK|PIOA_B4_MASK|PIOA_B5_MASK,
- PIOA_B1_MASK|PIOA_B2_MASK|PIOA_B3_MASK|PIOA_B4_MASK|PIOA_B5_MASK,
- PAL_MODE_INPUT},
- };
-
-#endif
+#define GINPUT_TOGGLE_DECLARE_STRUCTURE() \
+ const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES] = { \
+ {AT91C_BASE_PIOB, /* Switch 1 and Switch 2 */ \
+ PIOB_SW1_MASK|PIOB_SW2_MASK, \
+ PIOB_SW1_MASK|PIOB_SW2_MASK, \
+ PAL_MODE_INPUT}, \
+ {AT91C_BASE_PIOA, /* B1..4 Joystick */ \
+ PIOA_B1_MASK|PIOA_B2_MASK|PIOA_B3_MASK|PIOA_B4_MASK|PIOA_B5_MASK, \
+ PIOA_B1_MASK|PIOA_B2_MASK|PIOA_B3_MASK|PIOA_B4_MASK|PIOA_B5_MASK, \
+ PAL_MODE_INPUT}, \
+ }
#endif /* _GDISP_LLD_TOGGLE_BOARD_H */
/** @} */
diff --git a/drivers/ginput/toggle/Pal/ginput_lld_toggle_config.h b/drivers/ginput/toggle/Pal/ginput_lld_toggle_config.h
index a3fcf22e..774be200 100644
--- a/drivers/ginput/toggle/Pal/ginput_lld_toggle_config.h
+++ b/drivers/ginput/toggle/Pal/ginput_lld_toggle_config.h
@@ -31,7 +31,10 @@
#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE
-#if defined(BOARD_OLIMEX_SAM7_EX256)
+#if GINPUT_TOGGLE_USE_CUSTOM_BOARD
+ /* Include the user supplied board definitions */
+ #include "ginput_lld_toggle_board.h"
+#elif defined(BOARD_OLIMEX_SAM7_EX256)
#include "ginput_lld_toggle_board_olimexsam7ex256.h"
#else
/* Include the user supplied board definitions */
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
index fa3dca7e..2fa6fe44 100644
--- 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
@@ -105,7 +105,7 @@ static __inline void release_bus(void) {
*
* @notapi
*/
-static uint16_t read_x_value(void) {
+static __inline uint16_t read_x_value(void) {
uint16_t val1, val2;
adcsample_t samples[ADC_NUM_CHANNELS * ADC_BUF_DEPTH];
@@ -113,7 +113,7 @@ static uint16_t read_x_value(void) {
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);
chThdSleepMilliseconds(1);
@@ -135,7 +135,7 @@ static uint16_t read_x_value(void) {
*
* @notapi
*/
-static uint16_t read_y_value(void) {
+static __inline uint16_t read_y_value(void) {
uint16_t val1, val2;
adcsample_t samples[ADC_NUM_CHANNELS * ADC_BUF_DEPTH];
@@ -143,8 +143,8 @@ static uint16_t read_y_value(void) {
palSetPadMode(GPIOC, 3, PAL_MODE_INPUT_ANALOG);
palSetPadMode(GPIOC, 0, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(GPIOC, 1, PAL_MODE_OUTPUT_PUSHPULL);
-
- palSetPad(GPIOC, 1);
+
+ palSetPad(GPIOC, 1);
palClearPad(GPIOC, 0);
chThdSleepMilliseconds(1);
adcConvert(&ADCD1, &adc_y_config, samples, ADC_BUF_DEPTH);