Xmega Application Note


compiler.h File Reference

Commonly used includes, types and macros. More...

#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include "bit_handling/clz_ctz.h"
#include "preprocessor.h"
#include <parts.h>
Include dependency graph for compiler.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  StructCPtr
 Structure of pointers to constant 64-, 32-, 16- and 8-bit unsigned integers. More...
struct  StructCVPtr
 Structure of pointers to constant volatile 64-, 32-, 16- and 8-bit unsigned integers. More...
struct  StructPtr
 Structure of pointers to 64-, 32-, 16- and 8-bit unsigned integers. More...
struct  StructVPtr
 Structure of pointers to volatile 64-, 32-, 16- and 8-bit unsigned integers. More...
union  Union16
 16-bit union. More...
union  Union32
 32-bit union. More...
union  Union64
 64-bit union. More...
union  UnionCPtr
 Union of pointers to constant 64-, 32-, 16- and 8-bit unsigned integers. More...
union  UnionCVPtr
 Union of pointers to constant volatile 64-, 32-, 16- and 8-bit unsigned integers. More...
union  UnionPtr
 Union of pointers to 64-, 32-, 16- and 8-bit unsigned integers. More...
union  UnionVPtr
 Union of pointers to volatile 64-, 32-, 16- and 8-bit unsigned integers. More...

Defines

#define Assert(expr)
 This macro is used to test fatal errors.
#define barrier()   asm ("")
 Memory barrier.
#define COMPILER_PACK_RESET(alignment)
#define COMPILER_PACK_SET(alignment)
#define COMPILER_PRAGMA(arg)   _Pragma(#arg)
 Emit the compiler pragma arg.
#define Long_call(addr)   ((*(void (*)(void))(addr))())
 Calls the routine at address addr.
Mathematics

Compiler optimization for non-constant expressions, only for abs under WinAVR

#define abs(a)   Abs(a)
 Takes the absolute value of a.
#define Abs(a)   (((a) < 0 ) ? -(a) : (a))
 Takes the absolute value of a.
#define max(a, b)   Max(a, b)
 Takes the absolute value of a.
#define Max(a, b)   (((a) > (b)) ? (a) : (b))
 Takes the maximal value of a and b.
#define min(a, b)   Min(a, b)
 Takes the absolute value of a.
#define Min(a, b)   (((a) < (b)) ? (a) : (b))
 Takes the minimal value of a and b.
Alignment

 

#define Align_down(val, n)   ( (val) & ~((n) - 1))
 Aligns the number val with the lower n boundary.
#define Align_up(val, n)   (((val) + ((n) - 1)) & ~((n) - 1))
 Aligns the number val with the upper n boundary.
#define Get_align(val, n)   ( Rd_bits( val, (n) - 1 ) )
 Gets alignment of the number val with respect to the n boundary.
#define Set_align(lval, n, alg)   ( Wr_bits(lval, (n) - 1, alg) )
 Sets alignment of the lvalue number lval to alg with respect to the n boundary.
#define Test_align(val, n)   (!Tst_bits( val, (n) - 1 ) )
 Tests alignment of the number val with the n boundary.
MCU Endianism Handling

Gets the value of the dbgreg debug register.

Parameters:
dbgreg Address of the debug register of which to get the value.
Returns:
Value of the dbgreg debug register.

Sets the value of the dbgreg debug register to value.

Parameters:
dbgreg Address of the debug register of which to set the value.
value Value to set the dbgreg debug register to.

xmega is a MCU little endianism.

#define BE16(x)   Swap16(x)
 Least significant byte of 1st rank of u32.
#define BE16_TO_CPU(x)   Swap16(x)
 Least significant byte of 1st rank of u32.
#define be16_to_cpu(x)   swap16(x)
 Least significant byte of 1st rank of u32.
#define BE32(x)   Swap32(x)
 Least significant byte of 1st rank of u32.
#define BE32_TO_CPU(x)   Swap32(x)
 Least significant byte of 1st rank of u32.
#define be32_to_cpu(x)   swap32(x)
 Least significant byte of 1st rank of u32.
#define CPU_TO_BE16(x)   Swap16(x)
 Least significant byte of 1st rank of u32.
#define cpu_to_be16(x)   swap16(x)
 Least significant byte of 1st rank of u32.
#define CPU_TO_BE32(x)   Swap32(x)
 Least significant byte of 1st rank of u32.
#define cpu_to_be32(x)   swap32(x)
 Least significant byte of 1st rank of u32.
#define CPU_TO_LE16(x)   (x)
 Least significant byte of 1st rank of u32.
#define cpu_to_le16(x)   (x)
 Least significant byte of 1st rank of u32.
#define CPU_TO_LE32(x)   (x)
 Least significant byte of 1st rank of u32.
#define cpu_to_le32(x)   (x)
 Least significant byte of 1st rank of u32.
