Microchip® Advanced Software Framework

pal_config.h File Reference

Board specific configuration file.

To use this board, define BOARD=AVR477_REMOTE.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include "pal_boardtypes.h"
#include "return_val.h"

Macros

#define ALERT_INDICATE()
 Alert indication One loop cycle below is about 6 clock cycles (or more, depending on optimization settings), so it takes 2...3 loop iterations per microsecond. More...
 
#define ALERT_INIT()
 Alert initialization. More...
 
#define BUTTON_INPUT_PINS   (PINE)
 Input pins for buttons. More...
 
#define BUTTON_PIN_0   (PE5)
 Button 0 pin. More...
 
#define BUTTON_PORT   (PORTE)
 Port for buttons. More...
 
#define BUTTON_PORT_DIR   (DDRE)
 Port directions for buttons. More...
 
#define EE_IEEE_ADDR   (0)
 This board has an external eeprom that stores the IEEE address and other information. More...
 
#define EE_XTAL_TRIM_ADDR   (21)
 Storage location for crystal trim value in external EEPROM. More...
 
#define EXT_EE_CS_DDR   (DDRG)
 Data direction register for the external EEPROM's chip select. More...
 
#define EXT_EE_CS_PIN   (0x20) /* PG5 */
 Pin where the external EEPROM's chip select is connected to. More...
 
#define EXT_EE_CS_PORT   (PORTG)
 Port where the external EEPROM's chip select is connected to. More...
 
#define F_CPU   (16000000UL)
 The default CPU clock. More...
 
#define LED_PIN_0   (PE2)
 LED 0 pin. More...
 
#define LED_PIN_1   (PE3)
 LED 1 pin. More...
 
#define LED_PIN_2   (PE4)
 LED 2 pin. More...
 
#define LED_PORT   (PORTE)
 Port for LEDs. More...
 
#define LED_PORT_DIR   (DDRE)
 Port directions for LEDs. More...
 
#define NO_OF_BUTTONS   (1)
 Number of buttons provided by this board. More...
 
#define NO_OF_LEDS   (3)
 Number of LEDs provided by this board. More...
 
#define PAL_WAIT_65_NS()
 Wait for 65 ns. More...
 
#define TST_PIN_0_HIGH()
 
#define TST_PIN_0_LOW()
 
#define TST_PIN_1_HIGH()
 
#define TST_PIN_1_LOW()
 
#define TST_PIN_2_HIGH()
 
#define TST_PIN_2_LOW()
 
#define TST_PIN_3_HIGH()
 
#define TST_PIN_3_LOW()
 
#define TST_PIN_4_HIGH()
 
#define TST_PIN_4_LOW()
 
#define TST_PIN_5_HIGH()
 
#define TST_PIN_5_LOW()
 
#define TST_PIN_6_HIGH()
 
#define TST_PIN_6_LOW()
 
#define TST_PIN_7_HIGH()
 
#define TST_PIN_7_LOW()
 
#define TST_PIN_8_HIGH()
 
#define TST_PIN_8_LOW()
 
#define UART_0_INIT_NON_GENERIC()
 UART0 non-generic (board specific) initialization part not used. More...
 
#define UART_1_INIT_NON_GENERIC()
 UART1 non-generic (board specific) initialization part not used. More...
 

Typedefs

typedef enum button_id_tag button_id_t
 Enumerations used to identify buttons. More...
 
typedef enum led_id_tag led_id_t
 This section describes the Board Configuration for RCB V6.3 with ATmega128RFA1. More...
 

Enumerations

enum  button_id_tag { BUTTON_0 }
 Enumerations used to identify buttons. More...
 
enum  led_id_tag {
  LED_0,
  LED_1,
  LED_2
}
 This section describes the Board Configuration for RCB V6.3 with ATmega128RFA1. More...
 

#define ALERT_INDICATE ( )
Value:
do { \
LED_PORT ^= 0xFF; \
} while (0)
#define LED_PORT
Port for LEDs.
Definition: pal_config.h:260

Alert indication One loop cycle below is about 6 clock cycles (or more, depending on optimization settings), so it takes 2...3 loop iterations per microsecond.

60000 cycles thus results in 20...30 ms of delay, so the LEDs should be seen as flickering.

#define ALERT_INIT ( )
Value:
do { \
LED_PORT_DIR = 0xFF; \
} while (0)
#define LED_PORT_DIR
Port directions for LEDs.
Definition: pal_config.h:261
#define LED_PORT
Port for LEDs.
Definition: pal_config.h:260

