Add named macros to the board joystick drivers where a shift is needed to maintain...
authorDean Camera <dean@fourwalledcubicle.com>
Tue, 15 Mar 2011 06:51:50 +0000 (06:51 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Tue, 15 Mar 2011 06:51:50 +0000 (06:51 +0000)
LUFA/Drivers/Board/EVK527/Joystick.h
LUFA/Drivers/Board/STK525/Joystick.h
LUFA/Drivers/Board/USBKEY/Joystick.h

index be8f35a..cab4423 100644 (file)
@@ -65,7 +65,9 @@
        #if !defined(__DOXYGEN__)
                /* Macros: */
                        #define JOY_FMASK                 ((1 << 4) | (1 << 5) | (1 << 6) | (1 << 7))
        #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: */
        #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_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)
 
                        /** Mask for the joystick being pushed inward. */
                        #define JOY_PRESS                 (1 << 6)
                        static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
                        static inline uint8_t Joystick_GetStatus(void)
                        {
                        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
 
                        }
                #endif
 
index c1dd362..c90e7a0 100644 (file)
@@ -66,6 +66,8 @@
                /* Macros: */
                        #define JOY_BMASK                 ((1 << 5) | (1 << 6) | (1 << 7))
                        #define JOY_EMASK                 ((1 << 4) | (1 << 5))
                /* 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: */
        #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_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)
 
                        /** Mask for the joystick being pushed inward. */
                        #define JOY_PRESS                 (1 << 5)
                        static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
                        static inline uint8_t Joystick_GetStatus(void)
                        {
                        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
 
                        }
                #endif
 
index 8ca5bc4..b8ae7bc 100644 (file)
@@ -66,6 +66,8 @@
                /* Macros: */
                        #define JOY_BMASK                 ((1 << 5) | (1 << 6) | (1 << 7))
                        #define JOY_EMASK                 ((1 << 4) | (1 << 5))
                /* 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: */
        #endif
 
        /* Public Interface - May be used in end-application: */
                        #define JOY_LEFT                  (1 << 6)
 
                        /** Mask for the joystick being pushed in the right direction. */
                        #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. */
 
                        /** 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)
 
                        /** Mask for the joystick being pushed inward. */
                        #define JOY_PRESS                 (1 << 5)
                        static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
                        static inline uint8_t Joystick_GetStatus(void)
                        {
                        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
 
                        }
                #endif