Xmega Application Note | |||||
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>
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 | ||||||||||
#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.
Sets the value of the dbgreg debug register to value.
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:
| ||||||||||
#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 | ||||||||||
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. |
Commonly used includes, types and macros.
Copyright (C) 2010 Atmel Corporation. All rights reserved.
Definition in file compiler.h.
#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 | ( | a | ) | Abs(a) |
Takes the absolute value of a.
a | Input value. |
Definition at line 696 of file compiler.h.
#define Abs | ( | a | ) | (((a) < 0 ) ? -(a) : (a)) |
Takes the absolute value of a.
a | Input value. |
Definition at line 694 of file compiler.h.
#define Align_down | ( | val, | |||
n | ) | ( (val) & ~((n) - 1)) |
Aligns the number val with the lower n boundary.
val | Input value. | |
n | Boundary. |
Definition at line 675 of file compiler.h.
#define Align_up | ( | val, | |||
n | ) | (((val) + ((n) - 1)) & ~((n) - 1)) |
Aligns the number val with the upper n boundary.
val | Input value. | |
n | Boundary. |
Definition at line 666 of file compiler.h.
#define Assert | ( | expr | ) |
This macro is used to test fatal errors.
The macro tests if the expression is FALSE. If it is, a fatal error is detected and the application hangs up.
expr | Expression to evaluate and supposed to be nonzero. |
Definition at line 515 of file compiler.h.
Referenced by adc_disable_clock(), adc_enable_clock(), adc_get_calibration_data(), adc_is_enabled(), adc_set_clock_rate(), adc_set_conversion_trigger(), adc_write_configuration(), adcch_get_gain_setting(), adcch_read_configuration(), adcch_set_input(), adcch_write_configuration(), genclk_config_set_divider(), genclk_config_set_source(), osc_disable(), osc_enable_autocalibration(), osc_enable_internal(), osc_get_rate(), osc_is_ready(), pll_config_clear_option(), pll_config_init(), pll_config_read(), pll_config_set_option(), pll_config_write(), pll_disable(), pll_enable(), pll_get_default_rate_priv(), pll_is_locked(), pll_wait_for_lock(), pmic_disable_level(), pmic_enable_level(), pmic_level_is_enabled(), pmic_set_scheduling(), pmic_set_vector_location(), sleepmgr_enter_sleep(), sleepmgr_lock_mode(), sleepmgr_unlock_mode(), sysclk_init(), sysclk_set_prescalers(), and sysclk_set_source().
#define barrier | ( | ) | asm ("") |
#define BE16 | ( | x | ) | Swap16(x) |
Least significant byte of 1st rank of u32.
Definition at line 831 of file compiler.h.
#define BE16_TO_CPU | ( | x | ) | Swap16(x) |
Least significant byte of 1st rank of u32.
Definition at line 834 of file compiler.h.
#define be16_to_cpu | ( | x | ) | swap16(x) |
Least significant byte of 1st rank of u32.
Definition at line 832 of file compiler.h.
#define BE32 | ( | x | ) | Swap32(x) |
Least significant byte of 1st rank of u32.
Definition at line 843 of file compiler.h.
#define BE32_TO_CPU | ( | x | ) | Swap32(x) |
Least significant byte of 1st rank of u32.
Definition at line 846 of file compiler.h.
#define be32_to_cpu | ( | x | ) | swap32(x) |
Least significant byte of 1st rank of u32.
Definition at line 844 of file compiler.h.
Reverses the bits of u16.
u16 | U16 of which to reverse the bits. |
Definition at line 536 of file compiler.h.
#define bit_reverse64 | ( | u64 | ) |
Reverses the bits of u32.
u32 | U32 of which to reverse the bits. |
Reverses the bits of u64.
u64 | U64 of which to reverse the bits. |
Definition at line 563 of file compiler.h.
Reverses the bits of u8.
u8 | U8 of which to reverse the 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.
lvalue | C lvalue of which to clear bits. | |
mask | Bit-mask indicating bits to clear. |
Definition at line 460 of file compiler.h.
#define compiler_demux_size | ( | size, | |||
func, | |||||
... | ) |
(((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)
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.
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 | ( | x | ) | Swap16(x) |
Least significant byte of 1st rank of u32.
Definition at line 835 of file compiler.h.
#define cpu_to_be16 | ( | x | ) | swap16(x) |
Least significant byte of 1st rank of u32.
Definition at line 833 of file compiler.h.
#define CPU_TO_BE32 | ( | x | ) | Swap32(x) |
Least significant byte of 1st rank of u32.
Definition at line 847 of file compiler.h.
#define cpu_to_be32 | ( | x | ) | swap32(x) |
Least significant byte of 1st rank of u32.
Definition at line 845 of file compiler.h.
#define CPU_TO_LE16 | ( | x | ) | (x) |
Least significant byte of 1st rank of u32.
Definition at line 829 of file compiler.h.
#define cpu_to_le16 | ( | x | ) | (x) |
Least significant byte of 1st rank of u32.
Definition at line 827 of file compiler.h.
#define CPU_TO_LE32 | ( | x | ) | (x) |
Least significant byte of 1st rank of u32.
Definition at line 841 of file compiler.h.
#define cpu_to_le32 | ( | x | ) | (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.
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.
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, | |||
n | ) | ( Rd_bits( val, (n) - 1 ) ) |
Gets alignment of the number val with respect to the n boundary.
val | Input value. | |
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.
exp | Any expression |
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 | ) | (x) |
Least significant byte of 1st rank of u32.
Definition at line 825 of file compiler.h.
#define LE16_TO_CPU | ( | x | ) | (x) |
Least significant byte of 1st rank of u32.
Definition at line 828 of file compiler.h.
#define le16_to_cpu | ( | x | ) | (x) |
Least significant byte of 1st rank of u32.
Definition at line 826 of file compiler.h.
#define LE32 | ( | x | ) | (x) |
Least significant byte of 1st rank of u32.
Definition at line 837 of file compiler.h.
#define LE32_TO_CPU | ( | x | ) | (x) |
Least significant byte of 1st rank of u32.
Definition at line 840 of file compiler.h.
#define le32_to_cpu | ( | x | ) | (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.
addr | Address of the routine to call. |
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, | |||
b | ) | Max(a, b) |
Takes the absolute value of a.
a | Input value. |
Definition at line 721 of file compiler.h.
#define Max | ( | a, | |||
b | ) | (((a) > (b)) ? (a) : (b)) |
Takes the maximal value of a and b.
a | Input value. | |
b | Input value. |
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, | |||
b | ) | Min(a, b) |
Takes the absolute value of a.
a | Input value. |
Definition at line 709 of file compiler.h.
#define Min | ( | a, | |||
b | ) | (((a) < (b)) ? (a) : (b)) |
Takes the minimal value of a and b.
a | Input value. | |
b | Input value. |
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.
value | Value to read a bit-field from. | |
mask | Bit-mask indicating the bit-field to read. |
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.
value | Value to read bits from. | |
mask | Bit-mask indicating bits to read. |
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.
lval | Input/output lvalue. | |
n | Boundary. | |
alg | Alignment. |
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.
lvalue | C lvalue of which to set bits. | |
mask | Bit-mask indicating bits to set. |
Definition at line 469 of file compiler.h.
#define swap16 | ( | u16 | ) | Swap16(u16) |
Toggles the endianism of u16 (by swapping its bytes).
u16 | U16 of which to toggle the endianism. |
Definition at line 907 of file compiler.h.
#define Swap16 | ( | u16 | ) |
Toggles the endianism of u16 (by swapping its bytes).
u16 | U16 of which to toggle the endianism. |
Definition at line 874 of file compiler.h.
#define swap32 | ( | u32 | ) | Swap32(u32) |
Toggles the endianism of u32 (by swapping its bytes).
u32 | U32 of which to toggle the endianism. |
Definition at line 917 of file compiler.h.
#define Swap32 | ( | u32 | ) |
Toggles the endianism of u32 (by swapping its bytes).
u32 | U32 of which to toggle the endianism. |
Definition at line 885 of file compiler.h.
#define swap64 | ( | u64 | ) |
Toggles the endianism of u64 (by swapping its bytes).
u64 | U64 of which to toggle the endianism. |
Definition at line 927 of file compiler.h.
#define Swap64 | ( | u64 | ) |
Toggles the endianism of u64 (by swapping its bytes).
u64 | U64 of which to toggle the endianism. |
Definition at line 896 of file compiler.h.
#define Test_align | ( | val, | |||
n | ) | (!Tst_bits( val, (n) - 1 ) ) |
Tests alignment of the number val with the n boundary.
val | Input value. | |
n | Boundary. |
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.
lvalue | C lvalue of which to toggle bits. | |
mask | Bit-mask indicating bits to toggle. |
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.
value | Value of which to test bits. | |
mask | Bit-mask indicating bits to test. |
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.
lvalue | C lvalue to write a bit-field to. | |
mask | Bit-mask indicating the bit-field to write. | |
bitfield | Bit-field to write. |
Definition at line 497 of file compiler.h.
#define Wr_bits | ( | lvalue, | |||
mask, | |||||
bits | ) |
((lvalue) = ((lvalue) & ~(mask)) |\ ((bits ) & (mask)))
Writes the bits of a C lvalue specified by a given bit-mask.
lvalue | C lvalue to write bits to. | |
mask | Bit-mask indicating bits to write. | |
bits | Bits to write. |
Definition at line 441 of file compiler.h.
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.
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.
typedef Bool Status_bool_t |
Boolean status.
Definition at line 134 of file compiler.h.
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.
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.
x | A 32-bit value |
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 }
Generated on Fri Oct 22 12:15:25 2010 for AVR1300 Using the Xmega ADC by ![]() |