Alert initialization.

#define BUTTON_INPUT_PINS   (PINE)

Input pins for buttons.

#define BUTTON_PIN_0   (PE5)

Button 0 pin.

#define BUTTON_PORT   (PORTE)

Port for buttons.

#define BUTTON_PORT_DIR   (DDRE)

Port directions for buttons.

#define EE_IEEE_ADDR   (0)

This board has an external eeprom that stores the IEEE address and other information.

IEEE address of board in external EEPROM

#define EE_XTAL_TRIM_ADDR   (21)

Storage location for crystal trim value in external EEPROM.

#define EXT_EE_CS_DDR   (DDRG)

Data direction register for the external EEPROM's chip select.

#define EXT_EE_CS_PIN   (0x20) /* PG5 */

Pin where the external EEPROM's chip select is connected to.

#define EXT_EE_CS_PORT   (PORTG)

Port where the external EEPROM's chip select is connected to.

#define F_CPU   (16000000UL)

The default CPU clock.

The board must be configured for 16 MHz clock, which can be fused for either the 16 MHz internal RC oscillator, or for the 16 MHz crystal oscillator that is required for the transceiver operation. If F_CPU is set to 4 or 8 MHz, the prescaler reduces the CPU clock. One of the following lines need to be enabled.

#define LED_PIN_0   (PE2)

LED 0 pin.

#define LED_PIN_1   (PE3)

LED 1 pin.

#define LED_PIN_2   (PE4)

LED 2 pin.

#define LED_PORT   (PORTE)

Port for LEDs.

#define LED_PORT_DIR   (DDRE)

Port directions for LEDs.

#define NO_OF_BUTTONS   (1)

Number of buttons provided by this board.

#define NO_OF_LEDS   (3)

Number of LEDs provided by this board.

#define PAL_WAIT_65_NS ( )

Wait for 65 ns.

time t7: SLP_TR time (see data sheet or SWPM). In case the system clock is slower than 32 MHz we do not need to have this value filled.

#define TST_PIN_0_HIGH ( )
#define TST_PIN_0_LOW ( )
#define TST_PIN_1_HIGH ( )
#define TST_PIN_1_LOW ( )
#define TST_PIN_2_HIGH ( )
#define TST_PIN_2_LOW ( )
#define TST_PIN_3_HIGH ( )
#define TST_PIN_3_LOW ( )
#define TST_PIN_4_HIGH ( )
#define TST_PIN_4_LOW ( )
#define TST_PIN_5_HIGH ( )
#define TST_PIN_5_LOW ( )
#define TST_PIN_6_HIGH ( )
#define TST_PIN_6_LOW ( )
#define TST_PIN_7_HIGH ( )
#define TST_PIN_7_LOW ( )
#define TST_PIN_8_HIGH ( )
#define TST_PIN_8_LOW ( )
#define UART_0_INIT_NON_GENERIC ( )

UART0 non-generic (board specific) initialization part not used.

#define UART_1_INIT_NON_GENERIC ( )

UART1 non-generic (board specific) initialization part not used.

typedef enum button_id_tag button_id_t

Enumerations used to identify buttons.

typedef enum led_id_tag led_id_t

This section describes the Board Configuration for RCB V6.3 with ATmega128RFA1.

The board RCB V6.3 with ATmega128RFA1 provides an IEEE 802.15.4 single chip solution for the 2.4 GHz band.

For more information about this board see the AVR2025 MAC User Guide.

For more information about the complete API for all software layers including PAL see the AVR2025: IEEE 802.15.4-2006 MAC Reference Manual.

Since the ATmega128RFA1 is a single chip including both MCU and transceiver, there is no external interface between Transceiver and MCU such as SPI or GPIOs.
All transceiver registers are memory mapped.

The default clock speed is defined by F_CPU and is currently 16MHz. The CPU clock source is selected in mcu_clock_init() in file pal_mcu_generic.c.

