Microcontroller Wireless Solutions


(Plain) Radio Controller board RCB V6.3 with ATmega128RFA1

Defines

#define ALERT_INDICATE()
#define ALERT_INIT()
#define ANTENNA_DIVERSITY   (0)
#define AT25010_BP0   0x04
#define AT25010_BP1   0x08
#define AT25010_CMD_RDSR   0x05
#define AT25010_CMD_READ   0x03
#define AT25010_CMD_WRDI   0x04
#define AT25010_CMD_WREN   0x06
#define AT25010_CMD_WRITE   0x02
#define AT25010_CMD_WRSR   0x01
#define AT25010_STATUS_NRDY   0x01
#define AT25010_STATUS_WE   0x02
#define BUTTON_INPUT_PINS   (PINE)
#define BUTTON_PIN_0   (PE5)
#define BUTTON_PORT   (PORTE)
#define BUTTON_PORT_DIR   (DDRE)
#define CFG_BINARYLEN   32
#define CFG_FEATURE1_ANTENNA   0x02
#define CFG_FEATURE1_EXDIV   0x04
#define CFG_FEATURE1_LNA   0x20
#define CFG_FEATURE1_PA   0x10
#define CFG_FEATURE1_RESV3   0x08
#define CFG_FEATURE1_RESV6   0x40
#define CFG_FEATURE1_RESV7   0x80
#define CFG_FEATURE1_RFCONN   0x01
#define CFG_NAMELEN   (32 - sizeof(uint16_t))
#define EE_IEEE_ADDR   (0)
#define EE_XTAL_TRIM_ADDR   (21)
#define EXT_EE_CS_DDR   (DDRG)
#define EXT_EE_CS_PIN   (0x20)
#define EXT_EE_CS_PORT   (PORTG)
#define EXTERN_EEPROM_AVAILABLE   (1)
#define F_CPU   (16000000UL)
#define LED_PIN_0   (PE2)
#define LED_PIN_1   (PE3)
#define LED_PIN_2   (PE4)
#define LED_PORT   (PORTE)
#define LED_PORT_DIR   (DDRE)
#define NO_OF_BUTTONS   (1)
#define NO_OF_LEDS   (3)
#define pal_pwr_mode(x)   pal_sleep_mode(x)
#define PAL_WAIT_65_NS()
#define UART_0_INIT_NON_GENERIC()
#define UART_1_INIT_NON_GENERIC()

Typedefs

typedef enum button_id_tag button_id_t
typedef enum led_id_tag led_id_t

Enumerations

enum  boardfamilycode { CFG_BFAMILY_RADIO_EXTENDER, CFG_BFAMILY_RCB }
enum  button_id_tag { BUTTON_0 }
enum  led_id_tag { LED_0, LED_1, LED_2 }

Functions

static uint8_t at25010_read_byte (uint8_t addr)
static void at25010_spi_cleanup (void)
static void at25010_spi_setup (void)
uint16_t crc_ccitt_update (uint16_t crc, uint8_t data)
retval_t extern_eeprom_get (uint8_t start_offset, uint8_t length, void *value)
static void extern_eeprom_init (void)
void gpio_init (void)
 ISR (INT5_vect)
void pal_button_init (void)
button_state_t pal_button_read (button_id_t button_no)
bool pal_calibrate_rc_osc (void)
void pal_led (led_id_t led_no, led_action_t led_setting)
void pal_led_init (void)
void pal_sleep_mode (uint8_t sleep_mode)

Variables

enum boardfamilycode SHORTENUM

Detailed Description

Introduction

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.

Transceiver-MCU interface

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.

Default clock speed (F_CPU)

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.

IRQ generation

The ATmega128RFA1 provides up to 10 transceiver specific interrupts:

Timestamping

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/ATMEGARFA1/Src/tal_irq_handler.c.

LEDs

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

Buttons

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

SIO (Serial I/O)

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

External EEPROM

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.

Fuse settings

The following fuse settings are recommended:

Make sure that the fuse CKDIV8 is NOT set.


Define Documentation

#define ALERT_INDICATE ( )
Value:
do {    \
        LED_PORT ^= 0xFF;                       \
} while (0)

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.

Definition at line 356 of file pal_config.h.

Referenced by pal_alert().

#define ALERT_INIT ( )
Value:
do {    \
        LED_PORT = 0;                           \
        LED_PORT_DIR = 0xFF;                    \
} while (0)

Alert initialization

Definition at line 344 of file pal_config.h.

Referenced by pal_alert().

#define ANTENNA_DIVERSITY   (0)

This board does not support antenna diversity.

Definition at line 260 of file pal_config.h.

#define AT25010_BP0   0x04

block-protection bit 0

Definition at line 45 of file pal_board.c.

#define AT25010_BP1   0x08

block-protection bit 1

Definition at line 46 of file pal_board.c.

#define AT25010_CMD_RDSR   0x05

Read Status Register

Definition at line 37 of file pal_board.c.

#define AT25010_CMD_READ   0x03

Read Data from Memory Array

Definition at line 39 of file pal_board.c.

