Update board driver common APIs to use uint_reg_t.

pull/1469/head
Dean Camera 14 years ago
parent 86be7f9330
commit a318f32b31

@ -74,7 +74,10 @@
#include "BoardTypes.h" #include "BoardTypes.h"
/* Architecture specific utility includes: */ /* 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/io.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
@ -83,13 +86,11 @@
#include <util/atomic.h> #include <util/atomic.h>
#include <util/delay.h> #include <util/delay.h>
typedef uint8_t uintN_t; typedef uint8_t uint_reg_t;
typedef int8_t intN_t;
#elif (ARCH == ARCH_UC3B) #elif (ARCH == ARCH_UC3B)
#include <avr32/io.h> #include <avr32/io.h>
typedef uint32_t uintN_t; typedef uint32_t uint_reg_t;
typedef int32_t intN_t;
#warning The UC3B architecture support is currently experimental and incomplete! #warning The UC3B architecture support is currently experimental and incomplete!
#endif #endif

@ -92,61 +92,61 @@
#endif #endif
/* Includes: */ /* Includes: */
#include "../../Common/Common.h" #include "../../Common/Common.h"
#if (BOARD == BOARD_NONE) #if (BOARD == BOARD_NONE)
#error The Board Buttons driver cannot be used if the makefile BOARD option is not set. #error The Board Buttons driver cannot be used if the makefile BOARD option is not set.
#elif (BOARD == BOARD_USBKEY) #elif (BOARD == BOARD_USBKEY)
#include "USBKEY/Buttons.h" #include "USBKEY/Buttons.h"
#elif (BOARD == BOARD_STK525) #elif (BOARD == BOARD_STK525)
#include "STK525/Buttons.h" #include "STK525/Buttons.h"
#elif (BOARD == BOARD_STK526) #elif (BOARD == BOARD_STK526)
#include "STK526/Buttons.h" #include "STK526/Buttons.h"
#elif (BOARD == BOARD_ATAVRUSBRF01) #elif (BOARD == BOARD_ATAVRUSBRF01)
#include "ATAVRUSBRF01/Buttons.h" #include "ATAVRUSBRF01/Buttons.h"
#elif (BOARD == BOARD_BUMBLEB) #elif (BOARD == BOARD_BUMBLEB)
#include "BUMBLEB/Buttons.h" #include "BUMBLEB/Buttons.h"
#elif (BOARD == BOARD_EVK527) #elif (BOARD == BOARD_EVK527)
#include "EVK527/Buttons.h" #include "EVK527/Buttons.h"
#elif (BOARD == BOARD_USBTINYMKII) #elif (BOARD == BOARD_USBTINYMKII)
#include "USBTINYMKII/Buttons.h" #include "USBTINYMKII/Buttons.h"
#elif (BOARD == BOARD_BENITO) #elif (BOARD == BOARD_BENITO)
#include "BENITO/Buttons.h" #include "BENITO/Buttons.h"
#elif (BOARD == BOARD_JMDBU2) #elif (BOARD == BOARD_JMDBU2)
#include "JMDBU2/Buttons.h" #include "JMDBU2/Buttons.h"
#elif (BOARD == BOARD_OLIMEX162) #elif (BOARD == BOARD_OLIMEX162)
#include "OLIMEX162/Buttons.h" #include "OLIMEX162/Buttons.h"
#elif (BOARD == BOARD_USBFOO) #elif (BOARD == BOARD_USBFOO)
#include "USBFOO/Buttons.h" #include "USBFOO/Buttons.h"
#elif (BOARD == BOARD_UDIP) #elif (BOARD == BOARD_UDIP)
#include "UDIP/Buttons.h" #include "UDIP/Buttons.h"
#elif (BOARD == BOARD_CULV3) #elif (BOARD == BOARD_CULV3)
#include "CULV3/Buttons.h" #include "CULV3/Buttons.h"
#elif (BOARD == BOARD_MINIMUS) #elif (BOARD == BOARD_MINIMUS)
#include "MINIMUS/Buttons.h" #include "MINIMUS/Buttons.h"
#elif (BOARD == BOARD_MICROSIN162) #elif (BOARD == BOARD_MICROSIN162)
#include "MICROSIN162/Buttons.h" #include "MICROSIN162/Buttons.h"
#elif (BOARD == BOARD_EVK1101) #elif (BOARD == BOARD_EVK1101)
#include "EVK1101/Buttons.h" #include "EVK1101/Buttons.h"
#else #else
#include "Board/Buttons.h" #include "Board/Buttons.h"
#endif #endif
/* Pseudo-Functions for Doxygen: */ /* Pseudo-Functions for Doxygen: */
#if defined(__DOXYGEN__) #if defined(__DOXYGEN__)
/** Initialises the BUTTONS driver, so that the current button position can be read. This sets the appropriate /** 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. * I/O pins to an inputs with pull-ups enabled.
* *
* This must be called before any Button driver functions are used. * This must be called before any Button driver functions are used.
*/ */
static inline void Buttons_Init(void); static inline void Buttons_Init(void);
/** Returns a mask indicating which board buttons are currently pressed. /** Returns a mask indicating which board buttons are currently pressed.
* *
* \return 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; static inline uint_reg_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
#endif #endif
#endif #endif

@ -82,12 +82,12 @@
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
static inline void Buttons_Init(void) static inline void Buttons_Init(void)
{ {
AVR32_GPIO.port[BUTTONS_PORT].gpers = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2); AVR32_GPIO.port[BUTTONS_PORT].gpers = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2);
AVR32_GPIO.port[BUTTONS_PORT].puers = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2); AVR32_GPIO.port[BUTTONS_PORT].puers = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2);
} }
static inline uintN_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT; static inline uint32_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline uintN_t Buttons_GetStatus(void) static inline uint32_t Buttons_GetStatus(void)
{ {
return (~(AVR32_GPIO.port[JOY_MOVE_PORT].pvr & (BUTTONS_BUTTON1 | BUTTONS_BUTTON2))); return (~(AVR32_GPIO.port[JOY_MOVE_PORT].pvr & (BUTTONS_BUTTON1 | BUTTONS_BUTTON2)));
} }

@ -102,11 +102,11 @@
AVR32_GPIO.port[JOY_PRESS_PORT].puers = JOY_PRESS_MASK; AVR32_GPIO.port[JOY_PRESS_PORT].puers = JOY_PRESS_MASK;
}; };
static inline uintN_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; static inline uint32_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline uintN_t Joystick_GetStatus(void) static inline uint32_t Joystick_GetStatus(void)
{ {
return (uintN_t)(~(((AVR32_GPIO.port[JOY_MOVE_PORT].pvr & JOY_MOVE_MASK) | return (uint32_t)(~(((AVR32_GPIO.port[JOY_MOVE_PORT].pvr & JOY_MOVE_MASK) |
(AVR32_GPIO.port[JOY_PRESS_PORT].pvr & JOY_PRESS_MASK)) << JOY_SHIFT_LEFT)); (AVR32_GPIO.port[JOY_PRESS_PORT].pvr & JOY_PRESS_MASK)) << JOY_SHIFT_LEFT));
} }
#endif #endif

@ -98,23 +98,23 @@
AVR32_GPIO.port[LEDS_PORT].ovrs = LEDS_ALL_LEDS; AVR32_GPIO.port[LEDS_PORT].ovrs = LEDS_ALL_LEDS;
} }
static inline void LEDs_TurnOnLEDs(const uintN_t LedMask) static inline void LEDs_TurnOnLEDs(const uint32_t LedMask)
{ {
AVR32_GPIO.port[LEDS_PORT].ovrc = LedMask; AVR32_GPIO.port[LEDS_PORT].ovrc = LedMask;
} }
static inline void LEDs_TurnOffLEDs(const uintN_t LedMask) static inline void LEDs_TurnOffLEDs(const uint32_t LedMask)
{ {
AVR32_GPIO.port[LEDS_PORT].ovrs = LedMask; AVR32_GPIO.port[LEDS_PORT].ovrs = LedMask;
} }
static inline void LEDs_SetAllLEDs(const uintN_t LedMask) static inline void LEDs_SetAllLEDs(const uint32_t LedMask)
{ {
AVR32_GPIO.port[LEDS_PORT].ovrs = LEDS_ALL_LEDS; AVR32_GPIO.port[LEDS_PORT].ovrs = LEDS_ALL_LEDS;
AVR32_GPIO.port[LEDS_PORT].ovrc = LedMask; AVR32_GPIO.port[LEDS_PORT].ovrc = LedMask;
} }
static inline void LEDs_ChangeLEDs(const uintN_t LedMask, const uintN_t ActiveMask) static inline void LEDs_ChangeLEDs(const uint32_t LedMask, const uint32_t ActiveMask)
{ {
AVR32_GPIO.port[LEDS_PORT].ovrs = LedMask; AVR32_GPIO.port[LEDS_PORT].ovrs = LedMask;
AVR32_GPIO.port[LEDS_PORT].ovrc = ActiveMask; AVR32_GPIO.port[LEDS_PORT].ovrc = ActiveMask;

@ -100,41 +100,41 @@
#endif #endif
/* Includes: */ /* Includes: */
#include "../../Common/Common.h" #include "../../Common/Common.h"
#if (BOARD == BOARD_NONE) #if (BOARD == BOARD_NONE)
#error The Board Joystick driver cannot be used if the makefile BOARD option is not set. #error The Board Joystick driver cannot be used if the makefile BOARD option is not set.
#elif (BOARD == BOARD_USBKEY) #elif (BOARD == BOARD_USBKEY)
#include "USBKEY/Joystick.h" #include "USBKEY/Joystick.h"
#elif (BOARD == BOARD_STK525) #elif (BOARD == BOARD_STK525)
#include "STK525/Joystick.h" #include "STK525/Joystick.h"
#elif (BOARD == BOARD_STK526) #elif (BOARD == BOARD_STK526)
#include "STK526/Joystick.h" #include "STK526/Joystick.h"
#elif (BOARD == BOARD_BUMBLEB) #elif (BOARD == BOARD_BUMBLEB)
#include "BUMBLEB/Joystick.h" #include "BUMBLEB/Joystick.h"
#elif (BOARD == BOARD_EVK527) #elif (BOARD == BOARD_EVK527)
#include "EVK527/Joystick.h" #include "EVK527/Joystick.h"
#elif (BOARD == BOARD_EVK1101) #elif (BOARD == BOARD_EVK1101)
#include "EVK1101/Joystick.h" #include "EVK1101/Joystick.h"
#else #else
#include "Board/Joystick.h" #include "Board/Joystick.h"
#endif #endif
/* Pseudo-Functions for Doxygen: */ /* Pseudo-Functions for Doxygen: */
#if defined(__DOXYGEN__) #if defined(__DOXYGEN__)
/** Initialises the joystick driver so that the joystick position can be read. This sets the appropriate /** 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. * I/O pins to inputs with their pull-ups enabled.
*/ */
static inline void Joystick_Init(void); static inline void Joystick_Init(void);
/** Returns the current status of the joystick, as a mask indicating the direction the joystick is /** Returns the current status of the joystick, as a mask indicating the direction the joystick is
* currently facing in (multiple bits can be set). * currently facing in (multiple bits can be set).
* *
* \return Mask indicating the joystick direction - see corresponding board specific Joystick.h file * \return Mask indicating the joystick direction - see corresponding board specific Joystick.h file
* for direction masks. * for direction masks.
*/ */
static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; static inline uint_reg_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
#endif #endif
#endif #endif