The ATmega128RFA1 provides up to 10 transceiver specific interrupts:

  • Transceiver main (Transmit End) interrupt:
    This interrupt is used in the ISR for the transceiver transmit end interrupt (referred to as the transceiver main interrupt) in the corresponding file pal_irq.c.
  • Transceiver Receive End interrupt:
    This interrupt is used in the ISR for the transceiver receive end interrupt in the corresponding file pal_irq.c.
  • Transceiver CCA/ED Meassurement finished interrupt:
    This interrupt is used in the ISR for the transceiver CCA/ED measurement finished interrupt in the corresponding file pal_irq.c.
  • Transceiver timestamp (Receive Start) interrupt:
    By the time the SFD is detected, the hardware timestamps the current frame in the SCTSR register. This interrupt is used in the ISR for the transceiver receive start interrupt (referred to as the transceiver timestamp interrupt) in the corresponding file pal_irq.c.
    This interrupt is only enabled by setting the compile switch BEACON_SUPPORT or ENABLE_TSTAMP.
  • Transceiver PLL lock interrupt:
    This interrupt is used in the ISR for the transceiver PLL lock interrupt in the corresponding file pal_irq.c.
    This interrupt is only enabled by setting the compile switch ENABLE_ALL_TRX_IRQS.
  • Transceiver PLL unlock interrupt:
    This interrupt is used in the ISR for the transceiver PLL unlock interrupt in the corresponding file pal_irq.c.
    This interrupt is only enabled by setting the compile switch ENABLE_ALL_TRX_IRQS.
  • Transceiver Frame Address Match interrupt:
    This interrupt is used in the ISR for the transceiver frame address match interrupt in the corresponding file pal_irq.c.
    This interrupt is only enabled by setting the compile switch ENABLE_ALL_TRX_IRQS.
  • Transceiver Wakeup Finished interrupt:
    This interrupt is used in the ISR for the transceiver awake interrupt in the corresponding file pal_irq.c.
    This interrupt is only enabled by setting the compile switch ENABLE_ALL_TRX_IRQS.
  • AES Encryption Ready interrupt:
    This interrupt is used in the ISR for the transceiver AES encryption ready interrupt in the corresponding file pal_irq.c.
    This interrupt is only enabled by setting the compile switch ENABLE_ALL_TRX_IRQS.
  • Batterie Monitor Alert interrupt:
    This interrupt is used in the ISR for the transceiver battery low interruptt interrupt in the corresponding file pal_irq.c.
    This interrupt is only enabled by setting the compile switch ENABLE_ALL_TRX_IRQS.

The function for reading the current timestamp (pal_trx_read_timestamp()) is located in the corresponding file pal_board.c.
This function needs to be called explicitly at the instant when the current timestamp shall be retrieved. For example in the AVR2025 MAC for ATmega128RFA1 this is done whenever a Transceiver Receive Start interrupt occurs. For more implementation details see function trx_irq_timestamp_handler_cb() in file TAL/ATMEGARF_TAL_1/Src/tal_irq_handler.c.

This board provides 3 LEDs that are connected to pins 2-4 of port E. See LED_PORT and other corresponding defines.

This board provides 1 button that is connected to pin 5 of port E. See BUTTON_PORT and other corresponding defines.

This board provides two UART channels - UART_0 and UART_1, but usually SIO is not used with plain RCBs.

This board provides an external EEPROM, i.e. the IEEE address of the plaform is already stored in the external EEPROM based on AT25010.
Once this switch is set (and thus the external EEPROM is enabled), each call of function pal_ps_get() with parameter ps_type set to EXTERN_EEPROM (see pal.c) results in a call of function extern_eeprom_get() (see pal_board.c).
Note: In case the internal EEPROM from the MCU shall be used, function pal_ps_get() (see pal.c) nees to be called with parameter ps_type set to INTERN_EEPROM.
Make sure that an appropiate IEEE address is stored in the internal EEPROM.

The following fuse settings are recommended:

  • LF: 0xC2
  • HF: 0x91
  • EF: 0xFE

Make sure that the fuse CKDIV8 is NOT set.Enumerations used to identify LEDs

Enumerations used to identify buttons.

Enumerator
BUTTON_0 
enum led_id_tag

This section describes the Board Configuration for RCB V6.3 with ATmega128RFA1.

The board RCB V6.3 with ATmega128RFA1 provides an IEEE 802.15.4 single chip solution for the 2.4 GHz band.

For more information about this board see the AVR2025 MAC User Guide.

For more information about the complete API for all software layers including PAL see the AVR2025: IEEE 802.15.4-2006 MAC Reference Manual.

Since the ATmega128RFA1 is a single chip including both MCU and transceiver, there is no external interface between Transceiver and MCU such as SPI or GPIOs.
All transceiver registers are memory mapped.

