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"
/* 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>
@ -83,13 +86,11 @@
#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>
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

@ -92,61 +92,61 @@
#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

@ -82,12 +82,12 @@
#if !defined(__DOXYGEN__)
static inline void Buttons_Init(void)
{
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].gpers = (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 uintN_t Buttons_GetStatus(void)
static inline uint32_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline uint32_t Buttons_GetStatus(void)
{
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;
};
static inline uintN_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline uintN_t Joystick_GetStatus(void)
static inline uint32_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline uint32_t Joystick_GetStatus(void)
{
return (uintN_t)(~(((AVR32_GPIO.port[JOY_MOVE_PORT].pvr & JOY_MOVE_MASK) |
(AVR32_GPIO.port[JOY_PRESS_PORT].pvr & JOY_PRESS_MASK)) << JOY_SHIFT_LEFT));
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));
}
#endif

@ -98,23 +98,23 @@
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;
}
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;
}
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].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].ovrc = ActiveMask;

@ -100,41 +100,41 @@
#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

@ -199,20 +199,20 @@
*
* \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).
*/
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).
*/
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.
@ -220,21 +220,21 @@
* \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).
*/
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.
*/
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

@ -30,18 +30,19 @@
#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)
{

Loading…
Cancel
Save