@ -199,20 +199,20 @@
* *
* \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. /** 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). * \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 /** Turns off all LEDs not specified in the given LED mask, and turns on all the LEDs in the given LED
* mask. * mask.
* *
* \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_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 /** 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. * specified in both the LED and active masks.
@ -220,21 +220,21 @@
* \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).
* \param[in] ActiveMask Mask of whether the LEDs in the LED mask should be turned on or off. * \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, static inline void LEDs_ChangeLEDs(const uint_reg_t LEDMask,
const uint8_t ActiveMask); const uint_reg_t ActiveMask);
/** Toggles all LEDs in the LED mask, leaving all others in their current states. /** 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). * \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 /** Returns the status of all the board LEDs; set LED masks in the return value indicate that the
* corresponding LED is on. * corresponding LED is on.
* *
* \return Mask of the board LEDs which are currently turned 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

@ -30,18 +30,19 @@
#include "Temperature.h" #include "Temperature.h"
static const uint16_t PROGMEM Temperature_Lookup[TEMP_TABLE_SIZE] = { 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, 0x3B4, 0x3B0, 0x3AB, 0x3A6, 0x3A0, 0x39A, 0x394, 0x38E, 0x388, 0x381, 0x37A, 0x373,
0x2FC, 0x2F1, 0x2E6, 0x2DB, 0x2D0, 0x2C4, 0x2B8, 0x2AC, 0x2A0, 0x294, 0x288, 0x27C, 0x36B, 0x363, 0x35B, 0x353, 0x34A, 0x341, 0x338, 0x32F, 0x325, 0x31B, 0x311, 0x307,
0x26F, 0x263, 0x256, 0x24A, 0x23D, 0x231, 0x225, 0x218, 0x20C, 0x200, 0x1F3, 0x1E7, 0x2FC, 0x2F1, 0x2E6, 0x2DB, 0x2D0, 0x2C4, 0x2B8, 0x2AC, 0x2A0, 0x294, 0x288, 0x27C,
0x1DB, 0x1CF, 0x1C4, 0x1B8, 0x1AC, 0x1A1, 0x196, 0x18B, 0x180, 0x176, 0x16B, 0x161, 0x26F, 0x263, 0x256, 0x24A, 0x23D, 0x231, 0x225, 0x218, 0x20C, 0x200, 0x1F3, 0x1E7,
0x157, 0x14D, 0x144, 0x13A, 0x131, 0x128, 0x11F, 0x117, 0x10F, 0x106, 0x0FE, 0x0F7, 0x1DB, 0x1CF, 0x1C4, 0x1B8, 0x1AC, 0x1A1, 0x196, 0x18B, 0x180, 0x176, 0x16B, 0x161,
0x0EF, 0x0E8, 0x0E1, 0x0DA, 0x0D3, 0x0CD, 0x0C7, 0x0C0, 0x0BA, 0x0B5, 0x0AF, 0x0AA, 0x157, 0x14D, 0x144, 0x13A, 0x131, 0x128, 0x11F, 0x117, 0x10F, 0x106, 0x0FE, 0x0F7,
0x0A4, 0x09F, 0x09A, 0x096, 0x091, 0x08C, 0x088, 0x084, 0x080, 0x07C, 0x078, 0x074, 0x0EF, 0x0E8, 0x0E1, 0x0DA, 0x0D3, 0x0CD, 0x0C7, 0x0C0, 0x0BA, 0x0B5, 0x0AF, 0x0AA,
0x071, 0x06D, 0x06A, 0x067, 0x064, 0x061, 0x05E, 0x05B, 0x058, 0x055, 0x053, 0x050, 0x0A4, 0x09F, 0x09A, 0x096, 0x091, 0x08C, 0x088, 0x084, 0x080, 0x07C, 0x078, 0x074,
0x04E, 0x04C, 0x049, 0x047, 0x045, 0x043, 0x041, 0x03F, 0x03D, 0x03C, 0x03A, 0x038 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)
{ {

Loading…
Cancel
Save