Update board driver common APIs to use uint_reg_t.
authorDean Camera <dean@fourwalledcubicle.com>
Sun, 20 Feb 2011 19:18:06 +0000 (19:18 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Sun, 20 Feb 2011 19:18:06 +0000 (19:18 +0000)
LUFA/Common/Common.h
LUFA/Drivers/Board/Buttons.h
LUFA/Drivers/Board/EVK1101/Buttons.h
LUFA/Drivers/Board/EVK1101/Joystick.h
LUFA/Drivers/Board/EVK1101/LEDs.h
LUFA/Drivers/Board/Joystick.h
LUFA/Drivers/Board/LEDs.h
LUFA/Drivers/Board/Temperature.c

index 4efa27e..a62cc7e 100644 (file)
                #include "BoardTypes.h"
                
        /* Architecture specific utility includes: */
                #include "BoardTypes.h"
                
        /* Architecture specific utility includes: */
-               #if (ARCH == ARCH_AVR8)
+               #if defined(__DOXYGEN__)
+                       /** Type define for an unsigned integer the same width as the selected architecture's machine register. */
+                       typedef MACHINE_REG_t uint_reg_t;
+               #elif (ARCH == ARCH_AVR8)
                        #include <avr/io.h>
                        #include <avr/interrupt.h>
                        #include <avr/pgmspace.h>
                        #include <avr/io.h>
                        #include <avr/interrupt.h>
                        #include <avr/pgmspace.h>
                        #include <util/atomic.h>
                        #include <util/delay.h>
                        
                        #include <util/atomic.h>
                        #include <util/delay.h>
                        
-                       typedef uint8_t uintN_t;
-                       typedef int8_t  intN_t;
+                       typedef uint8_t uint_reg_t;
                #elif (ARCH == ARCH_UC3B)
                        #include <avr32/io.h>
 
                #elif (ARCH == ARCH_UC3B)
                        #include <avr32/io.h>
 
-                       typedef uint32_t uintN_t;
-                       typedef int32_t  intN_t;
+                       typedef uint32_t uint_reg_t;
                        
                        #warning The UC3B architecture support is currently experimental and incomplete!
                #endif
                        
                        #warning The UC3B architecture support is currently experimental and incomplete!
                #endif
index d768c2e..b91c770 100644 (file)
        #endif
 
        /* Includes: */
        #endif
 
        /* Includes: */
-       #include "../../Common/Common.h"
+               #include "../../Common/Common.h"
 
 
-       #if (BOARD == BOARD_NONE)
-               #error The Board Buttons driver cannot be used if the makefile BOARD option is not set.
-       #elif (BOARD == BOARD_USBKEY)
-               #include "USBKEY/Buttons.h"
-       #elif (BOARD == BOARD_STK525)
-               #include "STK525/Buttons.h"
-       #elif (BOARD == BOARD_STK526)
-               #include "STK526/Buttons.h"
-       #elif (BOARD == BOARD_ATAVRUSBRF01)
-               #include "ATAVRUSBRF01/Buttons.h"
-       #elif (BOARD == BOARD_BUMBLEB)
-               #include "BUMBLEB/Buttons.h"
-       #elif (BOARD == BOARD_EVK527)
-               #include "EVK527/Buttons.h"
-       #elif (BOARD == BOARD_USBTINYMKII)
-               #include "USBTINYMKII/Buttons.h"
-       #elif (BOARD == BOARD_BENITO)
-               #include "BENITO/Buttons.h"
-       #elif (BOARD == BOARD_JMDBU2)
-               #include "JMDBU2/Buttons.h"
-       #elif (BOARD == BOARD_OLIMEX162)
-               #include "OLIMEX162/Buttons.h"
-       #elif (BOARD == BOARD_USBFOO)
-               #include "USBFOO/Buttons.h"
-       #elif (BOARD == BOARD_UDIP)
-               #include "UDIP/Buttons.h"
-       #elif (BOARD == BOARD_CULV3)
-               #include "CULV3/Buttons.h"
-       #elif (BOARD == BOARD_MINIMUS)
-               #include "MINIMUS/Buttons.h"
-       #elif (BOARD == BOARD_MICROSIN162)
-               #include "MICROSIN162/Buttons.h"
-       #elif (BOARD == BOARD_EVK1101)
-               #include "EVK1101/Buttons.h"
-       #else
-               #include "Board/Buttons.h"
-       #endif
+               #if (BOARD == BOARD_NONE)
+                       #error The Board Buttons driver cannot be used if the makefile BOARD option is not set.
+               #elif (BOARD == BOARD_USBKEY)
+                       #include "USBKEY/Buttons.h"
+               #elif (BOARD == BOARD_STK525)
+                       #include "STK525/Buttons.h"
+               #elif (BOARD == BOARD_STK526)
+                       #include "STK526/Buttons.h"
+               #elif (BOARD == BOARD_ATAVRUSBRF01)
+                       #include "ATAVRUSBRF01/Buttons.h"
+               #elif (BOARD == BOARD_BUMBLEB)
+                       #include "BUMBLEB/Buttons.h"
+               #elif (BOARD == BOARD_EVK527)
+                       #include "EVK527/Buttons.h"
+               #elif (BOARD == BOARD_USBTINYMKII)
+                       #include "USBTINYMKII/Buttons.h"
+               #elif (BOARD == BOARD_BENITO)
+                       #include "BENITO/Buttons.h"
+               #elif (BOARD == BOARD_JMDBU2)
+                       #include "JMDBU2/Buttons.h"
+               #elif (BOARD == BOARD_OLIMEX162)
+                       #include "OLIMEX162/Buttons.h"
+               #elif (BOARD == BOARD_USBFOO)
+                       #include "USBFOO/Buttons.h"
+               #elif (BOARD == BOARD_UDIP)
+                       #include "UDIP/Buttons.h"
+               #elif (BOARD == BOARD_CULV3)
+                       #include "CULV3/Buttons.h"
+               #elif (BOARD == BOARD_MINIMUS)
+                       #include "MINIMUS/Buttons.h"
+               #elif (BOARD == BOARD_MICROSIN162)
+                       #include "MICROSIN162/Buttons.h"
+               #elif (BOARD == BOARD_EVK1101)
+                       #include "EVK1101/Buttons.h"
+               #else
+                       #include "Board/Buttons.h"
+               #endif
 
 
-       /* Pseudo-Functions for Doxygen: */
-       #if defined(__DOXYGEN__)
-               /** Initialises the BUTTONS driver, so that the current button position can be read. This sets the appropriate
-                *  I/O pins to an inputs with pull-ups enabled.
-                *
-                *  This must be called before any Button driver functions are used.
-                */
-               static inline void Buttons_Init(void);
+               /* Pseudo-Functions for Doxygen: */
+               #if defined(__DOXYGEN__)
+                       /** Initialises the BUTTONS driver, so that the current button position can be read. This sets the appropriate
+                        *  I/O pins to an inputs with pull-ups enabled.
+                        *
+                        *  This must be called before any Button driver functions are used.
+                        */
+                       static inline void Buttons_Init(void);
 
 
-               /** Returns a mask indicating which board buttons are currently pressed.
-                *
-                *  \return Mask indicating which board buttons are currently pressed.
-                */
-               static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
-       #endif
+                       /** Returns a mask indicating which board buttons are currently pressed.
+                        *
+                        *  \return Mask indicating which board buttons are currently pressed.
+                        */
+                       static inline uint_reg_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
+               #endif
 
 #endif
 
 
 #endif
 
index e76bc52..51a4eaf 100644 (file)
                #if !defined(__DOXYGEN__)\r
                        static inline void Buttons_Init(void)\r
                        {\r
                #if !defined(__DOXYGEN__)\r
                        static inline void Buttons_Init(void)\r
                        {\r
-                               AVR32_GPIO.port[BUTTONS_PORT].gpers  = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2);\r
-                               AVR32_GPIO.port[BUTTONS_PORT].puers  = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2);\r
+                               AVR32_GPIO.port[BUTTONS_PORT].gpers = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2);\r
+                               AVR32_GPIO.port[BUTTONS_PORT].puers = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2);\r
                        }\r
 \r
                        }\r
 \r