#define LE16(x)   (x)
 Least significant byte of 1st rank of u32.
#define LE16_TO_CPU(x)   (x)
 Least significant byte of 1st rank of u32.
#define le16_to_cpu(x)   (x)
 Least significant byte of 1st rank of u32.
#define LE32(x)   (x)
 Least significant byte of 1st rank of u32.
#define LE32_TO_CPU(x)   (x)
 Least significant byte of 1st rank of u32.
#define le32_to_cpu(x)   (x)
 Least significant byte of 1st rank of u32.
#define LSB(u16)   (((uint8_t* )&u16)[0])
 Least significant byte of 1st rank of u32.
#define LSB0(u32)   MSB3(u32)
 Least significant byte of 1st rank of u32.
#define LSB0W(u32)   MSB3W(u32)
 Least significant byte of 1st rank of u32.
#define LSB1(u32)   MSB2(u32)
 Least significant byte of 1st rank of u32.
#define LSB1W(u32)   MSB2W(u32)
 Least significant byte of 2nd rank of u32.
#define LSB2(u32)   MSB1(u32)
 Least significant byte of 1st rank of u32.
#define LSB2W(u32)   MSB1W(u32)
 Least significant byte of 3rd rank of u32.
#define LSB3(u32)   MSB0(u32)
 Least significant byte of 1st rank of u32.
#define LSB3W(u32)   MSB0W(u32)
 Least significant byte of 4th rank of u32.
#define LSW(u32)   (((uint16_t*)&u32)[0])
 Least significant byte of 1st rank of u32.
#define MSB(u16)   (((uint8_t* )&u16)[1])
 Least significant byte of 1st rank of u32.
#define MSB0(u32)   (((uint8_t* )&u32)[3])
 Least significant byte of 1st rank of u32.
#define MSB0W(u32)   (((U8 *)&(u32))[3])
 Most significant byte of 1st rank of u32.
#define MSB1(u32)   (((uint8_t* )&u32)[2])
 Least significant byte of 1st rank of u32.
#define MSB1W(u32)   (((U8 *)&(u32))[2])
 Most significant byte of 2nd rank of u32.
#define MSB2(u32)   (((uint8_t* )&u32)[1])
 Least significant byte of 1st rank of u32.
#define MSB2W(u32)   (((U8 *)&(u32))[1])
 Most significant byte of 3rd rank of u32.
#define MSB3(u32)   (((uint8_t* )&u32)[0])
 Least significant byte of 1st rank of u32.
#define MSB3W(u32)   (((U8 *)&(u32))[0])
 Most significant byte of 4th rank of u32.
#define MSW(u32)   (((uint16_t*)&u32)[1])
 Least significant byte of 1st rank of u32.
Bit Reversing

#define bit_reverse16(u16)   ((U16)(bit_reverse32((U16)(u16)) >> 16))
 Reverses the bits of u16.
#define bit_reverse64(u64)
 Reverses the bits of u32.
#define bit_reverse8(u8)   ((U8)(bit_reverse32((U8)(u8)) >> 24))
 Reverses the bits of u8.
Usual Constants

#define CLR   0
#define DISABLE   0
#define DISABLED   0
#define ENABLE   1
#define ENABLED   1
#define FAIL   1
#define false   FALSE
#define FALSE   0
#define HIGH   1
#define KO   0
#define LOW   0
#define OFF   0
#define OK   1
#define ON   1
#define PASS   0
#define SET   1
#define true   TRUE
#define TRUE   1
Bit-Field Handling

#define Clr_bits(lvalue, mask)   ((lvalue) &= ~(mask))
 Clears the bits of a C lvalue specified by a given bit-mask.
#define Rd_bitfield(value, mask)   (Rd_bits( value, (uint32_t)mask) >> ctz(mask))
 Reads the bit-field of a value specified by a given bit-mask.
#define Rd_bits(value, mask)   ((value)&(mask))
 Reads the bits of a value specified by a given bit-mask.
#define Set_bits(lvalue, mask)   ((lvalue) |= (mask))
 Sets the bits of a C lvalue specified by a given bit-mask.
#define Tgl_bits(lvalue, mask)   ((lvalue) ^= (mask))
 Toggles the bits of a C lvalue specified by a given bit-mask.
#define Tst_bits(value, mask)   (Rd_bits(value, mask) != 0)
 Tests the bits of a value specified by a given bit-mask.
#define Wr_bitfield(lvalue, mask, bitfield)   (Wr_bits(lvalue, mask, (uint32_t)(bitfield) << ctz(mask)))
 Writes the bit-field of a C lvalue specified by a given bit-mask.
#define Wr_bits(lvalue, mask, bits)
 Writes the bits of a C lvalue specified by a given bit-mask.
Compile time error handling

#define ERROR_FUNC(name, msg)   extern int name(void)
 Fail compilation if function call isn't eliminated.
Optimization Control

