Compiler abstraction layer and code utilities for 8-bit AVR.
This module provides various abstraction layers and utilities to make code compatible between different compilers.
Modules | |
Assembler Support | |
This group provides a good handful of macros intended to smooth out the differences between various assemblers, similar to what compiler.h does for compilers, except that assemblers tend to be much less standardized than compilers. | |
Macro Repeat | |
Stringize | |
Token Paste | |
Program memory | |
Status Codes | |
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... | |
Macros | |
#define | __always_inline inline __attribute__((__always_inline__)) |
The function should always be inlined. More... | |
#define | ADDR_COPY_DST_SRC_16(dst, src) memcpy((&(dst)), (&(src)), sizeof(uint16_t)) |
#define | ADDR_COPY_DST_SRC_64(dst, src) memcpy((&(dst)), (&(src)), sizeof(uint64_t)) |
#define | Assert(expr) ((void) 0) |
This macro is used to test fatal errors. More... | |
#define | barrier() asm volatile("" ::: "memory") |
Memory barrier. More... | |
#define | CCPU_ENDIAN_TO_LE16(x) (x) |
#define | CCPU_ENDIAN_TO_LE32(x) (x) |
#define | CCPU_ENDIAN_TO_LE64(x) (x) |
#define | CLE16_TO_CPU_ENDIAN(x) (x) |
#define | CLE32_TO_CPU_ENDIAN(x) (x) |
#define | CLE64_TO_CPU_ENDIAN(x) (x) |
#define | CMD_ID_OCTET (0) |
#define | COMPILER_ALIGNED(a) __attribute__((__aligned__(a))) |
Set aligned boundary. More... | |
#define | COMPILER_PACK_RESET(alignment) |
#define | COMPILER_PACK_SET(alignment) |
#define | COMPILER_PRAGMA(arg) _Pragma(#arg) |
Emit the compiler pragma arg. More... | |
#define | COMPILER_WORD_ALIGNED __attribute__((__aligned__(2))) |
Set word-aligned boundary. More... | |
#define | convert_16_bit_to_byte_address(value, data) ((*(uint16_t *)(data)) = (uint16_t)(value)) |
#define | convert_16_bit_to_byte_array(value, data) ((*(uint16_t *)(data)) = (uint16_t)(value)) |
#define | convert_32_bit_to_byte_array(value, data) ((*(uint32_t *)(data)) = (uint32_t)(value)) |
#define | convert_64_bit_to_byte_array(value, data) memcpy((data), (&(value)), sizeof(uint64_t)) |
#define | convert_byte_array_to_16_bit(data) (*(uint16_t *)(data)) |
#define | convert_byte_array_to_32_bit(data) (*(uint32_t *)(data)) |
#define | convert_byte_array_to_64_bit(data) (*(uint64_t *)(data)) |
#define | convert_spec_16_bit_to_byte_array(value, data) ((*(uint16_t *)(data)) = (uint16_t)(value)) |
#define | CPU_ENDIAN_TO_LE16(x) (x) |
#define | CPU_ENDIAN_TO_LE32(x) (x) |
#define | CPU_ENDIAN_TO_LE64(x) (x) |
#define | div_ceil(a, b) (((a) + (b) - 1) / (b)) |
Calculate \( \left\lceil \frac{a}{b} \right\rceil \) using integer arithmetic. More... | |
#define | FLASH_DECLARE(x) const x __attribute__((__progmem__)) |
#define | FLASH_EXTERN(x) extern const x |
#define | FUNC_PTR void * |
#define | LE16_TO_CPU_ENDIAN(x) (x) |
#define | LE32_TO_CPU_ENDIAN(x) (x) |
#define | LE64_TO_CPU_ENDIAN(x) (x) |
#define | Long_call(addr) ((*(void (*)(void))(addr))()) |
Calls the routine at address addr. More... | |
#define | MEMCPY_ENDIAN memcpy |
#define | nop() do { __asm__ __volatile__ ("nop"); } while (0) |
#define | PGM_READ_BLOCK(dst, src, len) memcpy_P((dst), (src), (len)) |
#define | PGM_READ_BYTE(x) pgm_read_byte(x) |
#define | PGM_READ_WORD(x) pgm_read_word(x) |
#define | SHORTENUM __attribute__ ((packed)) |
#define | UNUSED(v) (void)(v) |
Marking v as a unused parameter or value. More... | |
#define | unused(v) do { (void)(v); } while(0) |
Marking v as a unused parameter or value. More... | |
Tag functions as deprecated | |
Tagging a function as deprecated will produce a warning when and only when the function is called. Usage is to add the DEPRECATED symbol before the function definition. E.g.: DEPRECATED uint8_t some_deprecated_function (void) { ... }
| |
#define | __DEPRECATED__ __attribute__((__deprecated__)) |
Usual Types | |
typedef unsigned char | Bool |
Boolean. More... | |
typedef unsigned char | bool |
Boolean. More... | |
typedef int8_t | S8 |
8-bit signed integer. More... | |
typedef uint8_t | U8 |
8-bit unsigned integer. More... | |
typedef int16_t | S16 |
16-bit signed integer. More... | |
typedef uint16_t | U16 |
16-bit unsigned integer. More... | |
typedef uint16_t | le16_t |
typedef uint16_t | be16_t |
typedef int32_t | S32 |
32-bit signed integer. More... | |
typedef uint32_t | U32 |
32-bit unsigned integer. More... | |
typedef uint32_t | le32_t |
typedef uint32_t | be32_t |
typedef int64_t | S64 |
64-bit signed integer. More... | |
typedef uint64_t | U64 |
64-bit unsigned integer. More... | |
typedef float | F32 |
32-bit floating-point number. More... | |
typedef double | F64 |
64-bit floating-point number. More... | |
typedef uint16_t | iram_size_t |
Status Types | |
typedef Bool | Status_bool_t |
Boolean status. More... | |
typedef U8 | Status_t |
8-bit-coded status. More... | |
Usual Constants | |
#define | DISABLE 0 |
#define | ENABLE 1 |
#define | false 0 |
#define | true 1 |
#define | PASS 0 |
#define | FAIL 1 |
#define | LOW 0 |
#define | HIGH 1 |
Compile time error handling | |
#define | ERROR_FUNC(name, msg) extern int name(void) |
Fail compilation if function call isn't eliminated. More... | |
Function call demultiplexing | |
ERROR_FUNC (compiler_demux_bad_size,"Invalid parameter size") | |
Error function for failed demultiplexing. More... | |
#define | compiler_demux_size(size, func,...) |
Demultiplex function call based on size of datatype. More... | |
Optimization Control | |
#define | __always_optimize __attribute__((optimize(3))) |
The function should always be optimized. More... | |
#define | likely(exp) (exp) |
The expression exp is likely to be true. More... | |
#define | unlikely(exp) (exp) |
The expression exp is unlikely to be true. More... | |
#define | is_constant(exp) __builtin_constant_p(exp) |
Determine if an expression evaluates to a constant value. More... | |
Bit-Field Handling | |
#define | Rd_bits(value, mask) ((value)&(mask)) |
Reads the bits of a value specified by a given bit-mask. More... | |
#define | Wr_bits(lvalue, mask, bits) |
Writes the bits of a C lvalue specified by a given bit-mask. More... | |
#define | Tst_bits(value, mask) (Rd_bits(value, mask) != 0) |
Tests the bits of a value specified by a given bit-mask. More... | |
#define | Clr_bits(lvalue, mask) ((lvalue) &= ~(mask)) |
Clears the bits of a C lvalue specified by a given bit-mask. More... | |
#define | Set_bits(lvalue, mask) ((lvalue) |= (mask)) |
Sets the bits of a C lvalue specified by a given bit-mask. More... | |
#define | Tgl_bits(lvalue, mask) ((lvalue) ^= (mask)) |
Toggles the bits of a C lvalue specified by a given bit-mask. More... | |
#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. More... | |
#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. More... | |
Bit Reversing | |
#define | bit_reverse8(u8) ((U8)(bit_reverse32((U8)(u8)) >> 24)) |
Reverses the bits of u8. More... | |
#define | bit_reverse16(u16) ((U16)(bit_reverse32((U16)(u16)) >> 16)) |
Reverses the bits of u16. More... | |
#define | bit_reverse32(u32) |
Reverses the bits of u32. More... | |
#define | bit_reverse64(u64) |
Reverses the bits of u64. More... | |
Logarithmic functions | |
int_fast8_t | ilog2_undefined (void) |
static int_fast8_t | ilog2 (uint32_t x) |
Calculate the base-2 logarithm of a number rounded down to the nearest integer. More... | |
Alignment | |
#define | Test_align(val, n) (!Tst_bits( val, (n) - 1 ) ) |
Tests alignment of the number val with the n boundary. More... | |
#define | Get_align(val, n) ( Rd_bits( val, (n) - 1 ) ) |
Gets alignment of the number val with respect to the n boundary. More... | |
#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. More... | |
#define | Align_up(val, n) (((val) + ((n) - 1)) & ~((n) - 1)) |
Aligns the number val with the upper n boundary. More... | |
#define | Align_down(val, n) ( (val) & ~((n) - 1)) |
Aligns the number val with the lower n boundary. More... | |
Mathematics | |
Compiler optimization for non-constant expressions, only for abs under WinAVR | |
#define | Abs(a) (((a) < 0 ) ? -(a) : (a)) |
Takes the absolute value of a. More... | |
#define | abs(a) Abs(a) |
#define | Min(a, b) (((a) < (b)) ? (a) : (b)) |
Takes the minimal value of a and b. More... | |
#define | min(a, b) Min(a, b) |
#define | Max(a, b) (((a) > (b)) ? (a) : (b)) |
Takes the maximal value of a and b. More... | |
#define | max(a, b) Max(a, b) |
System Register Access | |
#define | Get_system_register(sysreg) __builtin_mfsr(sysreg) |
Gets the value of the sysreg system register. More... | |
#define | Set_system_register(sysreg, value) __builtin_mtsr(sysreg, value) |
Sets the value of the sysreg system register to value. More... | |
Debug Register Access | |
#define | Get_debug_register(dbgreg) __builtin_mfdr(dbgreg) |
Gets the value of the dbgreg debug register. More... | |
#define | Set_debug_register(dbgreg, value) __builtin_mtdr(dbgreg, value) |
Sets the value of the dbgreg debug register to value. More... | |
MCU Endianism Handling | |
#define | MSB(u16) (((uint8_t* )&u16)[1]) |
#define | LSB(u16) (((uint8_t* )&u16)[0]) |
#define | MSW(u32) (((uint16_t*)&u32)[1]) |
#define | LSW(u32) (((uint16_t*)&u32)[0]) |
#define | MSB0W(u32) (((uint8_t*)&(u32))[3]) |
Most significant byte of 1st rank of u32. More... | |
#define | MSB1W(u32) (((uint8_t*)&(u32))[2]) |
Most significant byte of 2nd rank of u32. More... | |
#define | MSB2W(u32) (((uint8_t*)&(u32))[1]) |
Most significant byte of 3rd rank of u32. More... | |
#define | MSB3W(u32) (((uint8_t*)&(u32))[0]) |
Most significant byte of 4th rank of u32. More... | |
#define | LSB3W(u32) MSB0W(u32) |
Least significant byte of 4th rank of u32. More... | |
#define | LSB2W(u32) MSB1W(u32) |
Least significant byte of 3rd rank of u32. More... | |
#define | LSB1W(u32) MSB2W(u32) |
Least significant byte of 2nd rank of u32. More... | |
#define | LSB0W(u32) MSB3W(u32) |
Least significant byte of 1st rank of u32. More... | |
#define | MSB0(u32) (((uint8_t*)&u32)[3]) |
#define | MSB1(u32) (((uint8_t*)&u32)[2]) |
#define | MSB2(u32) (((uint8_t*)&u32)[1]) |
#define | MSB3(u32) (((uint8_t*)&u32)[0]) |
#define | LSB0(u32) MSB3(u32) |
#define | LSB1(u32) MSB2(u32) |
#define | LSB2(u32) MSB1(u32) |
#define | LSB3(u32) MSB0(u32) |
#define | LE16(x) (x) |
#define | le16_to_cpu(x) (x) |
#define | cpu_to_le16(x) (x) |
#define | LE16_TO_CPU(x) (x) |
#define | CPU_TO_LE16(x) (x) |
#define | BE16(x) Swap16(x) |
#define | be16_to_cpu(x) swap16(x) |
#define | cpu_to_be16(x) swap16(x) |
#define | BE16_TO_CPU(x) Swap16(x) |
#define | CPU_TO_BE16(x) Swap16(x) |
#define | LE32(x) (x) |
#define | le32_to_cpu(x) (x) |
#define | cpu_to_le32(x) (x) |
#define | LE32_TO_CPU(x) (x) |
#define | CPU_TO_LE32(x) (x) |
#define | BE32(x) Swap32(x) |
#define | be32_to_cpu(x) swap32(x) |
#define | cpu_to_be32(x) swap32(x) |
#define | BE32_TO_CPU(x) Swap32(x) |
#define | CPU_TO_BE32(x) Swap32(x) |
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) |
Toggles the endianism of u16 (by swapping its bytes). More... | |
#define | Swap32(u32) |
Toggles the endianism of u32 (by swapping its bytes). More... | |
#define | Swap64(u64) |
Toggles the endianism of u64 (by swapping its bytes). More... | |
#define | swap16(u16) Swap16(u16) |
Toggles the endianism of u16 (by swapping its bytes). More... | |
#define | swap32(u32) Swap32(u32) |
Toggles the endianism of u32 (by swapping its bytes). More... | |
#define | swap64(u64) |
Toggles the endianism of u64 (by swapping its bytes). More... | |
Target Abstraction | |
typedef U8 | Byte |
8-bit unsigned integer. More... | |
#define | _GLOBEXT_ extern |
extern storage-class specifier. More... | |
#define | _CONST_TYPE_ const |
const type qualifier. More... | |
#define | _MEM_TYPE_SLOW_ |
Slow memory type. More... | |
#define | _MEM_TYPE_MEDFAST_ |
Fairly fast memory type. More... | |
#define | _MEM_TYPE_FAST_ |
Fast memory type. More... | |
#define | memcmp_ram2ram memcmp |
Target-specific memcmp of RAM to RAM. More... | |
#define | memcmp_code2ram memcmp |
Target-specific memcmp of RAM to NVRAM. More... | |
#define | memcpy_ram2ram memcpy |
Target-specific memcpy from RAM to RAM. More... | |
#define | memcpy_code2ram memcpy |
Target-specific memcpy from NVRAM to RAM. More... | |
#define __always_inline inline __attribute__((__always_inline__)) |
The function should always be inlined.
This annotation instructs the compiler to ignore its inlining heuristics and inline the function no matter how big it thinks it becomes.
#define __always_optimize __attribute__((optimize(3))) |
The function should always be optimized.
This annotation instructs the compiler to ignore global optimization settings and always compile the function with a high level of optimization.
#define __DEPRECATED__ __attribute__((__deprecated__)) |
#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 Abs | ( | a | ) | (((a) < 0 ) ? -(a) : (a)) |
Takes the absolute value of a.
a | Input value. |
#define abs | ( | a | ) | Abs(a) |
#define ADDR_COPY_DST_SRC_16 | ( | dst, | |
src | |||
) | memcpy((&(dst)), (&(src)), sizeof(uint16_t)) |
#define ADDR_COPY_DST_SRC_64 | ( | dst, | |
src | |||
) | memcpy((&(dst)), (&(src)), sizeof(uint64_t)) |
#define Align_down | ( | val, | |
n | |||
) | ( (val) & ~((n) - 1)) |
Aligns the number val with the lower n boundary.
val | Input value. |
n | Boundary. |
#define Align_up | ( | val, | |
n | |||
) | (((val) + ((n) - 1)) & ~((n) - 1)) |
Aligns the number val with the upper n boundary.
val | Input value. |
n | Boundary. |
#define Assert | ( | expr | ) | ((void) 0) |
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. If TEST_SUITE_DEFINE_ASSERT_MACRO is defined, a unit test version of the macro is used, to allow execution of further tests after a false expression.
expr | Expression to evaluate and supposed to be nonzero. |
Referenced by osc_disable(), osc_disable_autocalibration(), osc_enable_autocalibration(), osc_enable_external(), osc_enable_internal(), osc_get_rate(), osc_is_ready(), osc_user_calibration(), pll_config_init(), pll_config_read(), pll_config_write(), pll_disable(), pll_enable(), pll_enable_config_defaults(), pll_enable_source(), 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_get_sleep_mode(), sleepmgr_sleep(), sysclk_disable_peripheral_clock(), sysclk_enable_peripheral_clock(), sysclk_get_peripheral_bus_hz(), sysclk_init(), and sysclk_rtcsrc_enable().
#define barrier | ( | ) | asm volatile("" ::: "memory") |
Memory barrier.
Referenced by cpu_irq_restore(), and twim_release().
#define BE16 | ( | x | ) | Swap16(x) |
#define be16_to_cpu | ( | x | ) | swap16(x) |
#define BE16_TO_CPU | ( | x | ) | Swap16(x) |
#define BE32 | ( | x | ) | Swap32(x) |
#define be32_to_cpu | ( | x | ) | swap32(x) |
#define BE32_TO_CPU | ( | x | ) | Swap32(x) |
#define bit_reverse16 | ( | u16 | ) | ((U16)(bit_reverse32((U16)(u16)) >> 16)) |
Reverses the bits of u16.
u16 | U16 of which to reverse the bits. |
#define bit_reverse32 | ( | u32 | ) |
#define bit_reverse64 | ( | u64 | ) |
Reverses the bits of u64.
u64 | U64 of which to reverse the bits. |
#define bit_reverse8 | ( | u8 | ) | ((U8)(bit_reverse32((U8)(u8)) >> 24)) |
Reverses the bits of u8.
u8 | U8 of which to reverse the bits. |
#define CCPU_ENDIAN_TO_LE16 | ( | x | ) | (x) |
#define CCPU_ENDIAN_TO_LE32 | ( | x | ) | (x) |
#define CCPU_ENDIAN_TO_LE64 | ( | x | ) | (x) |
#define CLE16_TO_CPU_ENDIAN | ( | x | ) | (x) |
#define CLE32_TO_CPU_ENDIAN | ( | x | ) | (x) |
#define CLE64_TO_CPU_ENDIAN | ( | x | ) | (x) |
#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. |
#define CMD_ID_OCTET (0) |
#define COMPILER_ALIGNED | ( | a | ) | __attribute__((__aligned__(a))) |
Set aligned boundary.
#define compiler_demux_size | ( | size, | |
func, | |||
... | |||
) |
Demultiplex function call based on size of datatype.
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:
size | Size of the datatype. |
func | Base function name. |
... | List of parameters to pass to the function. |
#define COMPILER_PACK_RESET | ( | alignment | ) |
#define COMPILER_PACK_SET | ( | alignment | ) |
#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). |
#define COMPILER_WORD_ALIGNED __attribute__((__aligned__(2))) |
Set word-aligned boundary.
#define convert_16_bit_to_byte_address | ( | value, | |
data | |||
) | ((*(uint16_t *)(data)) = (uint16_t)(value)) |
#define convert_16_bit_to_byte_array | ( | value, | |
data | |||
) | ((*(uint16_t *)(data)) = (uint16_t)(value)) |
#define convert_32_bit_to_byte_array | ( | value, | |
data | |||
) | ((*(uint32_t *)(data)) = (uint32_t)(value)) |
#define convert_64_bit_to_byte_array | ( | value, | |
data | |||
) | memcpy((data), (&(value)), sizeof(uint64_t)) |
#define convert_byte_array_to_16_bit | ( | data | ) | (*(uint16_t *)(data)) |
#define convert_byte_array_to_32_bit | ( | data | ) | (*(uint32_t *)(data)) |
#define convert_byte_array_to_64_bit | ( | data | ) | (*(uint64_t *)(data)) |
#define convert_spec_16_bit_to_byte_array | ( | value, | |
data | |||
) | ((*(uint16_t *)(data)) = (uint16_t)(value)) |
#define CPU_ENDIAN_TO_LE16 | ( | x | ) | (x) |
#define CPU_ENDIAN_TO_LE32 | ( | x | ) | (x) |
#define CPU_ENDIAN_TO_LE64 | ( | x | ) | (x) |
#define cpu_to_be16 | ( | x | ) | swap16(x) |
#define CPU_TO_BE16 | ( | x | ) | Swap16(x) |
#define cpu_to_be32 | ( | x | ) | swap32(x) |
#define CPU_TO_BE32 | ( | x | ) | Swap32(x) |
#define cpu_to_le16 | ( | x | ) | (x) |
#define CPU_TO_LE16 | ( | x | ) | (x) |
#define cpu_to_le32 | ( | x | ) | (x) |
#define CPU_TO_LE32 | ( | x | ) | (x) |
#define DISABLE 0 |
#define div_ceil | ( | a, | |
b | |||
) | (((a) + (b) - 1) / (b)) |
Calculate \( \left\lceil \frac{a}{b} \right\rceil \) using integer arithmetic.
a | An integer |
b | Another integer |
#define ENABLE 1 |
#define ERROR_FUNC | ( | name, | |
msg | |||
) | extern int name(void) |
Fail compilation if function call isn't eliminated.
If the compiler fails to optimize away all calls to the function name, terminate compilation and display msg to the user.
#define FAIL 1 |
#define false 0 |
#define FLASH_DECLARE | ( | x | ) | const x __attribute__((__progmem__)) |
#define FLASH_EXTERN | ( | x | ) | extern const x |
#define FUNC_PTR void * |
#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. |
#define Get_debug_register | ( | dbgreg | ) | __builtin_mfdr(dbgreg) |
Gets the value of the dbgreg debug register.
dbgreg | Address of the debug register of which to get the value. |
#define Get_system_register | ( | sysreg | ) | __builtin_mfsr(sysreg) |
Gets the value of the sysreg system register.
sysreg | Address of the system register of which to get the value. |
#define HIGH 1 |
#define is_constant | ( | exp | ) | __builtin_constant_p(exp) |
Determine if an expression evaluates to a constant value.
exp | Any expression |
Referenced by ilog2().
#define LE16 | ( | x | ) | (x) |
#define le16_to_cpu | ( | x | ) | (x) |
#define LE16_TO_CPU | ( | x | ) | (x) |
#define LE16_TO_CPU_ENDIAN | ( | x | ) | (x) |
#define LE32 | ( | x | ) | (x) |
#define le32_to_cpu | ( | x | ) | (x) |
#define LE32_TO_CPU | ( | x | ) | (x) |
#define LE32_TO_CPU_ENDIAN | ( | x | ) | (x) |
#define LE64_TO_CPU_ENDIAN | ( | x | ) | (x) |
#define likely | ( | exp | ) | (exp) |
The expression exp is likely to be true.
#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. |
#define LOW 0 |
#define LSB | ( | u16 | ) | (((uint8_t* )&u16)[0]) |
Referenced by osc_user_calibration(), and sysclk_init().
#define LSB0 | ( | u32 | ) | MSB3(u32) |
#define LSB0W | ( | u32 | ) | MSB3W(u32) |
Least significant byte of 1st rank of u32.
#define LSB1 | ( | u32 | ) | MSB2(u32) |
#define LSB1W | ( | u32 | ) | MSB2W(u32) |
Least significant byte of 2nd rank of u32.
#define LSB2 | ( | u32 | ) | MSB1(u32) |
#define LSB2W | ( | u32 | ) | MSB1W(u32) |
Least significant byte of 3rd rank of u32.
#define LSB3 | ( | u32 | ) | MSB0(u32) |
#define LSB3W | ( | u32 | ) | MSB0W(u32) |
Least significant byte of 4th rank of u32.
#define LSW | ( | u32 | ) | (((uint16_t*)&u32)[0]) |
#define Max | ( | a, | |
b | |||
) | (((a) > (b)) ? (a) : (b)) |
Takes the maximal value of a and b.
a | Input value. |
b | Input value. |
#define max | ( | a, | |
b | |||
) | Max(a, b) |
#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_ENDIAN memcpy |
#define memcpy_ram2ram memcpy |
Target-specific memcpy from RAM to RAM.
#define Min | ( | a, | |
b | |||
) | (((a) < (b)) ? (a) : (b)) |
Takes the minimal value of a and b.
a | Input value. |
b | Input value. |
#define min | ( | a, | |
b | |||
) | Min(a, b) |
#define MSB | ( | u16 | ) | (((uint8_t* )&u16)[1]) |
Referenced by osc_user_calibration(), and sysclk_init().
#define MSB0 | ( | u32 | ) | (((uint8_t*)&u32)[3]) |
#define MSB0W | ( | u32 | ) | (((uint8_t*)&(u32))[3]) |
Most significant byte of 1st rank of u32.
#define MSB1 | ( | u32 | ) | (((uint8_t*)&u32)[2]) |
#define MSB1W | ( | u32 | ) | (((uint8_t*)&(u32))[2]) |
Most significant byte of 2nd rank of u32.
#define MSB2 | ( | u32 | ) | (((uint8_t*)&u32)[1]) |
#define MSB2W | ( | u32 | ) | (((uint8_t*)&(u32))[1]) |
Most significant byte of 3rd rank of u32.
#define MSB3 | ( | u32 | ) | (((uint8_t*)&u32)[0]) |
#define MSB3W | ( | u32 | ) | (((uint8_t*)&(u32))[0]) |
Most significant byte of 4th rank of u32.
#define MSW | ( | u32 | ) | (((uint16_t*)&u32)[1]) |
#define nop | ( | ) | do { __asm__ __volatile__ ("nop"); } while (0) |
#define PASS 0 |
#define PGM_READ_BLOCK | ( | dst, | |
src, | |||
len | |||
) | memcpy_P((dst), (src), (len)) |
#define PGM_READ_BYTE | ( | x | ) | pgm_read_byte(x) |
#define PGM_READ_WORD | ( | x | ) | pgm_read_word(x) |
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. |
#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. |
#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. |
#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. |
#define Set_debug_register | ( | dbgreg, | |
value | |||
) | __builtin_mtdr(dbgreg, value) |
Sets the value of the dbgreg debug register to value.
dbgreg | Address of the debug register of which to set the value. |
value | Value to set the dbgreg debug register to. |
#define Set_system_register | ( | sysreg, | |
value | |||
) | __builtin_mtsr(sysreg, value) |
Sets the value of the sysreg system register to value.
sysreg | Address of the system register of which to set the value. |
value | Value to set the sysreg system register to. |
#define SHORTENUM __attribute__ ((packed)) |
#define Swap16 | ( | u16 | ) |
Toggles the endianism of u16 (by swapping its bytes).
u16 | U16 of which to toggle the endianism. |
#define swap16 | ( | u16 | ) | Swap16(u16) |
Toggles the endianism of u16 (by swapping its bytes).
u16 | U16 of which to toggle the endianism. |
#define Swap32 | ( | u32 | ) |
Toggles the endianism of u32 (by swapping its bytes).
u32 | U32 of which to toggle the endianism. |
#define swap32 | ( | u32 | ) | Swap32(u32) |
Toggles the endianism of u32 (by swapping its bytes).
u32 | U32 of which to toggle the endianism. |
#define Swap64 | ( | u64 | ) |
Toggles the endianism of u64 (by swapping its bytes).
u64 | U64 of which to toggle the endianism. |
#define swap64 | ( | u64 | ) |
Toggles the endianism of u64 (by swapping its bytes).
u64 | U64 of which to toggle the endianism. |
#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
. #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. |
#define true 1 |
#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
. #define unlikely | ( | exp | ) | (exp) |
The expression exp is unlikely to be true.
#define UNUSED | ( | v | ) | (void)(v) |
Marking v as a unused parameter or value.
Referenced by sleepmgr_lock_mode(), sleepmgr_unlock_mode(), and sysclk_init().
#define unused | ( | v | ) | do { (void)(v); } while(0) |
Marking v as a unused parameter or value.
#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. |
#define Wr_bits | ( | lvalue, | |
mask, | |||
bits | |||
) |
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. |
typedef uint16_t be16_t |
typedef uint32_t be32_t |
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 |
typedef uint16_t le16_t |
typedef uint32_t le32_t |
typedef int16_t S16 |
16-bit signed integer.
typedef int32_t S32 |
32-bit signed integer.
typedef int64_t S64 |
64-bit signed integer.
typedef int8_t S8 |
8-bit signed integer.
typedef Bool Status_bool_t |
Boolean status.
typedef uint16_t U16 |
16-bit unsigned integer.
typedef uint32_t U32 |
32-bit unsigned integer.
typedef uint64_t U64 |
64-bit unsigned integer.
typedef uint8_t U8 |
8-bit unsigned integer.
ERROR_FUNC | ( | compiler_demux_bad_size | , |
"Invalid parameter size" | |||
) |
Error function for failed demultiplexing.
|
inlinestatic |
Calculate the base-2 logarithm of a number rounded down to the nearest integer.
x | A 32-bit value |
References clz, ilog2_undefined(), and is_constant.