-                       static inline uintN_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
-                       static inline uintN_t Buttons_GetStatus(void)\r
+                       static inline uint32_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+                       static inline uint32_t Buttons_GetStatus(void)\r
                        {\r
                                return (~(AVR32_GPIO.port[JOY_MOVE_PORT].pvr & (BUTTONS_BUTTON1 | BUTTONS_BUTTON2)));\r
                        }\r
                        {\r
                                return (~(AVR32_GPIO.port[JOY_MOVE_PORT].pvr & (BUTTONS_BUTTON1 | BUTTONS_BUTTON2)));\r
                        }\r
index 9bb7f6b..a27c29d 100644 (file)
                                AVR32_GPIO.port[JOY_PRESS_PORT].puers = JOY_PRESS_MASK;\r
                        };\r
                        \r
                                AVR32_GPIO.port[JOY_PRESS_PORT].puers = JOY_PRESS_MASK;\r
                        };\r
                        \r
-                       static inline uintN_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
-                       static inline uintN_t Joystick_GetStatus(void)\r
+                       static inline uint32_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+                       static inline uint32_t Joystick_GetStatus(void)\r
                        {\r
                        {\r
-                               return (uintN_t)(~(((AVR32_GPIO.port[JOY_MOVE_PORT].pvr  & JOY_MOVE_MASK) |\r
-                                                   (AVR32_GPIO.port[JOY_PRESS_PORT].pvr & JOY_PRESS_MASK)) << JOY_SHIFT_LEFT));\r
+                               return (uint32_t)(~(((AVR32_GPIO.port[JOY_MOVE_PORT].pvr  & JOY_MOVE_MASK) |\r
+                                                    (AVR32_GPIO.port[JOY_PRESS_PORT].pvr & JOY_PRESS_MASK)) << JOY_SHIFT_LEFT));\r
                        }\r
                #endif\r
 \r
                        }\r
                #endif\r
 \r