#define is_constant(exp)   (0)
 Determine if an expression evaluates to a constant value.
#define likely(exp)   (exp)
 The expression exp is likely to be true.
#define unlikely(exp)   (exp)
 The expression exp is unlikely to be true.
Endianism Conversion

The same considerations as for clz and ctz apply here but AVR32-GCC's __builtin_bswap_16 and __builtin_bswap_32 do not behave like macros when applied to constant expressions, so two sets of macros are defined here:

  • Swap16, Swap32 and Swap64 to apply to constant expressions (values known at compile time);
  • swap16, swap32 and swap64 to apply to non-constant expressions (values unknown at compile time).
#define swap16(u16)   Swap16(u16)
 Toggles the endianism of u16 (by swapping its bytes).
#define Swap16(u16)
 Toggles the endianism of u16 (by swapping its bytes).
#define swap32(u32)   Swap32(u32)
 Toggles the endianism of u32 (by swapping its bytes).
#define Swap32(u32)
 Toggles the endianism of u32 (by swapping its bytes).
#define swap64(u64)
 Toggles the endianism of u64 (by swapping its bytes).
#define Swap64(u64)
 Toggles the endianism of u64 (by swapping its bytes).

Typedefs

Usual Types

Set word-aligned boundary.

typedef unsigned short int be16_t
 Boolean.
typedef uint32_t be32_t
 Boolean.
typedef unsigned char bool
 Boolean.
typedef unsigned char Bool
 Boolean.
typedef float F32
 32-bit floating-point number.
typedef double F64
 64-bit floating-point number.
typedef uint16_t iram_size_t
 Boolean.
typedef unsigned short int le16_t
 Boolean.
typedef uint32_t le32_t
 Boolean.
typedef signed short int S16
 16-bit signed integer.
typedef signed long int S32
 32-bit signed integer.
typedef signed long long int S64
 64-bit signed integer.
typedef signed char S8
 8-bit signed integer.
typedef unsigned short int U16
 16-bit unsigned integer.
typedef unsigned long int U32
 32-bit unsigned integer.
typedef unsigned long long int U64
 64-bit unsigned integer.
typedef unsigned char U8
 8-bit unsigned integer.
Status Types

typedef Bool Status_bool_t
 Boolean status.
typedef U8 Status_t

Functions

Logarithmic functions

static __always_inline int_fast8_t ilog2 (uint32_t x)
 Calculate the base-2 logarithm of a number rounded down to the nearest integer.
int_fast8_t ilog2_undefined (void)

Target Abstraction



#define _CONST_TYPE_   const
 const type qualifier.
#define _GLOBEXT_   extern
 extern storage-class specifier.
#define _MEM_TYPE_FAST_
 Fast memory type.
#define _MEM_TYPE_MEDFAST_
 Fairly fast memory type.
#define _MEM_TYPE_SLOW_
 Slow memory type.
#define memcmp_code2ram   memcmp
 Target-specific memcmp of RAM to NVRAM.
#define memcmp_ram2ram   memcmp
 Target-specific memcmp of RAM to RAM.
#define memcpy_code2ram   memcpy
 Target-specific memcpy from NVRAM to RAM.
#define memcpy_ram2ram   memcpy
 Target-specific memcpy from RAM to RAM.
typedef U8 Byte
 8-bit unsigned integer.

Function call demultiplexing



#define compiler_demux_size(size, func,...)
 Demultiplex function call based on size of datatype.
 ERROR_FUNC (compiler_demux_bad_size,"Invalid parameter size")
 Error function for failed demultiplexing.

Detailed Description

Commonly used includes, types and macros.

Copyright (C) 2010 Atmel Corporation. All rights reserved.

Definition in file compiler.h.


Define Documentation

#define _CONST_TYPE_   const

const type qualifier.

Definition at line 938 of file compiler.h.

#define _GLOBEXT_   extern

extern storage-class specifier.

Definition at line 937 of file compiler.h.

#define _MEM_TYPE_FAST_

Fast memory type.

Definition at line 941 of file compiler.h.

#define _MEM_TYPE_MEDFAST_

Fairly fast memory type.

Definition at line 940 of file compiler.h.

#define _MEM_TYPE_SLOW_

Slow memory type.

Definition at line 939 of file compiler.h.

#define abs (  )     Abs(a)

Takes the absolute value of a.

Parameters:
a Input value.
Returns:
Absolute value of a.
Note:
More optimized if only used with values known at compile time.

Definition at line 696 of file compiler.h.

#define Abs (  )     (((a) < 0 ) ? -(a) : (a))

Takes the absolute value of a.

Parameters:
a Input value.
Returns:
Absolute value of a.
Note:
More optimized if only used with values known at compile time.

Definition at line 694 of file compiler.h.

#define Align_down ( val,
 )     ( (val) & ~((n) - 1))

Aligns the number val with the lower n boundary.