The default clock speed is defined by F_CPU and is currently 16MHz. The CPU clock source is selected in mcu_clock_init() in file pal_mcu_generic.c.

The ATmega128RFA1 provides up to 10 transceiver specific interrupts:

  • Transceiver main (Transmit End) interrupt:
    This interrupt is used in the ISR for the transceiver transmit end interrupt (referred to as the transceiver main interrupt) in the corresponding file pal_irq.c.
  • Transceiver Receive End interrupt:
    This interrupt is used in the ISR for the transceiver receive end interrupt in the corresponding file pal_irq.c.
  • Transceiver CCA/ED Meassurement finished interrupt:
    This interrupt is used in the ISR for the transceiver CCA/ED measurement finished interrupt in the corresponding file pal_irq.c.
  • Transceiver timestamp (Receive Start) interrupt:
    By the time the SFD is detected, the hardware timestamps the current frame in the SCTSR register. This interrupt is used in the ISR for the transceiver receive start interrupt (referred to as the transceiver timestamp interrupt) in the corresponding file pal_irq.c.
    This interrupt is only enabled by setting the compile switch BEACON_SUPPORT or ENABLE_TSTAMP.
  • Transceiver PLL lock interrupt:
    This interrupt is used in the ISR for the transceiver PLL lock interrupt in the corresponding file pal_irq.c.
    This interrupt is only enabled by setting the compile switch ENABLE_ALL_TRX_IRQS.
  • Transceiver PLL unlock interrupt:
    This interrupt is used in the ISR for the transceiver PLL unlock interrupt in the corresponding file pal_irq.c.
    This interrupt is only enabled by setting the compile switch ENABLE_ALL_TRX_IRQS.
  • Transceiver Frame Address Match interrupt:
    This interrupt is used in the ISR for the transceiver frame address match interrupt in the corresponding file pal_irq.c.
    This interrupt is only enabled by setting the compile switch ENABLE_ALL_TRX_IRQS.
  • Transceiver Wakeup Finished interrupt:
    This interrupt is used in the ISR for the transceiver awake interrupt in the corresponding file pal_irq.c.
    This interrupt is only enabled by setting the compile switch ENABLE_ALL_TRX_IRQS.
  • AES Encryption Ready interrupt:
    This interrupt is used in the ISR for the transceiver AES encryption ready interrupt in the corresponding file pal_irq.c.
    This interrupt is only enabled by setting the compile switch ENABLE_ALL_TRX_IRQS.
  • Batterie Monitor Alert interrupt:
    This interrupt is used in the ISR for the transceiver battery low interruptt interrupt in the corresponding file pal_irq.c.
    This interrupt is only enabled by setting the compile switch ENABLE_ALL_TRX_IRQS.

The function for reading the current timestamp (pal_trx_read_timestamp()) is located in the corresponding file pal_board.c.
This function needs to be called explicitly at the instant when the current timestamp shall be retrieved. For example in the AVR2025 MAC for ATmega128RFA1 this is done whenever a Transceiver Receive Start interrupt occurs. For more implementation details see function trx_irq_timestamp_handler_cb() in file TAL/ATMEGARF_TAL_1/Src/tal_irq_handler.c.

This board provides 3 LEDs that are connected to pins 2-4 of port E. See LED_PORT and other corresponding defines.

This board provides 1 button that is connected to pin 5 of port E. See BUTTON_PORT and other corresponding defines.

This board provides two UART channels - UART_0 and UART_1, but usually SIO is not used with plain RCBs.

This board provides an external EEPROM, i.e. the IEEE address of the plaform is already stored in the external EEPROM based on AT25010.
Once this switch is set (and thus the external EEPROM is enabled), each call of function pal_ps_get() with parameter ps_type set to EXTERN_EEPROM (see pal.c) results in a call of function extern_eeprom_get() (see pal_board.c).
Note: In case the internal EEPROM from the MCU shall be used, function pal_ps_get() (see pal.c) nees to be called with parameter ps_type set to INTERN_EEPROM.
Make sure that an appropiate IEEE address is stored in the internal EEPROM.

The following fuse settings are recommended:

  • LF: 0xC2
  • HF: 0x91
  • EF: 0xFE

Make sure that the fuse CKDIV8 is NOT set.Enumerations used to identify LEDs

Enumerator
LED_0 
LED_1 
LED_2