index 5eeaa7a..4dae3fb 100644 (file)
                                AVR32_GPIO.port[LEDS_PORT].ovrs  = LEDS_ALL_LEDS;\r
                        }\r
                        \r
                                AVR32_GPIO.port[LEDS_PORT].ovrs  = LEDS_ALL_LEDS;\r
                        }\r
                        \r
-                       static inline void LEDs_TurnOnLEDs(const uintN_t LedMask)\r
+                       static inline void LEDs_TurnOnLEDs(const uint32_t LedMask)\r
                        {\r
                                AVR32_GPIO.port[LEDS_PORT].ovrc  = LedMask;\r
                        }\r
 \r
                        {\r
                                AVR32_GPIO.port[LEDS_PORT].ovrc  = LedMask;\r
                        }\r
 \r
-                       static inline void LEDs_TurnOffLEDs(const uintN_t LedMask)\r
+                       static inline void LEDs_TurnOffLEDs(const uint32_t LedMask)\r
                        {\r
                                AVR32_GPIO.port[LEDS_PORT].ovrs  = LedMask;\r
                        }\r
 \r
                        {\r
                                AVR32_GPIO.port[LEDS_PORT].ovrs  = LedMask;\r
                        }\r
 \r
-                       static inline void LEDs_SetAllLEDs(const uintN_t LedMask)\r
+                       static inline void LEDs_SetAllLEDs(const uint32_t LedMask)\r
                        {\r
                                AVR32_GPIO.port[LEDS_PORT].ovrs  = LEDS_ALL_LEDS;\r
                                AVR32_GPIO.port[LEDS_PORT].ovrc  = LedMask;\r
                        }\r
                        \r
                        {\r
                                AVR32_GPIO.port[LEDS_PORT].ovrs  = LEDS_ALL_LEDS;\r
                                AVR32_GPIO.port[LEDS_PORT].ovrc  = LedMask;\r
                        }\r
                        \r