Parameters:
val Input value.
n Boundary.
Returns:
Value resulting from the number val aligned with the lower n boundary.

Definition at line 675 of file compiler.h.

#define Align_up ( val,
 )     (((val) + ((n) - 1)) & ~((n) - 1))

Aligns the number val with the upper n boundary.

Parameters:
val Input value.
n Boundary.
Returns:
Value resulting from the number val aligned with the upper n boundary.

Definition at line 666 of file compiler.h.

#define Assert ( expr   ) 
 
#define barrier (  )     asm ("")

Memory barrier.

Definition at line 76 of file compiler.h.

Referenced by cpu_irq_restore().

#define BE16 (  )     Swap16(x)

Least significant byte of 1st rank of u32.

Definition at line 831 of file compiler.h.

#define BE16_TO_CPU (  )     Swap16(x)

Least significant byte of 1st rank of u32.

Definition at line 834 of file compiler.h.

#define be16_to_cpu (  )     swap16(x)

Least significant byte of 1st rank of u32.

Definition at line 832 of file compiler.h.

#define BE32 (  )     Swap32(x)

Least significant byte of 1st rank of u32.

Definition at line 843 of file compiler.h.

#define BE32_TO_CPU (  )     Swap32(x)

Least significant byte of 1st rank of u32.

Definition at line 846 of file compiler.h.

#define be32_to_cpu (  )     swap32(x)

Least significant byte of 1st rank of u32.

Definition at line 844 of file compiler.h.

#define bit_reverse16 ( u16   )     ((U16)(bit_reverse32((U16)(u16)) >> 16))

Reverses the bits of u16.

Parameters:
u16 U16 of which to reverse the bits.
Returns:
Value resulting from u16 with reversed bits.

Definition at line 536 of file compiler.h.

#define bit_reverse64 ( u64   ) 
Value:
((U64)(((U64)bit_reverse32((U64)(u64) >> 32)) |\
                                   ((U64)bit_reverse32((U64)(u64)) << 32)))

Reverses the bits of u32.

Parameters:
u32 U32 of which to reverse the bits.
Returns:
Value resulting from u32 with reversed bits.

Reverses the bits of u64.

Parameters:
u64 U64 of which to reverse the bits.
Returns:
Value resulting from u64 with reversed bits.

Definition at line 563 of file compiler.h.

#define bit_reverse8 ( u8   )     ((U8)(bit_reverse32((U8)(u8)) >> 24))

Reverses the bits of u8.

Parameters:
u8 U8 of which to reverse the bits.
Returns:
Value resulting from u8 with reversed bits.

Definition at line 528 of file compiler.h.

#define CLR   0

Definition at line 308 of file compiler.h.

#define Clr_bits ( lvalue,
mask   )     ((lvalue) &= ~(mask))

Clears the bits of a C lvalue specified by a given bit-mask.

Parameters:
lvalue C lvalue of which to clear bits.
mask Bit-mask indicating bits to clear.
Returns:
Resulting value with cleared bits.

Definition at line 460 of file compiler.h.

#define compiler_demux_size ( size,
func,
...   ) 
Value:
(((size) == 1) ? func##8(__VA_ARGS__) :     \
         ((size) == 2) ? func##16(__VA_ARGS__) :    \
         ((size) == 4) ? func##32(__VA_ARGS__) :    \
         compiler_demux_bad_size())

Demultiplex function call based on size of datatype.

For internal use only.

Evaluates to a function call to a function name with suffix 8, 16 or 32 depending on the size of the datatype. Any number of parameters can be passed to the function.

Usage:

 void foo8(uint8_t a, void *b);
 void foo16(uint16_t a, void *b);
 void foo32(uint32_t a, void *b);

 #define foo(x, y)    compiler_demux_size(sizeof(x), foo, x, y)
Parameters:
size Size of the datatype.
func Base function name.
... List of parameters to pass to the function.

Definition at line 362 of file compiler.h.

#define COMPILER_PACK_RESET ( alignment   ) 

Definition at line 90 of file compiler.h.

#define COMPILER_PACK_SET ( alignment   ) 

Definition at line 91 of file compiler.h.

#define COMPILER_PRAGMA ( arg   )     _Pragma(#arg)

Emit the compiler pragma arg.

Parameters:
arg The pragma directive as it would appear after #pragma (i.e. not stringified).

Definition at line 85 of file compiler.h.

#define CPU_TO_BE16 (  )     Swap16(x)

Least significant byte of 1st rank of u32.

Definition at line 835 of file compiler.h.

#define cpu_to_be16 (  )     swap16(x)

Least significant byte of 1st rank of u32.

Definition at line 833 of file compiler.h.

#define CPU_TO_BE32 (  )     Swap32(x)

Least significant byte of 1st rank of u32.

Definition at line 847 of file compiler.h.

#define cpu_to_be32 (  )     swap32(x)

Least significant byte of 1st rank of u32.