Referenced by at25010_read_byte().

#define AT25010_CMD_WRDI   0x04

Reset Write Enable Latch

Definition at line 36 of file pal_board.c.

#define AT25010_CMD_WREN   0x06

Set Write Enable Latch

Definition at line 35 of file pal_board.c.

#define AT25010_CMD_WRITE   0x02

Write Data to Memory Array

Definition at line 40 of file pal_board.c.

#define AT25010_CMD_WRSR   0x01

Write Status Register

Definition at line 38 of file pal_board.c.

#define AT25010_STATUS_NRDY   0x01

not ready

Definition at line 43 of file pal_board.c.

#define AT25010_STATUS_WE   0x02

write enabled

Definition at line 44 of file pal_board.c.

#define BUTTON_INPUT_PINS   (PINE)

Input pins for buttons

Definition at line 289 of file pal_config.h.

Referenced by pal_button_read().

#define BUTTON_PIN_0   (PE5)

Button 0 pin

Definition at line 294 of file pal_config.h.

Referenced by pal_button_init(), and pal_button_read().

#define BUTTON_PORT   (PORTE)

Port for buttons

Definition at line 287 of file pal_config.h.

Referenced by pal_button_init().

#define BUTTON_PORT_DIR   (DDRE)

Port directions for buttons

Definition at line 288 of file pal_config.h.

Referenced by pal_button_init().

#define CFG_BINARYLEN   32

Total space reserved for binary configuration data

Definition at line 79 of file pal_board.c.

#define CFG_FEATURE1_ANTENNA   0x02

On-board antenna enabled

Definition at line 54 of file pal_board.c.

#define CFG_FEATURE1_EXDIV   0x04

External antenna diversity

Definition at line 57 of file pal_board.c.

#define CFG_FEATURE1_LNA   0x20

Transceiver-controlled LNA present

Definition at line 66 of file pal_board.c.

#define CFG_FEATURE1_PA   0x10

Transceiver-controlled PA present

Definition at line 63 of file pal_board.c.

#define CFG_FEATURE1_RESV3   0x08

Reserved

Definition at line 60 of file pal_board.c.

#define CFG_FEATURE1_RESV6   0x40

Reserved

Definition at line 69 of file pal_board.c.

#define CFG_FEATURE1_RESV7   0x80

Reserved

Definition at line 72 of file pal_board.c.

#define CFG_FEATURE1_RFCONN   0x01

RF connector enabled

Definition at line 51 of file pal_board.c.

#define CFG_NAMELEN   (32 - sizeof(uint16_t))

Maximal length of textual board name

Definition at line 76 of file pal_board.c.

#define EE_IEEE_ADDR   (0)

IEEE address of board in external EEPROM

Definition at line 316 of file pal_config.h.

#define EE_XTAL_TRIM_ADDR   (21)

Storage location for crystal trim value in external EEPROM

Definition at line 321 of file pal_config.h.

#define EXT_EE_CS_DDR   (DDRG)

Data direction register for the external EEPROM's chip select

Definition at line 328 of file pal_config.h.

Referenced by extern_eeprom_init().

#define EXT_EE_CS_PIN   (0x20)

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

Definition at line 331 of file pal_config.h.

Referenced by at25010_read_byte(), and extern_eeprom_init().

#define EXT_EE_CS_PORT   (PORTG)

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

Definition at line 326 of file pal_config.h.

Referenced by at25010_read_byte(), and extern_eeprom_init().

#define EXTERN_EEPROM_AVAILABLE   (1)

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

Definition at line 310 of file pal_config.h.

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

Definition at line 254 of file pal_config.h.

#define LED_PIN_0   (PE2)

LED 0 pin

Definition at line 280 of file pal_config.h.

Referenced by pal_led(), and pal_led_init().

#define LED_PIN_1   (PE3)

LED 1 pin

Definition at line 281 of file pal_config.h.

Referenced by pal_led(), and pal_led_init().

#define LED_PIN_2   (PE4)

LED 2 pin

Definition at line 282 of file pal_config.h.

Referenced by pal_led(), and pal_led_init().

#define LED_PORT   (PORTE)

Port for LEDs

Definition at line 274 of file pal_config.h.

Referenced by pal_led(), and pal_led_init().

#define LED_PORT_DIR   (DDRE)

Port directions for LEDs

Definition at line 275 of file pal_config.h.

Referenced by pal_led_init().

#define NO_OF_BUTTONS   (1)

Number of buttons provided by this board.

Definition at line 238 of file pal_config.h.

#define NO_OF_LEDS   (3)

Number of LEDs provided by this board.

Definition at line 228 of file pal_config.h.

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

Definition at line 268 of file pal_config.h.

#define UART_0_INIT_NON_GENERIC ( )

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

Definition at line 300 of file pal_config.h.

#define UART_1_INIT_NON_GENERIC ( )

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

Definition at line 302 of file pal_config.h.


Typedef Documentation

typedef enum button_id_tag button_id_t

Enumerations used to identify buttons

typedef enum led_id_tag led_id_t

Enumerations used to identify LEDs


