Microchip® Advanced Software Framework

avrtypes.h File Reference

Compatibility definitions for compilers (IAR, GCC)

This file contains AVR type definitions that enable Atmel's 802.15.4 stack implementation to build using multiple compilers. This file contains compiler conditional subsystems for AVR functions such as: interrupts, sleep mode, USARTs, etc.

Id:
avrtypes.h 27766 2011-07-19 12:14:15Z agasthian.s
Author
Microchip Technology Inc: http://www.microchip.com
Support: https://www.microchip.com/support/
#include <string.h>
#include <avr/io.h>
#include <avr/boot.h>
#include <avr/eeprom.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/wdt.h>
#include <util/crc16.h>

Macros

#define _BV(x)   (1 << (x))
 Bit value – compute the bitmask for a bit position. 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 ALIGN8BIT   /* AVR-GCC uses an 8-bit alignment anyway */
 
#define CAN_INITIALIZE_FLEXIBLE_ARRAY_MEMBERS   1
 
#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 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 EEGET(var, addr)   (var) = eeprom_read_byte((uint8_t *)(addr))
 
#define EEPROM_BUSY_WAIT()   eeprom_busy_wait()
 
#define EEPUT(addr, val)   eeprom_write_byte((uint8_t *)(addr), (uint8_t)(val))
 
#define ENABLE_RWW_SECTION()   boot_rww_enable()
 
#define ENABLE_XRAM(void)
 
#define FLASH_DECLARE(x)   const x __attribute__((__progmem__))
 
#define FLASH_ERASE(addr)   boot_page_erase(addr)
 
#define FLASH_EXTERN(x)   extern x __attribute__((__progmem__))
 
#define FLASH_PAGE_FILL(addr, data)   boot_page_fill(addr, data)
 
#define FLASH_PAGE_WRITE(addr)   boot_page_write(addr)
 
#define FLASH_STRING(x)   PSTR(x)
 
#define FLASH_STRING_T   PGM_P
 
#define FORCE_INLINE(type, name,...)
 
#define FUNC_PTR   void *
 
#define HAS_PGM_VSNPRINTF   1
 
#define LE16_TO_CPU_ENDIAN(x)   (x)
 
#define LE32_TO_CPU_ENDIAN(x)   (x)
 
#define LE64_TO_CPU_ENDIAN(x)   (x)
 
#define MEMCPY_ENDIAN   memcpy
 
#define nop()   do { __asm__ __volatile__ ("nop"); } while (0)
 
#define PACKED   __attribute__((packed))
 
#define PGM_READ_BLOCK(dst, src, len)   memcpy_P((dst), (src), (len))
 
#define PGM_READ_BYTE(x)   pgm_read_byte(x)
 
#define PGM_READ_BYTE_FAR(x)   pgm_read_byte_far(x)
 
#define PGM_READ_WORD(x)   pgm_read_word(x)
 
#define PGM_STRCPY(dst, src)   strcpy_P((dst), (src))
 
#define PGM_STRLEN(x)   strlen_P(x)
 
#define PGM_VSNPRINTF(dst, n, fmt, ap)   vsnprintf_P((dst), (n), (fmt), (ap))
 
#define PRINTF(fmt,...)   { static const char c[] PROGMEM = fmt; printf_P(c, __VA_ARGS__); }
 
#define PRINTF_FLASH_STRING   "%S"
 
#define PUTS(s)   { static const char c[] PROGMEM = s; printf_P(c); }
 
#define RAMFUNCTION
 
#define read_avr_fuse(n)
 
#define restore_irq_status()   (SREG = sreg)
 This macro must be used together with save_irq_status() and it will restore the content of the IRQ status. More...
 
#define RETURN_ENABLE_XRAM
 
#define save_irq_status()   (sreg = SREG)
 This macro saves the IRQ status and is typically used before cli(). More...
 
#define SET_SLEEP_MODE(x)   set_sleep_mode(x)
 
#define SHORTENUM   __attribute__ ((packed))
 
#define SLEEP_MODE()   sleep_mode()
 
#define SPM_BUSY_WAIT()   boot_spm_busy_wait()
 
#define WDT_DISABLE()   wdt_disable()
 
#define WDT_RESET()   wdt_reset()
 

#define _BV (   x)    (1 << (x))

Bit value – compute the bitmask for a bit position.

#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 ALIGN8BIT   /* AVR-GCC uses an 8-bit alignment anyway */
#define CAN_INITIALIZE_FLEXIBLE_ARRAY_MEMBERS   1
#define CCPU_ENDIAN_TO_LE64 (   x)    (x)
#define CLE16_TO_CPU_ENDIAN (   x)    (x)