Definition at line 845 of file compiler.h.

#define CPU_TO_LE16 (  )     (x)

Least significant byte of 1st rank of u32.

Definition at line 829 of file compiler.h.

#define cpu_to_le16 (  )     (x)

Least significant byte of 1st rank of u32.

Definition at line 827 of file compiler.h.

#define CPU_TO_LE32 (  )     (x)

Least significant byte of 1st rank of u32.

Definition at line 841 of file compiler.h.

#define cpu_to_le32 (  )     (x)

Least significant byte of 1st rank of u32.

Definition at line 839 of file compiler.h.

#define DISABLE   0

Definition at line 288 of file compiler.h.

#define DISABLED   0

Definition at line 290 of file compiler.h.

#define ENABLE   1

Definition at line 289 of file compiler.h.

#define ENABLED   1

Definition at line 291 of file compiler.h.

#define ERROR_FUNC ( name,
msg   )     extern int name(void)

Fail compilation if function call isn't eliminated.

For internal use only.

If the compiler fails to optimize away all calls to the function name, terminate compilation and display msg to the user.

Note:
Not all compilers support this, so this is best-effort only. Sometimes, there may be a linker error instead, and when optimization is disabled, this mechanism will be completely disabled.

Definition at line 329 of file compiler.h.

#define FAIL   1

Definition at line 305 of file compiler.h.

#define false   FALSE

Definition at line 298 of file compiler.h.

#define FALSE   0

Definition at line 294 of file compiler.h.

#define Get_align ( val,
 )     ( Rd_bits( val, (n) - 1 ) )

Gets alignment of the number val with respect to the n boundary.

Parameters:
val Input value.
n Boundary.
Returns:
Alignment of the number val with respect to the n boundary.

Definition at line 647 of file compiler.h.

#define HIGH   1

Definition at line 307 of file compiler.h.

#define is_constant ( exp   )     (0)

Determine if an expression evaluates to a constant value.

Parameters:
exp Any expression
Returns:
true if exp is constant, false otherwise.

Definition at line 414 of file compiler.h.

Referenced by ilog2().

#define KO   0

Definition at line 302 of file compiler.h.

#define LE16 (  )     (x)

Least significant byte of 1st rank of u32.

Definition at line 825 of file compiler.h.

#define LE16_TO_CPU (  )     (x)

Least significant byte of 1st rank of u32.

Definition at line 828 of file compiler.h.

#define le16_to_cpu (  )     (x)

Least significant byte of 1st rank of u32.

Definition at line 826 of file compiler.h.

#define LE32 (  )     (x)

Least significant byte of 1st rank of u32.

Definition at line 837 of file compiler.h.

#define LE32_TO_CPU (  )     (x)

Least significant byte of 1st rank of u32.

Definition at line 840 of file compiler.h.

#define le32_to_cpu (  )     (x)

Least significant byte of 1st rank of u32.

Definition at line 838 of file compiler.h.

#define likely ( exp   )     (exp)

The expression exp is likely to be true.

Definition at line 392 of file compiler.h.

#define Long_call ( addr   )     ((*(void (*)(void))(addr))())

Calls the routine at address addr.

It generates a long call opcode.