Enumeration Type Documentation

Encoding of the board family in the board_family configuration record member.

Enumerator:
CFG_BFAMILY_RADIO_EXTENDER 

Radio Extender boards

CFG_BFAMILY_RCB 

Radio Controller boards

Definition at line 101 of file pal_board.c.

Enumerations used to identify buttons

Definition at line 232 of file pal_config.h.

enum led_id_tag

Enumerations used to identify LEDs

Definition at line 220 of file pal_config.h.


Function Documentation

static uint8_t at25010_read_byte ( uint8_t  addr) [static]

Read one byte from an AT25010 EEPROM.

Due to the connection between MCU, TRX and EEPROM, an EEPROM access causes a transceiver reset. Therefore an entire transceiver configuration is necessary after EEPROM access.

Parameters:
addrByte address to read from
Returns:
Data read from EEPROM

Definition at line 260 of file pal_board.c.

References AT25010_CMD_READ, EXT_EE_CS_PIN, and EXT_EE_CS_PORT.

Referenced by extern_eeprom_get().

static void at25010_spi_cleanup ( void  ) [static]

Clean up the SPI subsystem after accessing an AT25010 EEPROM.

This frees up the SPI subsystem completely, and thus, leaves port B back to either the FT245 USB converter, or to the user.

Definition at line 239 of file pal_board.c.

Referenced by extern_eeprom_get().

static void at25010_spi_setup ( void  ) [static]

Setup the SPI subsystem for accessing an AT25010 EEPROM.

The SPI subsystem on the RCB 6.3 is located on Port B which is either used as the data port when connecting to an FT245 USB converter, or available as general IO to the user otherwise. For that reason, PAL will only enable the SPI subsystem in order to access the feature EEPROM (AT25010), and does not touch port B otherwise.

The AT25010's chip select signal is located on PG5, outside port B.

Definition at line 215 of file pal_board.c.

Referenced by extern_eeprom_get().

uint16_t crc_ccitt_update ( uint16_t  crc,
uint8_t  data 
)

Computes the CCITT-CRC16 on a byte by byte basis.

This function computes the CCITT-CRC16 on a byte by byte basis. It updates the CRC for transmitted and received data using the CCITT 16bit algorithm (X^16 + X^12 + X^5 + 1).

Parameters:
crcCurrent crc value
dataNext byte that should be included into the CRC16
Returns:
updated CRC16

Definition at line 348 of file pal_board.c.

retval_t extern_eeprom_get ( uint8_t  start_offset,
uint8_t  length,
void *  value 
)

Get data from external EEPROM.

Parameters:
[in]start_offsetStart offset within EEPROM
[in]lengthNumber of bytes to read from EEPROM
[out]valueData from persistence storage
Returns:
MAC_SUCCESS If external EERPOM is available and contains valid contents FAILURE else

Definition at line 299 of file pal_board.c.

References at25010_read_byte(), at25010_spi_cleanup(), at25010_spi_setup(), FAILURE, and MAC_SUCCESS.

Referenced by pal_ps_get().

static void extern_eeprom_init ( void  ) [static]

Initializes the GPIO used for the extern EEPROM.

This function is used to initialize the port pins connecting the microcontroller to the extern EEPROM.

Definition at line 486 of file pal_board.c.

References EXT_EE_CS_DDR, EXT_EE_CS_PIN, and EXT_EE_CS_PORT.

Referenced by gpio_init().

void pal_button_init ( void  )

Initialize the button.

Button initialization.

Definition at line 439 of file pal_board.c.

References BUTTON_PIN_0, BUTTON_PORT, and BUTTON_PORT_DIR.

button_state_t pal_button_read ( button_id_t  button_no)

Read button.

Button handling.

Parameters:
button_noButton ID

Definition at line 452 of file pal_board.c.

References BUTTON_INPUT_PINS, BUTTON_OFF, BUTTON_PIN_0, and BUTTON_PRESSED.

bool pal_calibrate_rc_osc ( void  )

Calibrates the internal RC oscillator.

This function calibrates the internal RC oscillator, based on the external 32.768 Hz crystal clock source.

Returns:
True if calibration is successful, false otherwise.

Definition at line 194 of file pal_board.c.

void pal_led ( led_id_t  led_no,
led_action_t  led_setting 
)

Control LED status.

LED handling.

Parameters:
[in]led_noLED ID
[in]led_settingLED_ON, LED_OFF, LED_TOGGLE

Definition at line 383 of file pal_board.c.

References LED_OFF, LED_ON, LED_PIN_0, LED_PIN_1, LED_PIN_2, LED_PORT, and LED_TOGGLE.

void pal_led_init ( void  )

Initialize LEDs.

LED initialization.

Definition at line 365 of file pal_board.c.

References LED_PIN_0, LED_PIN_1, LED_PIN_2, LED_PORT, and LED_PORT_DIR.

void pal_sleep_mode ( uint8_t  sleep_mode)

Sleep/Power handling.

Handles Sleep/power modes for entire system

Parameters:
sleep_modedesired sleep/power mode

Definition at line 503 of file pal_board.c.