aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2011-03-15 06:51:50 +0000
committerDean Camera <dean@fourwalledcubicle.com>2011-03-15 06:51:50 +0000
commit95a1aa4c016829ebd7b641e8871ba123d36d49a4 (patch)
tree315e91e56f274c4b9a9ea0f75aed56eb4b6ce5b6 /LUFA
parentb35f93a372d8c872aebab4e3626bfc58d85b84d7 (diff)
downloadlufa-95a1aa4c016829ebd7b641e8871ba123d36d49a4.tar.gz
lufa-95a1aa4c016829ebd7b641e8871ba123d36d49a4.tar.bz2
lufa-95a1aa4c016829ebd7b641e8871ba123d36d49a4.zip
Add named macros to the board joystick drivers where a shift is needed to maintain unique joystick direction bits in the returned mask value.
Diffstat (limited to 'LUFA')
-rw-r--r--LUFA/Drivers/Board/EVK527/Joystick.h8
-rw-r--r--LUFA/Drivers/Board/STK525/Joystick.h6
-rw-r--r--LUFA/Drivers/Board/USBKEY/Joystick.h8
3 files changed, 14 insertions, 8 deletions
diff --git a/LUFA/Drivers/Board/EVK527/Joystick.h b/LUFA/Drivers/Board/EVK527/Joystick.h
index be8f35aa3..cab4423ed 100644
--- a/LUFA/Drivers/Board/EVK527/Joystick.h
+++ b/LUFA/Drivers/Board/EVK527/Joystick.h
@@ -65,7 +65,9 @@
#if !defined(__DOXYGEN__)
/* Macros: */
#define JOY_FMASK ((1 << 4) | (1 << 5) | (1 << 6) | (1 << 7))
- #define JOY_CMASK (1 << 6))
+ #define JOY_CMASK (1 << 6)
+
+ #define JOY_PORTC_MASK_SHIFT 3
#endif
/* Public Interface - May be used in end-application: */
@@ -80,7 +82,7 @@
#define JOY_UP (1 << 5)
/** Mask for the joystick being pushed in the downward direction. */
- #define JOY_DOWN ((1 << 6) >> 3)
+ #define JOY_DOWN ((1 << 6) >> JOY_PORTC_MASK_SHIFT)
/** Mask for the joystick being pushed inward. */
#define JOY_PRESS (1 << 6)
@@ -99,7 +101,7 @@
static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline uint8_t Joystick_GetStatus(void)
{
- return (((uint8_t)~PINF & JOY_FMASK) | (((uint8_t)~PINC & JOY_CMASK) >> 3));
+ return (((uint8_t)~PINF & JOY_FMASK) | (((uint8_t)~PINC & JOY_CMASK) >> JOY_PORTC_MASK_SHIFT));
}
#endif
diff --git a/LUFA/Drivers/Board/STK525/Joystick.h b/LUFA/Drivers/Board/STK525/Joystick.h
index c1dd3623e..c90e7a0d2 100644
--- a/LUFA/Drivers/Board/STK525/Joystick.h
+++ b/LUFA/Drivers/Board/STK525/Joystick.h
@@ -66,6 +66,8 @@
/* Macros: */
#define JOY_BMASK ((1 << 5) | (1 << 6) | (1 << 7))
#define JOY_EMASK ((1 << 4) | (1 << 5))
+
+ #define JOY_PORTE_MASK_SHIFT 1
#endif
/* Public Interface - May be used in end-application: */
@@ -80,7 +82,7 @@
#define JOY_UP (1 << 7)
/** Mask for the joystick being pushed in the downward direction. */
- #define JOY_DOWN ((1 << 5) >> 1)
+ #define JOY_DOWN ((1 << 5) >> JOY_PORTE_MASK_SHIFT)
/** Mask for the joystick being pushed inward. */
#define JOY_PRESS (1 << 5)
@@ -99,7 +101,7 @@
static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline uint8_t Joystick_GetStatus(void)
{
- return (((uint8_t)~PINB & JOY_BMASK) | (((uint8_t)~PINE & JOY_EMASK) >> 1));
+ return (((uint8_t)~PINB & JOY_BMASK) | (((uint8_t)~PINE & JOY_EMASK) >> JOY_PORTE_MASK_SHIFT));
}
#endif
diff --git a/LUFA/Drivers/Board/USBKEY/Joystick.h b/LUFA/Drivers/Board/USBKEY/Joystick.h
index 8ca5bc45f..b8ae7bc3e 100644
--- a/LUFA/Drivers/Board/USBKEY/Joystick.h
+++ b/LUFA/Drivers/Board/USBKEY/Joystick.h
@@ -66,6 +66,8 @@
/* Macros: */
#define JOY_BMASK ((1 << 5) | (1 << 6) | (1 << 7))
#define JOY_EMASK ((1 << 4) | (1 << 5))
+
+ #define JOY_PORTE_MASK_SHIFT 1
#endif
/* Public Interface - May be used in end-application: */
@@ -74,13 +76,13 @@
#define JOY_LEFT (1 << 6)
/** Mask for the joystick being pushed in the right direction. */
- #define JOY_RIGHT ((1 << 4) >> 1)
+ #define JOY_RIGHT ((1 << 4) >> JOY_PORTE_MASK_SHIFT)
/** Mask for the joystick being pushed in the upward direction. */
#define JOY_UP (1 << 7)
/** Mask for the joystick being pushed in the downward direction. */
- #define JOY_DOWN ((1 << 5) >> 1)
+ #define JOY_DOWN ((1 << 5) >> JOY_PORTE_MASK_SHIFT)
/** Mask for the joystick being pushed inward. */
#define JOY_PRESS (1 << 5)
@@ -99,7 +101,7 @@
static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline uint8_t Joystick_GetStatus(void)
{
- return (((uint8_t)~PINB & JOY_BMASK) | (((uint8_t)~PINE & JOY_EMASK) >> 1));
+ return (((uint8_t)~PINB & JOY_BMASK) | (((uint8_t)~PINE & JOY_EMASK) >> JOY_PORTE_MASK_SHIFT));
}
#endif