-                       static inline void LEDs_ChangeLEDs(const uintN_t LedMask, const uintN_t ActiveMask)\r
+                       static inline void LEDs_ChangeLEDs(const uint32_t LedMask, const uint32_t ActiveMask)\r
                        {\r
                                AVR32_GPIO.port[LEDS_PORT].ovrs  = LedMask;\r
                                AVR32_GPIO.port[LEDS_PORT].ovrc  = ActiveMask;\r
                        {\r
                                AVR32_GPIO.port[LEDS_PORT].ovrs  = LedMask;\r
                                AVR32_GPIO.port[LEDS_PORT].ovrc  = ActiveMask;\r
index 649b128..31ec3b8 100644 (file)
        #endif
 
        /* Includes: */
        #endif
 
        /* Includes: */
-       #include "../../Common/Common.h"
+               #include "../../Common/Common.h"
 
 
-       #if (BOARD == BOARD_NONE)
-               #error The Board Joystick driver cannot be used if the makefile BOARD option is not set.
-       #elif (BOARD == BOARD_USBKEY)
-               #include "USBKEY/Joystick.h"
-       #elif (BOARD == BOARD_STK525)
-               #include "STK525/Joystick.h"
-       #elif (BOARD == BOARD_STK526)
-               #include "STK526/Joystick.h"
-       #elif (BOARD == BOARD_BUMBLEB)
-               #include "BUMBLEB/Joystick.h"
-       #elif (BOARD == BOARD_EVK527)
-               #include "EVK527/Joystick.h"
-       #elif (BOARD == BOARD_EVK1101)
-               #include "EVK1101/Joystick.h"
-       #else
-               #include "Board/Joystick.h"
-       #endif
+               #if (BOARD == BOARD_NONE)
+                       #error The Board Joystick driver cannot be used if the makefile BOARD option is not set.
+               #elif (BOARD == BOARD_USBKEY)
+                       #include "USBKEY/Joystick.h"
+               #elif (BOARD == BOARD_STK525)
+                       #include "STK525/Joystick.h"
+               #elif (BOARD == BOARD_STK526)
+                       #include "STK526/Joystick.h"
+               #elif (BOARD == BOARD_BUMBLEB)
+                       #include "BUMBLEB/Joystick.h"
+               #elif (BOARD == BOARD_EVK527)
+                       #include "EVK527/Joystick.h"
+               #elif (BOARD == BOARD_EVK1101)
+                       #include "EVK1101/Joystick.h"
+               #else
+                       #include "Board/Joystick.h"
+               #endif
 
 
-       /* Pseudo-Functions for Doxygen: */
-       #if defined(__DOXYGEN__)
-               /** Initialises the joystick driver so that the joystick position can be read. This sets the appropriate
-                *  I/O pins to inputs with their pull-ups enabled.
-                */
-               static inline void Joystick_Init(void);
+               /* Pseudo-Functions for Doxygen: */
+               #if defined(__DOXYGEN__)
+                       /** Initialises the joystick driver so that the joystick position can be read. This sets the appropriate
+                        *  I/O pins to inputs with their pull-ups enabled.
+                        */
+                       static inline void Joystick_Init(void);
 
 
-               /** Returns the current status of the joystick, as a mask indicating the direction the joystick is
-                *  currently facing in (multiple bits can be set).
-                *
-                *  \return Mask indicating the joystick direction - see corresponding board specific Joystick.h file
-                *          for direction masks.
-                */
-               static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
-       #endif
+                       /** Returns the current status of the joystick, as a mask indicating the direction the joystick is
+                        *  currently facing in (multiple bits can be set).
+                        *
+                        *  \return Mask indicating the joystick direction - see corresponding board specific Joystick.h file
+                        *          for direction masks.
+                        */
+                       static inline uint_reg_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
+               #endif
 
 #endif
 
 
 #endif
 
index 3b250c0..173ed55 100644 (file)
                 *
                 *  \param[in] LEDMask  Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).
                 */
                 *
                 *  \param[in] LEDMask  Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).
                 */
-               static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask);
+               static inline void LEDs_TurnOnLEDs(const uint_reg_t LEDMask);
 
                /** Turns off the LEDs specified in the given LED mask.
                 *
                 *  \param[in] LEDMask  Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).
                 */
 
                /** Turns off the LEDs specified in the given LED mask.
                 *
                 *  \param[in] LEDMask  Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).
                 */
-               static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask);
+               static inline void LEDs_TurnOffLEDs(const uint_reg_t LEDMask);
 
                /** Turns off all LEDs not specified in the given LED mask, and turns on all the LEDs in the given LED
                 *  mask.
                 *
                 *  \param[in] LEDMask  Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).
                 */
 
                /** Turns off all LEDs not specified in the given LED mask, and turns on all the LEDs in the given LED
                 *  mask.
                 *
                 *  \param[in] LEDMask  Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).
                 */
-               static inline void LEDs_SetAllLEDs(const uint8_t LEDMask);
+               static inline void LEDs_SetAllLEDs(const uint_reg_t LEDMask);
 
                /** Turns off all LEDs in the LED mask that are not set in the active mask, and turns on all the LEDs
                 *  specified in both the LED and active masks.
 
                /** Turns off all LEDs in the LED mask that are not set in the active mask, and turns on all the LEDs
                 *  specified in both the LED and active masks.
                 *  \param[in] LEDMask     Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).
                 *  \param[in] ActiveMask  Mask of whether the LEDs in the LED mask should be turned on or off.
                 */
                 *  \param[in] LEDMask     Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).
                 *  \param[in] ActiveMask  Mask of whether the LEDs in the LED mask should be turned on or off.
                 */
-               static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,
-                                                  const uint8_t ActiveMask);
+               static inline void LEDs_ChangeLEDs(const uint_reg_t LEDMask,
+                                                  const uint_reg_t ActiveMask);
 
                /** Toggles all LEDs in the LED mask, leaving all others in their current states.
                 *
                 *  \param[in] LEDMask  Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).
                 */
 
                /** Toggles all LEDs in the LED mask, leaving all others in their current states.
                 *
                 *  \param[in] LEDMask  Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).
                 */