Referenced by parse_mpdu().

#define CLE32_TO_CPU_ENDIAN (   x)    (x)
#define CLE64_TO_CPU_ENDIAN (   x)    (x)
#define CMD_ID_OCTET   (0)

Referenced by dispatch_event().

#define convert_16_bit_to_byte_address (   value,
  data 
)    ((*(uint16_t *)(data)) = (uint16_t)(value))

Referenced by build_data_frame().

#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))

Referenced by build_data_frame(), and transmit_frame().

#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 EEGET (   var,
  addr 
)    (var) = eeprom_read_byte((uint8_t *)(addr))
#define EEPROM_BUSY_WAIT ( )    eeprom_busy_wait()
#define EEPUT (   addr,
  val 
)    eeprom_write_byte((uint8_t *)(addr), (uint8_t)(val))
#define ENABLE_RWW_SECTION ( )    boot_rww_enable()
#define ENABLE_XRAM (   void)
Value:
void xram_init(void) __attribute__((naked)) __attribute((section(".init3")));\
void xram_init(void)
#define FLASH_DECLARE (   x)    const x __attribute__((__progmem__))
#define FLASH_ERASE (   addr)    boot_page_erase(addr)
#define FLASH_EXTERN (   x)    extern x __attribute__((__progmem__))
#define FLASH_PAGE_FILL (   addr,
  data 
)    boot_page_fill(addr, data)

Referenced by flash_fill_page_buffer().

#define FLASH_PAGE_WRITE (   addr)    boot_page_write(addr)

Referenced by flash_program_page().

#define FLASH_STRING (   x)    PSTR(x)
#define FLASH_STRING_T   PGM_P
#define FORCE_INLINE (   type,
  name,
  ... 
)
Value:
static inline type name(__VA_ARGS__) __attribute__((always_inline)); \
static inline type name(__VA_ARGS__)
#define HAS_PGM_VSNPRINTF   1
#define LE16_TO_CPU_ENDIAN (   x)    (x)

Referenced by usr_mcps_data_ind().

#define LE32_TO_CPU_ENDIAN (   x)    (x)
#define LE64_TO_CPU_ENDIAN (   x)    (x)
#define nop ( )    do { __asm__ __volatile__ ("nop"); } while (0)
#define PACKED   __attribute__((packed))
#define PGM_READ_BLOCK (   dst,
  src,
  len 
)    memcpy_P((dst), (src), (len))

Referenced by zrc_cmd_disc_indication().

#define PGM_READ_BYTE (   x)    pgm_read_byte(x)
#define PGM_READ_BYTE_FAR (   x)    pgm_read_byte_far(x)
#define PGM_READ_WORD (   x)    pgm_read_word(x)

Referenced by dispatch_event(), and vendor_data_ind().

#define PGM_STRCPY (   dst,
  src 
)    strcpy_P((dst), (src))
#define PGM_STRLEN (   x)    strlen_P(x)
#define PGM_VSNPRINTF (   dst,
  n,
  fmt,
  ap 
)    vsnprintf_P((dst), (n), (fmt), (ap))
#define PRINTF (   fmt,
  ... 
)    { static const char c[] PROGMEM = fmt; printf_P(c, __VA_ARGS__); }
#define PRINTF_FLASH_STRING   "%S"
#define PUTS (   s)    { static const char c[] PROGMEM = s; printf_P(c); }
#define RAMFUNCTION
#define read_avr_fuse (   n)
Value:
boot_lock_fuse_bits_get(((n) == 0? GET_LOW_FUSE_BITS:\
((n) == 1? GET_HIGH_FUSE_BITS: GET_EXTENDED_FUSE_BITS)))
#define restore_irq_status ( )    (SREG = sreg)

This macro must be used together with save_irq_status() and it will restore the content of the IRQ status.

#define RETURN_ENABLE_XRAM
#define save_irq_status ( )    (sreg = SREG)

This macro saves the IRQ status and is typically used before cli().

#define SET_SLEEP_MODE (   x)    set_sleep_mode(x)

Referenced by app_task().

#define SHORTENUM   __attribute__ ((packed))
#define SLEEP_MODE ( )    sleep_mode()

Referenced by app_task().

#define SPM_BUSY_WAIT ( )    boot_spm_busy_wait()
#define WDT_DISABLE ( )    wdt_disable()

Referenced by app_task().

#define WDT_RESET ( )    wdt_reset()

Referenced by app_task().