For example, `Long_call(0x80000000)' generates a software reset on a UC3 if it is invoked from the CPU supervisor mode.

Parameters:
addr Address of the routine to call.
Note:
It may be used as a long jump opcode in some special cases.

Definition at line 737 of file compiler.h.

#define LOW   0

Definition at line 306 of file compiler.h.

#define LSB ( u16   )     (((uint8_t* )&u16)[0])

Least significant byte of 1st rank of u32.

Definition at line 803 of file compiler.h.

Referenced by osc_user_calibration(), and sysclk_init().

#define LSB0 ( u32   )     MSB3(u32)

Least significant byte of 1st rank of u32.

Definition at line 820 of file compiler.h.

#define LSB0W ( u32   )     MSB3W(u32)

Least significant byte of 1st rank of u32.

Definition at line 814 of file compiler.h.

#define LSB1 ( u32   )     MSB2(u32)

Least significant byte of 1st rank of u32.

Definition at line 821 of file compiler.h.

#define LSB1W ( u32   )     MSB2W(u32)

Least significant byte of 2nd rank of u32.

Definition at line 813 of file compiler.h.

#define LSB2 ( u32   )     MSB1(u32)

Least significant byte of 1st rank of u32.

Definition at line 822 of file compiler.h.

#define LSB2W ( u32   )     MSB1W(u32)

Least significant byte of 3rd rank of u32.

Definition at line 812 of file compiler.h.

#define LSB3 ( u32   )     MSB0(u32)

Least significant byte of 1st rank of u32.

Definition at line 823 of file compiler.h.

#define LSB3W ( u32   )     MSB0W(u32)

Least significant byte of 4th rank of u32.

Definition at line 811 of file compiler.h.

#define LSW ( u32   )     (((uint16_t*)&u32)[0])

Least significant byte of 1st rank of u32.

Definition at line 806 of file compiler.h.

#define max ( a,
 )     Max(a, b)

Takes the absolute value of a.

Parameters:
a Input value.
Returns:
Absolute value of a.
Note:
More optimized if only used with values known at compile time.

Definition at line 721 of file compiler.h.

#define Max ( a,
 )     (((a) > (b)) ? (a) : (b))

Takes the maximal value of a and b.

Parameters:
a Input value.
b Input value.
Returns:
Maximal value of a and b.
Note:
More optimized if only used with values known at compile time.

Definition at line 720 of file compiler.h.

#define memcmp_code2ram   memcmp

Target-specific memcmp of RAM to NVRAM.

Definition at line 946 of file compiler.h.

#define memcmp_ram2ram   memcmp

Target-specific memcmp of RAM to RAM.

Definition at line 945 of file compiler.h.

#define memcpy_code2ram   memcpy

Target-specific memcpy from NVRAM to RAM.

Definition at line 948 of file compiler.h.

#define memcpy_ram2ram   memcpy

Target-specific memcpy from RAM to RAM.

Definition at line 947 of file compiler.h.

#define min ( a,
 )     Min(a, b)

Takes the absolute value of a.

Parameters:
a Input value.
Returns:
Absolute value of a.
Note:
More optimized if only used with values known at compile time.

Definition at line 709 of file compiler.h.

#define Min ( a,
 )     (((a) < (b)) ? (a) : (b))

Takes the minimal value of a and b.

Parameters:
a Input value.
b Input value.
Returns:
Minimal value of a and b.
Note:
More optimized if only used with values known at compile time.

Definition at line 708 of file compiler.h.

#define MSB ( u16   )     (((uint8_t* )&u16)[1])

Least significant byte of 1st rank of u32.

Definition at line 802 of file compiler.h.

Referenced by osc_user_calibration(), and sysclk_init().

#define MSB0 ( u32   )     (((uint8_t* )&u32)[3])

Least significant byte of 1st rank of u32.

Definition at line 816 of file compiler.h.

#define MSB0W ( u32   )     (((U8 *)&(u32))[3])

Most significant byte of 1st rank of u32.

Definition at line 807 of file compiler.h.

#define MSB1 ( u32   )     (((uint8_t* )&u32)[2])

Least significant byte of 1st rank of u32.

Definition at line 817 of file compiler.h.

#define MSB1W ( u32   )     (((U8 *)&(u32))[2])

Most significant byte of 2nd rank of u32.

Definition at line 808 of file compiler.h.

#define MSB2 ( u32   )     (((uint8_t* )&u32)[1])

Least significant byte of 1st rank of u32.

Definition at line 818 of file compiler.h.

#define MSB2W ( u32   )     (((U8 *)&(u32))[1])

Most significant byte of 3rd rank of u32.

Definition at line 809 of file compiler.h.

#define MSB3 ( u32   )     (((uint8_t* )&u32)[0])

Least significant byte of 1st rank of u32.

Definition at line 819 of file compiler.h.

#define MSB3W ( u32   )     (((U8 *)&(u32))[0])

Most significant byte of 4th rank of u32.

Definition at line 810 of file compiler.h.

#define MSW ( u32   )     (((uint16_t*)&u32)[1])

Least significant byte of 1st rank of u32.

Definition at line 805 of file compiler.h.

#define OFF   0

Definition at line 292 of file compiler.h.

#define OK   1

Definition at line 303 of file compiler.h.

#define ON   1

Definition at line 293 of file compiler.h.

#define PASS   0

Definition at line 304 of file compiler.h.

#define Rd_bitfield ( value,
mask   )     (Rd_bits( value, (uint32_t)mask) >> ctz(mask))

Reads the bit-field of a value specified by a given bit-mask.

Parameters:
value Value to read a bit-field from.
mask Bit-mask indicating the bit-field to read.
Returns:
Read bit-field.

Definition at line 487 of file compiler.h.

#define Rd_bits ( value,
mask   )     ((value)&(mask))

Reads the bits of a value specified by a given bit-mask.

Parameters:
value Value to read bits from.
mask Bit-mask indicating bits to read.
Returns:
Read bits.

Definition at line 431 of file compiler.h.

#define SET   1

Definition at line 309 of file compiler.h.

#define Set_align ( lval,
n,
alg   )     ( Wr_bits(lval, (n) - 1, alg) )

Sets alignment of the lvalue number lval to alg with respect to the n boundary.

Parameters:
lval Input/output lvalue.
n Boundary.
alg Alignment.
Returns:
New value of lval resulting from its alignment set to alg with respect to the n boundary.

Definition at line 657 of file compiler.h.

#define Set_bits ( lvalue,
mask   )     ((lvalue) |= (mask))

Sets the bits of a C lvalue specified by a given bit-mask.

Parameters:
lvalue C lvalue of which to set bits.
mask Bit-mask indicating bits to set.
Returns:
Resulting value with set bits.

Definition at line 469 of file compiler.h.

#define swap16 ( u16   )     Swap16(u16)

Toggles the endianism of u16 (by swapping its bytes).

Parameters:
u16 U16 of which to toggle the endianism.
Returns:
Value resulting from u16 with toggled endianism.
Note:
More optimized if only used with values unknown at compile time.

Definition at line 907 of file compiler.h.

#define Swap16 ( u16   ) 
Value:
((U16)(((U16)(u16) >> 8) |\
                           ((U16)(u16) << 8)))

Toggles the endianism of u16 (by swapping its bytes).

Parameters:
u16 U16 of which to toggle the endianism.
Returns:
Value resulting from u16 with toggled endianism.
Note:
More optimized if only used with values known at compile time.

Definition at line 874 of file compiler.h.

#define swap32 ( u32   )     Swap32(u32)

Toggles the endianism of u32 (by swapping its bytes).

Parameters:
u32 U32 of which to toggle the endianism.
Returns:
Value resulting from u32 with toggled endianism.
Note:
More optimized if only used with values unknown at compile time.

Definition at line 917 of file compiler.h.

#define Swap32 ( u32   ) 
Value:
((U32)(((U32)Swap16((U32)(u32) >> 16)) |\
                           ((U32)Swap16((U32)(u32)) << 16)))

Toggles the endianism of u32 (by swapping its bytes).

Parameters:
u32 U32 of which to toggle the endianism.
Returns:
Value resulting from u32 with toggled endianism.
Note:
More optimized if only used with values known at compile time.

Definition at line 885 of file compiler.h.

#define swap64 ( u64   ) 
Value:
((U64)(((U64)swap32((U64)(u64) >> 32)) |\
                           ((U64)swap32((U64)(u64)) << 32)))

Toggles the endianism of u64 (by swapping its bytes).

Parameters:
u64 U64 of which to toggle the endianism.
Returns:
Value resulting from u64 with toggled endianism.
Note:
More optimized if only used with values unknown at compile time.

Definition at line 927 of file compiler.h.

#define Swap64 ( u64   ) 
Value:
((U64)(((U64)Swap32((U64)(u64) >> 32)) |\
                           ((U64)Swap32((U64)(u64)) << 32)))

Toggles the endianism of u64 (by swapping its bytes).

Parameters:
u64 U64 of which to toggle the endianism.
Returns:
Value resulting from u64 with toggled endianism.
Note:
More optimized if only used with values known at compile time.

Definition at line 896 of file compiler.h.

#define Test_align ( val,
 )     (!Tst_bits( val, (n) - 1 ) )

Tests alignment of the number val with the n boundary.

Parameters:
val Input value.
n Boundary.
Returns:
1 if the number val is aligned with the n boundary, else 0.

Definition at line 638 of file compiler.h.

#define Tgl_bits ( lvalue,
mask   )     ((lvalue) ^= (mask))

Toggles the bits of a C lvalue specified by a given bit-mask.

Parameters:
lvalue C lvalue of which to toggle bits.
mask Bit-mask indicating bits to toggle.
Returns:
Resulting value with toggled bits.

Definition at line 478 of file compiler.h.

#define true   TRUE

Definition at line 299 of file compiler.h.

#define TRUE   1

Definition at line 295 of file compiler.h.

#define Tst_bits ( value,
mask   )     (Rd_bits(value, mask) != 0)

Tests the bits of a value specified by a given bit-mask.

Parameters:
value Value of which to test bits.
mask Bit-mask indicating bits to test.
Returns:
1 if at least one of the tested bits is set, else 0.

Definition at line 451 of file compiler.h.

#define unlikely ( exp   )     (exp)

The expression exp is unlikely to be true.

Definition at line 400 of file compiler.h.

#define Wr_bitfield ( lvalue,
mask,
bitfield   )     (Wr_bits(lvalue, mask, (uint32_t)(bitfield) << ctz(mask)))

Writes the bit-field of a C lvalue specified by a given bit-mask.

Parameters:
lvalue C lvalue to write a bit-field to.
mask Bit-mask indicating the bit-field to write.
bitfield Bit-field to write.
Returns:
Resulting value with written bit-field.

Definition at line 497 of file compiler.h.

#define Wr_bits ( lvalue,
mask,
bits   ) 
Value:
((lvalue) = ((lvalue) & ~(mask)) |\
                                                 ((bits  ) &  (mask)))

Writes the bits of a C lvalue specified by a given bit-mask.

Parameters:
lvalue C lvalue to write bits to.
mask Bit-mask indicating bits to write.
bits Bits to write.
Returns:
Resulting value with written bits.

Definition at line 441 of file compiler.h.


Typedef Documentation

typedef unsigned short int be16_t

Boolean.

Definition at line 118 of file compiler.h.

typedef uint32_t be32_t

Boolean.

Definition at line 122 of file compiler.h.

typedef unsigned char bool

Boolean.

Definition at line 110 of file compiler.h.

typedef unsigned char Bool

Boolean.

Definition at line 107 of file compiler.h.

typedef U8 Byte

8-bit unsigned integer.

Definition at line 943 of file compiler.h.

typedef float F32

32-bit floating-point number.

Definition at line 125 of file compiler.h.

typedef double F64

64-bit floating-point number.

Definition at line 126 of file compiler.h.

typedef uint16_t iram_size_t

Boolean.

Definition at line 127 of file compiler.h.

typedef unsigned short int le16_t

Boolean.

Definition at line 117 of file compiler.h.

typedef uint32_t le32_t

Boolean.

Definition at line 121 of file compiler.h.

typedef signed short int S16

16-bit signed integer.

Definition at line 115 of file compiler.h.

typedef signed long int S32

32-bit signed integer.

Definition at line 119 of file compiler.h.

typedef signed long long int S64

64-bit signed integer.

Definition at line 123 of file compiler.h.

typedef signed char S8

8-bit signed integer.

Definition at line 113 of file compiler.h.

Boolean status.

Definition at line 134 of file compiler.h.

typedef U8 Status_t

8-bit-coded status.

Definition at line 135 of file compiler.h.

typedef unsigned short int U16

16-bit unsigned integer.

Definition at line 116 of file compiler.h.

typedef unsigned long int U32

32-bit unsigned integer.

Definition at line 120 of file compiler.h.

typedef unsigned long long int U64

64-bit unsigned integer.

Definition at line 124 of file compiler.h.

typedef unsigned char U8

8-bit unsigned integer.

Definition at line 114 of file compiler.h.


Function Documentation

ERROR_FUNC ( compiler_demux_bad_size  ,
"Invalid parameter size"   
)

Error function for failed demultiplexing.

static __always_inline int_fast8_t ilog2 ( uint32_t  x  )  [inline, static]

Calculate the base-2 logarithm of a number rounded down to the nearest integer.

Parameters:
x A 32-bit value
Returns:
The base-2 logarithm of x, or -1 if x is 0.

Definition at line 585 of file compiler.h.

References clz, ilog2_undefined(), and is_constant.

00586 {
00587         if (is_constant(x))
00588                 return ((x) & (1ULL << 31) ? 31 :
00589                         (x) & (1ULL << 30) ? 30 :
00590                         (x) & (1ULL << 29) ? 29 :
00591                         (x) & (1ULL << 28) ? 28 :
00592                         (x) & (1ULL << 27) ? 27 :
00593                         (x) & (1ULL << 26) ? 26 :
00594                         (x) & (1ULL << 25) ? 25 :
00595                         (x) & (1ULL << 24) ? 24 :
00596                         (x) & (1ULL << 23) ? 23 :
00597                         (x) & (1ULL << 22) ? 22 :
00598                         (x) & (1ULL << 21) ? 21 :
00599                         (x) & (1ULL << 20) ? 20 :
00600                         (x) & (1ULL << 19) ? 19 :
00601                         (x) & (1ULL << 18) ? 18 :
00602                         (x) & (1ULL << 17) ? 17 :
00603                         (x) & (1ULL << 16) ? 16 :
00604                         (x) & (1ULL << 15) ? 15 :
00605                         (x) & (1ULL << 14) ? 14 :
00606                         (x) & (1ULL << 13) ? 13 :
00607                         (x) & (1ULL << 12) ? 12 :
00608                         (x) & (1ULL << 11) ? 11 :
00609                         (x) & (1ULL << 10) ? 10 :
00610                         (x) & (1ULL <<  9) ?  9 :
00611                         (x) & (1ULL <<  8) ?  8 :
00612                         (x) & (1ULL <<  7) ?  7 :
00613                         (x) & (1ULL <<  6) ?  6 :
00614                         (x) & (1ULL <<  5) ?  5 :
00615                         (x) & (1ULL <<  4) ?  4 :
00616                         (x) & (1ULL <<  3) ?  3 :
00617                         (x) & (1ULL <<  2) ?  2 :
00618                         (x) & (1ULL <<  1) ?  1 :
00619                         (x) & (1ULL <<  0) ?  0 :
00620                         ilog2_undefined());
00621 
00622         return 31 - clz(x);
00623 }

Here is the call graph for this function:

int_fast8_t ilog2_undefined ( void   ) 

For internal use only.

Undefined function. Will cause a link failure if ilog2() is called with an invalid constant value.

Referenced by ilog2().

@DOC_TITLE@
Generated on Fri Oct 22 12:15:25 2010 for AVR1300 Using the Xmega ADC by doxygen 1.6.3