-               static inline void LEDs_ToggleLEDs(const uint8_t LEDMask);
+               static inline void LEDs_ToggleLEDs(const uint_reg_t LEDMask);
 
                /** Returns the status of all the board LEDs; set LED masks in the return value indicate that the
                 *  corresponding LED is on.
                 *
                 *  \return Mask of the board LEDs which are currently turned on.
                 */
 
                /** Returns the status of all the board LEDs; set LED masks in the return value indicate that the
                 *  corresponding LED is on.
                 *
                 *  \return Mask of the board LEDs which are currently turned on.
                 */
-               static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
+               static inline uint_reg_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
        #endif
 
 #endif
        #endif
 
 #endif
index 42b3937..b9b7adc 100644 (file)
 
 #include "Temperature.h"
 
 
 #include "Temperature.h"
 
-static const uint16_t PROGMEM Temperature_Lookup[TEMP_TABLE_SIZE] = {
-   0x3B4, 0x3B0, 0x3AB, 0x3A6, 0x3A0, 0x39A, 0x394, 0x38E, 0x388, 0x381, 0x37A, 0x373,
-   0x36B, 0x363, 0x35B, 0x353, 0x34A, 0x341, 0x338, 0x32F, 0x325, 0x31B, 0x311, 0x307,
-   0x2FC, 0x2F1, 0x2E6, 0x2DB, 0x2D0, 0x2C4, 0x2B8, 0x2AC, 0x2A0, 0x294, 0x288, 0x27C,
-   0x26F, 0x263, 0x256, 0x24A, 0x23D, 0x231, 0x225, 0x218, 0x20C, 0x200, 0x1F3, 0x1E7,
-   0x1DB, 0x1CF, 0x1C4, 0x1B8, 0x1AC, 0x1A1, 0x196, 0x18B, 0x180, 0x176, 0x16B, 0x161,
-   0x157, 0x14D, 0x144, 0x13A, 0x131, 0x128, 0x11F, 0x117, 0x10F, 0x106, 0x0FE, 0x0F7,
-   0x0EF, 0x0E8, 0x0E1, 0x0DA, 0x0D3, 0x0CD, 0x0C7, 0x0C0, 0x0BA, 0x0B5, 0x0AF, 0x0AA,
-   0x0A4, 0x09F, 0x09A, 0x096, 0x091, 0x08C, 0x088, 0x084, 0x080, 0x07C, 0x078, 0x074,
-   0x071, 0x06D, 0x06A, 0x067, 0x064, 0x061, 0x05E, 0x05B, 0x058, 0x055, 0x053, 0x050,
-   0x04E, 0x04C, 0x049, 0x047, 0x045, 0x043, 0x041, 0x03F, 0x03D, 0x03C, 0x03A, 0x038
-   };
+static const uint16_t PROGMEM Temperature_Lookup[TEMP_TABLE_SIZE] =
+{
+       0x3B4, 0x3B0, 0x3AB, 0x3A6, 0x3A0, 0x39A, 0x394, 0x38E, 0x388, 0x381, 0x37A, 0x373,
+       0x36B, 0x363, 0x35B, 0x353, 0x34A, 0x341, 0x338, 0x32F, 0x325, 0x31B, 0x311, 0x307,
+       0x2FC, 0x2F1, 0x2E6, 0x2DB, 0x2D0, 0x2C4, 0x2B8, 0x2AC, 0x2A0, 0x294, 0x288, 0x27C,
+       0x26F, 0x263, 0x256, 0x24A, 0x23D, 0x231, 0x225, 0x218, 0x20C, 0x200, 0x1F3, 0x1E7,
+       0x1DB, 0x1CF, 0x1C4, 0x1B8, 0x1AC, 0x1A1, 0x196, 0x18B, 0x180, 0x176, 0x16B, 0x161,
+       0x157, 0x14D, 0x144, 0x13A, 0x131, 0x128, 0x11F, 0x117, 0x10F, 0x106, 0x0FE, 0x0F7,
+       0x0EF, 0x0E8, 0x0E1, 0x0DA, 0x0D3, 0x0CD, 0x0C7, 0x0C0, 0x0BA, 0x0B5, 0x0AF, 0x0AA,
+       0x0A4, 0x09F, 0x09A, 0x096, 0x091, 0x08C, 0x088, 0x084, 0x080, 0x07C, 0x078, 0x074,
+       0x071, 0x06D, 0x06A, 0x067, 0x064, 0x061, 0x05E, 0x05B, 0x058, 0x055, 0x053, 0x050,
+       0x04E, 0x04C, 0x049, 0x047, 0x045, 0x043, 0x041, 0x03F, 0x03D, 0x03C, 0x03A, 0x038
+};
 
 int8_t Temperature_GetTemperature(void)
 {
 
 int8_t Temperature_GetTemperature(void)
 {