LUFA Library 110528
Common Utility Headers - LUFA/Drivers/Common/Common.h

Common library convenience headers, macros and functions. More...

Modules

 Hardware Architectures
 

Supported library architecture defines.


 Function/Variable Attributes
 

GCC special function/variable attribute macros.


 Board Types
 

Supported pre-made board hardware defines.


 Debugging Macros
 

Convenience macros to aid in debugging applications.


 Global Interrupt Macros
 

Convenience macros for the management of interrupts globally within the device.


 Endianness and Byte Ordering
 

Convenience macros and functions relating to byte (re-)ordering.


Defines

#define MACROS   do
#define MACROE   while (0)
#define MAX(x, y)   ((x > y) ? x : y)
#define MIN(x, y)   ((x < y) ? x : y)
#define pgm_read_ptr(Address)   (void*)pgm_read_word(Address)
#define GCC_FORCE_POINTER_ACCESS(StructPtr)   __asm__ __volatile__("" : "=b" (StructPtr) : "0" (StructPtr))
#define GCC_MEMORY_BARRIER()   __asm__ __volatile__("" ::: "memory");
#define GCC_IS_COMPILE_CONST(x)   __builtin_constant_p(x)

Typedefs

typedef MACHINE_REG_t uint_reg_t

Functions

static uint8_t BitReverse (uint8_t Byte) ATTR_WARN_UNUSED_RESULT ATTR_CONST
static void Delay_MS (uint8_t Milliseconds) ATTR_ALWAYS_INLINE

Detailed Description

Common utility headers containing macros, functions, enums and types which are common to all aspects of the library.


Define Documentation

#define GCC_FORCE_POINTER_ACCESS (   StructPtr)    __asm__ __volatile__("" : "=b" (StructPtr) : "0" (StructPtr))

Forces GCC to use pointer indirection (via the device's pointer register pairs) when accessing the given struct pointer. In some cases GCC will emit non-optimal assembly code when accessing a structure through a pointer, resulting in a larger binary. When this macro is used on a (non const) structure pointer before use, it will force GCC to use pointer indirection on the elements rather than direct store and load instructions.

Parameters:
[in,out]StructPtrPointer to a structure which is to be forced into indirect access mode.
#define GCC_IS_COMPILE_CONST (   x)    __builtin_constant_p(x)

Evaluates to boolean true if the specified value can be determined at compile time to be a constant value when compiling under GCC.

Parameters:
[in]xValue to check compile time constantness of.
Returns:
Boolean true if the given value is known to be a compile time constant.
#define GCC_MEMORY_BARRIER ( )    __asm__ __volatile__("" ::: "memory");

Forces GCC to create a memory barrier, ensuring that memory accesses are not reordered past the barrier point. This can be used before ordering-critical operations, to ensure that the compiler does not re-order the resulting assembly output in an unexpected manner on sections of code that are ordering-specific.

#define MACROE   while (0)

Macro for encasing other multi-statement macros. This should be used along with a preceding closing brace at the end of any multi-statement macro, so that the macros contents as a whole are treated as a discrete block and not as a list of separate statements which may cause problems when used as a block (such as inline if statements).

#define MACROS   do

Macro for encasing other multi-statement macros. This should be used along with an opening brace before the start of any multi-statement macro, so that the macros contents as a whole are treated as a discrete block and not as a list of separate statements which may cause problems when used as a block (such as inline if statements).

#define MAX (   x,
 
)    ((x > y) ? x : y)

Convenience macro to determine the larger of two values.

Note:
This macro should only be used with operands that do not have side effects from being evaluated multiple times.
Parameters:
[in]xFirst value to compare
[in]yFirst value to compare
Returns:
The larger of the two input parameters
#define MIN (   x,
 
)    ((x < y) ? x : y)

Convenience macro to determine the smaller of two values.

Note:
This macro should only be used with operands that do not have side effects from being evaluated multiple times.
Parameters:
[in]xFirst value to compare
[in]yFirst value to compare
Returns:
The smaller of the two input parameters
#define pgm_read_ptr (   Address)    (void*)pgm_read_word(Address)

Reads a pointer out of PROGMEM space on the AVR8 architecture. This is currently a wrapper for the avr-libc pgm_read_ptr() macro with a void* cast, so that its value can be assigned directly to a pointer variable or used in pointer arithmetic without further casting in C. In a future avr-libc distribution this will be part of the standard API and will be implemented in a more formal manner.

Note:
This macro is not available for all architectures.
Parameters:
[in]AddressAddress of the pointer to read.
Returns:
Pointer retrieved from PROGMEM space.

Typedef Documentation

typedef MACHINE_REG_t uint_reg_t

Type define for an unsigned integer the same width as the selected architecture's machine register. This is distinct from the non-specific standard int data type, whose width is machine dependant but which may not reflect the actual machine register width on some targets (e.g. AVR8).


Function Documentation

static uint8_t BitReverse ( uint8_t  Byte) [inline, static]

Function to reverse the individual bits in a byte - i.e. bit 7 is moved to bit 0, bit 6 to bit 1, etc.

Parameters:
[in]ByteByte of data whose bits are to be reversed.
static void Delay_MS ( uint8_t  Milliseconds) [inline, static]

Function to perform a blocking delay for a specified number of milliseconds. The actual delay will be at a minimum the specified number of milliseconds, however due to loop overhead and internal calculations may be slightly higher.

Parameters:
[in]MillisecondsNumber of milliseconds to delay