Contiki 2.6

RF230 hardware level drivers

HAL function names have the following conventions: More...

Data Structures

struct  hal_rx_frame_t
 This struct defines the rx data container. More...

Files

file  hal.h
 

This file contains low-level radio driver code.


file  halbb.c
 

This file contains low-level radio driver code.


file  hal.c
 

This file contains low-level radio driver code.


file  hal.h
 

This file contains low-level radio driver code.


Defines

#define HAL_SS_HIGH()   (HAL_PORT_SS |= ( 1 << HAL_SS_PIN ))
 MACRO for pulling SS high.
#define HAL_SS_LOW()   (HAL_PORT_SS &= ~( 1 << HAL_SS_PIN ))
 MACRO for pulling SS low.
#define HAL_ENABLE_RADIO_INTERRUPT()   ( INT1IC.BYTE |= 1 )
 Macros defined for HAL_TIMER1.
#define HAL_ENTER_CRITICAL_REGION()   MULLE_ENTER_CRITICAL_REGION( )
 This macro will protect the following code from interrupts.
#define HAL_LEAVE_CRITICAL_REGION()   MULLE_LEAVE_CRITICAL_REGION( )
 This macro must always be used in conjunction with HAL_ENTER_CRITICAL_REGION so that interrupts are enabled again.
#define hal_enable_trx_interrupt()   HAL_ENABLE_RADIO_INTERRUPT( )
 Enable the interrupt from the radio transceiver.
#define hal_disable_trx_interrupt()   HAL_DISABLE_RADIO_INTERRUPT( )
 Disable the interrupt from the radio transceiver.
#define HAL_SPI_TRANSFER_OPEN()
 This function is called when a rx_start interrupt is signaled.
#define HAL_RF230_ISR()   M16C_INTERRUPT(M16C_INT1)
 This function initializes the Hardware Abstraction Layer.
#define HAL_DUMMY_READ   (0x00)
 Dummy value for the SPI.
#define HAL_TRX_CMD_RW   (0xC0)
 Register Write (short mode).
#define HAL_TRX_CMD_RR   (0x80)
 Register Read (short mode).
#define HAL_TRX_CMD_FW   (0x60)
 Frame Transmit Mode (long mode).
#define HAL_TRX_CMD_FR   (0x20)
 Frame Receive Mode (long mode).
#define HAL_TRX_CMD_SW   (0x40)
 SRAM Write.
#define HAL_TRX_CMD_SR   (0x00)
 SRAM Read.
#define HAL_TRX_CMD_RADDRM   (0x7F)
 Register Address Mask.
#define HAL_CALCULATED_CRC_OK   (0)
 CRC calculated over the frame including the CRC field should be 0.
#define HAL_SS_HIGH()   (HAL_PORT_SPI |= ( 1 << HAL_SS_PIN ))
 MACRO for pulling SS high.
#define HAL_SS_LOW()   (HAL_PORT_SPI &= ~( 1 << HAL_SS_PIN ))
 MACRO for pulling SS low.
#define RADIO_VECT   INT5_vect
 Macros defined for HAL_TIMER1.
#define AVR_ENTER_CRITICAL_REGION()   {uint8_t volatile saved_sreg = SREG; cli( )
 This macro will protect the following code from interrupts.
#define AVR_LEAVE_CRITICAL_REGION()   SREG = saved_sreg;}
 This macro must always be used in conjunction with AVR_ENTER_CRITICAL_REGION so that interrupts are enabled again.
#define hal_enable_trx_interrupt()   HAL_ENABLE_RADIO_INTERRUPT( )
 Enable the interrupt from the radio transceiver.
#define hal_disable_trx_interrupt()   HAL_DISABLE_RADIO_INTERRUPT( )
 Disable the interrupt from the radio transceiver.

Typedefs

typedef void(* hal_rx_start_isr_event_handler_t )(uint32_t const isr_timestamp, uint8_t const frame_length)
 RX_START event handler callback type.
typedef void(* hal_trx_end_isr_event_handler_t )(uint32_t const isr_timestamp)
 RRX_END event handler callback type.
typedef void(* hal_rx_start_isr_event_handler_t )(uint32_t const isr_timestamp, uint8_t const frame_length)
 RX_START event handler callback type.
typedef void(* hal_trx_end_isr_event_handler_t )(uint32_t const isr_timestamp)
 RRX_END event handler callback type.

Functions

void hal_init (void)
 This function initializes the Hardware Abstraction Layer.
void hal_reset_flags (void)
 This function reset the interrupt flags and interrupt event handlers (Callbacks) to their default value.
uint8_t hal_get_bat_low_flag (void)
 This function returns the current value of the BAT_LOW flag.
void hal_clear_bat_low_flag (void)
 This function clears the BAT_LOW flag.
hal_trx_end_isr_event_handler_t hal_get_trx_end_event_handler (void)
 This function is used to set new TRX_END event handler, overriding old handler reference.
void hal_set_trx_end_event_handler (hal_trx_end_isr_event_handler_t trx_end_callback_handle)
 This function is used to set new TRX_END event handler, overriding old handler reference.
void hal_clear_trx_end_event_handler (void)
 Remove event handler reference.
hal_rx_start_isr_event_handler_t hal_get_rx_start_event_handler (void)
 This function returns the active RX_START event handler.
void hal_set_rx_start_event_handler (hal_rx_start_isr_event_handler_t rx_start_callback_handle)
 This function is used to set new RX_START event handler, overriding old handler reference.
void hal_clear_rx_start_event_handler (void)
 Remove event handler reference.
uint8_t hal_get_pll_lock_flag (void)
 This function returns the current value of the PLL_LOCK flag.
void hal_clear_pll_lock_flag (void)
 This function clears the PLL_LOCK flag.
uint8_t hal_register_read (uint8_t address)
 This function reset the interrupt flags and interrupt event handlers (Callbacks) to their default value.
void hal_register_write (uint8_t address, uint8_t value)
 This function writes a new value to one of the radio transceiver's registers.
uint8_t hal_subregister_read (uint8_t address, uint8_t mask, uint8_t position)
 This function reads the value of a specific subregister.
void hal_subregister_write (uint8_t address, uint8_t mask, uint8_t position, uint8_t value)
 This function writes a new value to one of the radio transceiver's subregisters.
void hal_frame_read (hal_rx_frame_t *rx_frame)
 Transfer a frame from the radio transceiver to a RAM buffer.
void hal_frame_write (uint8_t *write_buffer, uint8_t length)
 This function will download a frame to the radio transceiver's frame buffer.
void hal_sram_read (uint8_t address, uint8_t length, uint8_t *data)
 Read SRAM.
void hal_sram_write (uint8_t address, uint8_t length, uint8_t *data)
 Write SRAM.
void RADIO_VECT (void)
 Read SRAM.
void TIMER1_OVF_vect (void)
 Timer Overflow ISR This is the interrupt service routine for timer1 overflow.
void hal_frame_read (hal_rx_frame_t *rx_frame, rx_callback_t rx_callback)
 This function will upload a frame from the radio transceiver's frame buffer.

This is the list of pin configurations needed for a given platform.

Change these values to port to other platforms.
#define RAVENUSB_C   1
#define RAVEN_D   2
#define RCB_B   3
#define ZIGBIT   4
#define IRIS   5
#define ATMEGA128RFA1   6
#define SSPORT   SPIPORT
#define SCKPORT   SPIPORT
#define MOSIPORT   SPIPORT
#define MISOPORT   SPIPORT

Pin macros

These macros convert the platform-specific pin defines into names and functions that the source code can directly use.
#define SLP_TR   SLPTRPIN
 Pin number that corresponds to the SLP_TR pin.
#define DDR_SLP_TR   DDR( SLPTRPORT )
 Data Direction Register that corresponds to the port where SLP_TR is connected.
#define PORT_SLP_TR   PORT( SLPTRPORT )
 Port (Write Access) where SLP_TR is connected.
#define PIN_SLP_TR   PIN( SLPTRPORT )
 Pin (Read Access) where SLP_TR is connected.
#define hal_set_slptr_high()   ( PORT_SLP_TR |= ( 1 << SLP_TR ) )
 This macro pulls the SLP_TR pin high.
#define hal_set_slptr_low()   ( PORT_SLP_TR &= ~( 1 << SLP_TR ) )
 This macro pulls the SLP_TR pin low.
#define hal_get_slptr()   ( PIN_SLP_TR & ( 1 << SLP_TR ) )
 Read current state of the SLP_TR pin (High/Low).
#define RST   RSTPIN
 Pin number that corresponds to the RST pin.
#define DDR_RST   DDR( RSTPORT )
 Data Direction Register that corresponds to the port where RST is.
#define PORT_RST   PORT( RSTPORT )
 Port (Write Access) where RST is connected.
#define PIN_RST   PIN( RSTPORT /* BUG? */)
 Pin (Read Access) where RST is connected.
#define hal_set_rst_high()   ( PORT_RST |= ( 1 << RST ) )
 This macro pulls the RST pin high.
#define hal_set_rst_low()   ( PORT_RST &= ~( 1 << RST ) )
 This macro pulls the RST pin low.
#define hal_get_rst()   ( ( PIN_RST & ( 1 << RST ) ) >> RST )
 Read current state of the RST pin (High/Low).
#define HAL_SS_PIN   SSPIN
 The slave select pin.
#define HAL_SCK_PIN   SCKPIN
 Data bit for SCK.
#define HAL_MOSI_PIN   MOSIPIN
#define HAL_MISO_PIN   MISOPIN
#define HAL_PORT_SPI   PORT( SPIPORT )
 The SPI module is located on PORTB.
#define HAL_PORT_SS   PORT( SSPORT )
#define HAL_PORT_SCK   PORT( SCKPORT )
#define HAL_PORT_MOSI   PORT( MOSIPORT )
 The SPI module uses GPIO might be split on different ports.
#define HAL_PORT_MISO   PORT( MISOPORT )
 The SPI module uses GPIO might be split on different ports.
#define HAL_DDR_SPI   DDR( SPIPORT )
 Data Direction Register for PORTB.
#define HAL_DDR_SS   DDR( SSPORT )
 Data Direction Register for MISO GPIO pin.
#define HAL_DDR_SCK   DDR( SCKPORT )
 Data Direction Register for MISO GPIO pin.
#define HAL_DDR_MOSI   DDR( MOSIPORT )
 Data Direction Register for MISO GPIO pin.
#define HAL_DDR_MISO   DDR( MISOPORT )
 Data Direction Register for MOSI GPIO pin.
#define HAL_DD_SS   SSPIN
 Data Direction bit for SS.
#define HAL_DD_SCK   SCKPIN
 Data Direction bit for SCK.
#define HAL_DD_MOSI   MOSIPIN
 Data Direction bit for MOSI.
#define HAL_DD_MISO   MISOPIN
 Data Direction bit for MISO.

Macros for radio operation.

#define HAL_BAT_LOW_MASK   ( 0x80 )
 Mask for the BAT_LOW interrupt.
#define HAL_TRX_UR_MASK   ( 0x40 )
 Mask for the TRX_UR interrupt.
#define HAL_TRX_END_MASK   ( 0x08 )
 Mask for the TRX_END interrupt.
#define HAL_RX_START_MASK   ( 0x04 )
 Mask for the RX_START interrupt.
#define HAL_PLL_UNLOCK_MASK   ( 0x02 )
 Mask for the PLL_UNLOCK interrupt.
#define HAL_PLL_LOCK_MASK   ( 0x01 )
 Mask for the PLL_LOCK interrupt.
#define HAL_MIN_FRAME_LENGTH   ( 0x03 )
 A frame should be at least 3 bytes.
#define HAL_MAX_FRAME_LENGTH   ( 0x7F )
 A frame should no more than 127 bytes.

This is the list of pin configurations needed for a given platform.

Change these values to port to other platforms.
#define RAVEN_D   1
#define RAVENUSB_C   2
#define RCB_B   3
#define ZIGBIT   4
#define IRIS   5
#define SSPORT   B
#define SSPIN   (0x00)
#define SPIPORT   B
#define MOSIPIN   (0x02)
#define MISOPIN   (0x03)
#define SCKPIN   (0x01)
#define RSTPORT   B
#define RSTPIN   (0x05)
#define IRQPORT   D
#define IRQPIN   (0x04)
#define SLPTRPORT   B
#define SLPTRPIN   (0x04)
#define USART   1
#define USARTVECT   USART1_RX_vect
#define TICKTIMER   3
#define HAS_SPARE_TIMER

Macros used to generate read register names from platform-specific definitions of ports.

The various CAT macros (DDR, PORT, and PIN) are used to assign port/pin/DDR names to various macro variables.The variables are assigned based on the specific connections made in the hardware. For example TCCR(TICKTIMER,A) can be used in place of TCCR0A if TICKTIMER is defined as 0.
#define CAT(x, y)   x##y
#define CAT2(x, y, z)   x##y##z
#define DDR(x)   CAT(DDR, x)
#define PORT(x)   CAT(PORT, x)
#define PIN(x)   CAT(PIN, x)
#define UCSR(num, let)   CAT2(UCSR,num,let)
#define RXEN(x)   CAT(RXEN,x)
#define TXEN(x)   CAT(TXEN,x)
#define TXC(x)   CAT(TXC,x)
#define RXC(x)   CAT(RXC,x)
#define RXCIE(x)   CAT(RXCIE,x)
#define UCSZ(x, y)   CAT2(UCSZ,x,y)
#define UBRR(x, y)   CAT2(UBRR,x,y)
#define UDRE(x)   CAT(UDRE,x)
#define UDRIE(x)   CAT(UDRIE,x)
#define UDR(x)   CAT(UDR,x)
#define TCNT(x)   CAT(TCNT,x)
#define TIMSK(x)   CAT(TIMSK,x)
#define TCCR(x, y)   CAT2(TCCR,x,y)
#define COM(x, y)   CAT2(COM,x,y)
#define OCR(x, y)   CAT2(OCR,x,y)
#define CS(x, y)   CAT2(CS,x,y)
#define WGM(x, y)   CAT2(WGM,x,y)
#define OCIE(x, y)   CAT2(OCIE,x,y)
#define COMPVECT(x)   CAT2(TIMER,x,_COMPA_vect)
#define UDREVECT(x)   CAT2(USART,x,_UDRE_vect)
#define RXVECT(x)   CAT2(USART,x,_RX_vect)

Pin macros

These macros convert the platform-specific pin defines into names and functions that the source code can directly use.
#define SLP_TR   SLPTRPIN
 Pin number that corresponds to the SLP_TR pin.
#define DDR_SLP_TR   DDR( SLPTRPORT )
 Data Direction Register that corresponds to the port where SLP_TR is connected.
#define PORT_SLP_TR   PORT( SLPTRPORT )
 Port (Write Access) where SLP_TR is connected.
#define PIN_SLP_TR   PIN( SLPTRPORT )
 Pin (Read Access) where SLP_TR is connected.
#define hal_set_slptr_high()   ( PORT_SLP_TR |= ( 1 << SLP_TR ) )
 This macro pulls the SLP_TR pin high.
#define hal_set_slptr_low()   ( PORT_SLP_TR &= ~( 1 << SLP_TR ) )
 This macro pulls the SLP_TR pin low.
#define hal_get_slptr()   ( ( PIN_SLP_TR & ( 1 << SLP_TR ) ) >> SLP_TR )
 Read current state of the SLP_TR pin (High/Low).
#define RST   RSTPIN
 Pin number that corresponds to the RST pin.
#define DDR_RST   DDR( RSTPORT )
 Data Direction Register that corresponds to the port where RST is.
#define PORT_RST   PORT( RSTPORT )
 Port (Write Access) where RST is connected.
#define PIN_RST   PIN( RSTPORT )
 Pin (Read Access) where RST is connected.
#define hal_set_rst_high()   ( PORT_RST |= ( 1 << RST ) )
 This macro pulls the RST pin high.
#define hal_set_rst_low()   ( PORT_RST &= ~( 1 << RST ) )
 This macro pulls the RST pin low.
#define hal_get_rst()   ( ( PIN_RST & ( 1 << RST ) ) >> RST )
 Read current state of the RST pin (High/Low).
#define HAL_SS_PIN   SSPIN
 The slave select pin.
#define HAL_PORT_SPI   PORT( SPIPORT )
 The SPI module is located on PORTB.
#define HAL_DDR_SPI   DDR( SPIPORT )
 Data Direction Register for PORTB.
#define HAL_DD_SS   SSPIN
 Data Direction bit for SS.
#define HAL_DD_SCK   SCKPIN
 Data Direction bit for SCK.
#define HAL_DD_MOSI   MOSIPIN
 Data Direction bit for MOSI.
#define HAL_DD_MISO   MISOPIN
 Data Direction bit for MISO.

Macros for radio operation.

#define HAL_BAT_LOW_MASK   ( 0x80 )
 Mask for the BAT_LOW interrupt.
#define HAL_TRX_UR_MASK   ( 0x40 )
 Mask for the TRX_UR interrupt.
#define HAL_TRX_END_MASK   ( 0x08 )
 Mask for the TRX_END interrupt.
#define HAL_RX_START_MASK   ( 0x04 )
 Mask for the RX_START interrupt.
#define HAL_PLL_UNLOCK_MASK   ( 0x02 )
 Mask for the PLL_UNLOCK interrupt.
#define HAL_PLL_LOCK_MASK   ( 0x01 )
 Mask for the PLL_LOCK interrupt.
#define HAL_MIN_FRAME_LENGTH   ( 0x03 )
 A frame should be at least 3 bytes.
#define HAL_MAX_FRAME_LENGTH   ( 0x7F )
 A frame should no more than 127 bytes.

Detailed Description

HAL function names have the following conventions:

HAL which SimpleMAC library depends upon: API that is required for proper operation of the SimpleMAC library. As with all of the HAL, it is provided as source and it is possible for the end customer to modify this code. However, unlike other portions of the HAL, if the customer does modify this code, it must ensure that equivalent functionality is still provided to ensure proper operation of the SimpleMAC library.

HAL for other chip capabilities: API which SimpleMAC does not directly depend on. However, much of this functionality may be required for proper operation of all features of the chip.

Additional HAL for sample applications: API which is included to assist the development of the included sample applications. This functionality may be very useful, but is not required for proper operation of the chip. This code and functionality may be freely modified by the end customer.



See also hal.h.


Define Documentation

#define AVR_ENTER_CRITICAL_REGION ( )    {uint8_t volatile saved_sreg = SREG; cli( )
#define AVR_LEAVE_CRITICAL_REGION ( )    SREG = saved_sreg;}
#define DDR_SLP_TR   DDR( SLPTRPORT )

Data Direction Register that corresponds to the port where SLP_TR is connected.

Definition at line 246 of file hal.h.

#define DDR_SLP_TR   DDR( SLPTRPORT )

Data Direction Register that corresponds to the port where SLP_TR is connected.

Definition at line 333 of file hal.h.

Referenced by hal_init().

#define HAL_BAT_LOW_MASK   ( 0x80 )

Mask for the BAT_LOW interrupt.

Definition at line 336 of file hal.h.

#define HAL_BAT_LOW_MASK   ( 0x80 )

Mask for the BAT_LOW interrupt.

Definition at line 465 of file hal.h.

#define HAL_CALCULATED_CRC_OK   (0)

CRC calculated over the frame including the CRC field should be 0.

Definition at line 82 of file hal.c.

Referenced by hal_frame_read().

#define HAL_DD_MISO   MISOPIN

Data Direction bit for MISO.

Definition at line 265 of file hal.h.

#define HAL_DD_MISO   MISOPIN

Data Direction bit for MISO.

Definition at line 364 of file hal.h.

#define HAL_DD_MOSI   MOSIPIN

Data Direction bit for MOSI.

Definition at line 264 of file hal.h.

#define HAL_DD_MOSI   MOSIPIN

Data Direction bit for MOSI.

Definition at line 363 of file hal.h.

#define HAL_DD_SCK   SCKPIN

Data Direction bit for SCK.

Definition at line 263 of file hal.h.

#define HAL_DD_SCK   SCKPIN

Data Direction bit for SCK.

Definition at line 362 of file hal.h.

#define HAL_DD_SS   SSPIN

Data Direction bit for SS.

Definition at line 262 of file hal.h.

#define HAL_DD_SS   SSPIN

Data Direction bit for SS.

Definition at line 361 of file hal.h.

#define HAL_DDR_MISO   DDR( MISOPORT )

Data Direction Register for MOSI GPIO pin.

Definition at line 360 of file hal.h.

Referenced by hal_init().

#define HAL_DDR_MOSI   DDR( MOSIPORT )

Data Direction Register for MISO GPIO pin.

Definition at line 359 of file hal.h.

Referenced by hal_init().

#define HAL_DDR_SCK   DDR( SCKPORT )

Data Direction Register for MISO GPIO pin.

Definition at line 358 of file hal.h.

Referenced by hal_init().

#define HAL_DDR_SPI   DDR( SPIPORT )

Data Direction Register for PORTB.

Definition at line 261 of file hal.h.

#define HAL_DDR_SPI   DDR( SPIPORT )

Data Direction Register for PORTB.

Definition at line 356 of file hal.h.

#define HAL_DDR_SS   DDR( SSPORT )

Data Direction Register for MISO GPIO pin.

Definition at line 357 of file hal.h.

Referenced by hal_init().

#define hal_disable_trx_interrupt ( )    HAL_DISABLE_RADIO_INTERRUPT( )

Disable the interrupt from the radio transceiver.

Return values:
0if the pin is low, 1 if the pin is high.

Definition at line 329 of file hal.h.

#define hal_disable_trx_interrupt ( )    HAL_DISABLE_RADIO_INTERRUPT( )

Disable the interrupt from the radio transceiver.

Return values:
0if the pin is low, 1 if the pin is high.

Definition at line 458 of file hal.h.

#define HAL_DUMMY_READ   (0x00)

Dummy value for the SPI.

Definition at line 72 of file hal.c.

Referenced by hal_sram_read().

#define HAL_ENABLE_RADIO_INTERRUPT ( )    ( INT1IC.BYTE |= 1 )

Macros defined for HAL_TIMER1.

These macros are used to define the correct setupt of the AVR's Timer1, and to ensure that the hal_get_system_time function returns the system time in symbols (16 us ticks).

Definition at line 434 of file hal.h.

#define HAL_ENTER_CRITICAL_REGION ( )    MULLE_ENTER_CRITICAL_REGION( )

This macro will protect the following code from interrupts.

Definition at line 441 of file hal.h.

#define hal_get_rst ( )    ( ( PIN_RST & ( 1 << RST ) ) >> RST )

Read current state of the RST pin (High/Low).

Definition at line 258 of file hal.h.

#define hal_get_rst ( )    ( ( PIN_RST & ( 1 << RST ) ) >> RST )

Read current state of the RST pin (High/Low).

Definition at line 346 of file hal.h.

#define hal_get_slptr ( )    ( ( PIN_SLP_TR & ( 1 << SLP_TR ) ) >> SLP_TR )

Read current state of the SLP_TR pin (High/Low).

Definition at line 251 of file hal.h.

#define hal_get_slptr ( )    ( PIN_SLP_TR & ( 1 << SLP_TR ) )

Read current state of the SLP_TR pin (High/Low).

Definition at line 339 of file hal.h.

Referenced by radio_is_sleeping().

#define HAL_LEAVE_CRITICAL_REGION ( )    MULLE_LEAVE_CRITICAL_REGION( )

This macro must always be used in conjunction with HAL_ENTER_CRITICAL_REGION so that interrupts are enabled again.

Definition at line 445 of file hal.h.

#define HAL_MAX_FRAME_LENGTH   ( 0x7F )

A frame should no more than 127 bytes.

Definition at line 344 of file hal.h.

#define HAL_MAX_FRAME_LENGTH   ( 0x7F )

A frame should no more than 127 bytes.

Definition at line 473 of file hal.h.

Referenced by hal_frame_read().

#define HAL_MIN_FRAME_LENGTH   ( 0x03 )

A frame should be at least 3 bytes.

Definition at line 343 of file hal.h.

#define HAL_MIN_FRAME_LENGTH   ( 0x03 )

A frame should be at least 3 bytes.

Definition at line 472 of file hal.h.

Referenced by hal_frame_read().

#define HAL_PLL_LOCK_MASK   ( 0x01 )

Mask for the PLL_LOCK interrupt.

Definition at line 341 of file hal.h.

#define HAL_PLL_LOCK_MASK   ( 0x01 )

Mask for the PLL_LOCK interrupt.

Definition at line 470 of file hal.h.

#define HAL_PLL_UNLOCK_MASK   ( 0x02 )

Mask for the PLL_UNLOCK interrupt.

Definition at line 340 of file hal.h.

#define HAL_PLL_UNLOCK_MASK   ( 0x02 )

Mask for the PLL_UNLOCK interrupt.

Definition at line 469 of file hal.h.

#define HAL_PORT_MISO   PORT( MISOPORT )

The SPI module uses GPIO might be split on different ports.

Definition at line 355 of file hal.h.

#define HAL_PORT_MOSI   PORT( MOSIPORT )

The SPI module uses GPIO might be split on different ports.

Definition at line 354 of file hal.h.

#define HAL_PORT_SPI   PORT( SPIPORT )

The SPI module is located on PORTB.

Definition at line 260 of file hal.h.

#define HAL_PORT_SPI   PORT( SPIPORT )

The SPI module is located on PORTB.

Definition at line 351 of file hal.h.

#define HAL_RX_START_MASK   ( 0x04 )

Mask for the RX_START interrupt.

Definition at line 339 of file hal.h.

#define HAL_RX_START_MASK   ( 0x04 )

Mask for the RX_START interrupt.

Definition at line 468 of file hal.h.

#define HAL_SCK_PIN   SCKPIN

Data bit for SCK.

Definition at line 348 of file hal.h.

Referenced by hal_init().

#define hal_set_rst_high ( )    ( PORT_RST |= ( 1 << RST ) )

This macro pulls the RST pin high.

Definition at line 256 of file hal.h.

#define hal_set_rst_high ( )    ( PORT_RST |= ( 1 << RST ) )

This macro pulls the RST pin high.

Definition at line 344 of file hal.h.

Referenced by radio_reset_trx().

#define hal_set_rst_low ( )    ( PORT_RST &= ~( 1 << RST ) )

This macro pulls the RST pin low.

Definition at line 257 of file hal.h.

#define hal_set_rst_low ( )    ( PORT_RST &= ~( 1 << RST ) )

This macro pulls the RST pin low.

Definition at line 345 of file hal.h.

Referenced by radio_reset_trx().

#define hal_set_slptr_high ( )    ( PORT_SLP_TR |= ( 1 << SLP_TR ) )

This macro pulls the SLP_TR pin high.

Definition at line 336 of file hal.h.

Referenced by radio_enter_sleep_mode(), and radio_send_data().

#define hal_set_slptr_high ( )    ( PORT_SLP_TR |= ( 1 << SLP_TR ) )

This macro pulls the SLP_TR pin high.

Definition at line 249 of file hal.h.

#define hal_set_slptr_low ( )    ( PORT_SLP_TR &= ~( 1 << SLP_TR ) )

This macro pulls the SLP_TR pin low.

Definition at line 250 of file hal.h.

#define hal_set_slptr_low ( )    ( PORT_SLP_TR &= ~( 1 << SLP_TR ) )

This macro pulls the SLP_TR pin low.

Definition at line 337 of file hal.h.

Referenced by radio_leave_sleep_mode(), radio_reset_state_machine(), radio_reset_trx(), and radio_send_data().

#define HAL_SPI_TRANSFER_OPEN ( )
Value:
{ uint8_t spiTemp; \
  HAL_ENTER_CRITICAL_REGION();    \
  HAL_SS_LOW();

This function is called when a rx_start interrupt is signaled.

If this function pointer is set to something else than NULL, it will be called when a RX_START event is signaled. The function takes two parameters: timestamp in IEEE 802.15.4 symbols (16 us resolution) and frame length. The event handler will be called in the interrupt domain, so the function must be kept short and not be blocking! Otherwise the system performance will be greatly degraded.

See also:
hal_set_rx_start_event_handlerThis function is called when a trx_end interrupt is signaled.

If this function pointer is set to something else than NULL, it will be called when a TRX_END event is signaled. The function takes one parameter: timestamp in IEEE 802.15.4 symbols (16 us resolution). The event handler will be called in the interrupt domain, so the function must not block!

See also:
hal_set_trx_end_event_handler

Definition at line 172 of file halbb.c.

Referenced by hal_frame_read(), hal_frame_write(), hal_register_read(), and hal_register_write().

#define HAL_SS_HIGH ( )    (HAL_PORT_SPI |= ( 1 << HAL_SS_PIN ))

MACRO for pulling SS high.

Definition at line 269 of file hal.h.

#define HAL_SS_HIGH ( )    (HAL_PORT_SS |= ( 1 << HAL_SS_PIN ))

MACRO for pulling SS high.

Definition at line 370 of file hal.h.

Referenced by hal_frame_read(), hal_sram_read(), and hal_sram_write().

#define HAL_SS_LOW ( )    (HAL_PORT_SPI &= ~( 1 << HAL_SS_PIN ))

MACRO for pulling SS low.

Definition at line 270 of file hal.h.

#define HAL_SS_LOW ( )    (HAL_PORT_SS &= ~( 1 << HAL_SS_PIN ))

MACRO for pulling SS low.

Definition at line 371 of file hal.h.

Referenced by hal_frame_read(), hal_sram_read(), and hal_sram_write().

#define HAL_SS_PIN   SSPIN

The slave select pin.

Definition at line 259 of file hal.h.

#define HAL_SS_PIN   SSPIN

The slave select pin.

Definition at line 347 of file hal.h.

Referenced by hal_init().

#define HAL_TRX_CMD_FR   (0x20)

Frame Receive Mode (long mode).

Definition at line 77 of file hal.c.

Referenced by hal_frame_read().

#define HAL_TRX_CMD_FW   (0x60)

Frame Transmit Mode (long mode).

Definition at line 76 of file hal.c.

#define HAL_TRX_CMD_RADDRM   (0x7F)

Register Address Mask.

Definition at line 80 of file hal.c.

#define HAL_TRX_CMD_RR   (0x80)

Register Read (short mode).

Definition at line 75 of file hal.c.

#define HAL_TRX_CMD_RW   (0xC0)

Register Write (short mode).

Definition at line 74 of file hal.c.

#define HAL_TRX_CMD_SR   (0x00)

SRAM Read.

Definition at line 79 of file hal.c.

Referenced by hal_sram_read().

#define HAL_TRX_CMD_SW   (0x40)

SRAM Write.

Definition at line 78 of file hal.c.

Referenced by hal_sram_write().

#define HAL_TRX_END_MASK   ( 0x08 )

Mask for the TRX_END interrupt.

Definition at line 338 of file hal.h.

#define HAL_TRX_END_MASK   ( 0x08 )

Mask for the TRX_END interrupt.

Definition at line 467 of file hal.h.

#define HAL_TRX_UR_MASK   ( 0x40 )

Mask for the TRX_UR interrupt.

Definition at line 337 of file hal.h.

#define HAL_TRX_UR_MASK   ( 0x40 )

Mask for the TRX_UR interrupt.

Definition at line 466 of file hal.h.

#define PIN_RST   PIN( RSTPORT )

Pin (Read Access) where RST is connected.

Definition at line 255 of file hal.h.

#define PIN_RST   PIN( RSTPORT /* BUG? */)

Pin (Read Access) where RST is connected.

Definition at line 343 of file hal.h.

#define PIN_SLP_TR   PIN( SLPTRPORT )

Pin (Read Access) where SLP_TR is connected.

Definition at line 335 of file hal.h.

#define PIN_SLP_TR   PIN( SLPTRPORT )

Pin (Read Access) where SLP_TR is connected.

Definition at line 248 of file hal.h.

#define PORT_RST   PORT( RSTPORT )

Port (Write Access) where RST is connected.

Definition at line 342 of file hal.h.

#define PORT_RST   PORT( RSTPORT )

Port (Write Access) where RST is connected.

Definition at line 254 of file hal.h.

#define PORT_SLP_TR   PORT( SLPTRPORT )

Port (Write Access) where SLP_TR is connected.

Definition at line 247 of file hal.h.

#define PORT_SLP_TR   PORT( SLPTRPORT )

Port (Write Access) where SLP_TR is connected.

Definition at line 334 of file hal.h.

#define RADIO_VECT   INT5_vect

Macros defined for HAL_TIMER1.

These macros are used to define the correct setupt of the AVR's Timer1, and to ensure that the hal_get_system_time function returns the system time in symbols (16 us ticks).

Definition at line 301 of file hal.h.

#define RST   RSTPIN

Pin number that corresponds to the RST pin.

Definition at line 252 of file hal.h.

#define RST   RSTPIN

Pin number that corresponds to the RST pin.

Definition at line 340 of file hal.h.

Referenced by hal_init().

#define SLP_TR   SLPTRPIN

Pin number that corresponds to the SLP_TR pin.

Definition at line 332 of file hal.h.

Referenced by hal_init().

#define SLP_TR   SLPTRPIN

Pin number that corresponds to the SLP_TR pin.

Definition at line 245 of file hal.h.


Typedef Documentation

typedef void(* hal_rx_start_isr_event_handler_t)(uint32_t const isr_timestamp, uint8_t const frame_length)

RX_START event handler callback type.

Is called with timestamp in IEEE 802.15.4 symbols and frame length. See hal_set_rx_start_event_handler().

Definition at line 489 of file hal.h.

typedef void(* hal_rx_start_isr_event_handler_t)(uint32_t const isr_timestamp, uint8_t const frame_length)

RX_START event handler callback type.

Is called with timestamp in IEEE 802.15.4 symbols and frame length. See hal_set_rx_start_event_handler().

Definition at line 360 of file hal.h.

typedef void(* hal_trx_end_isr_event_handler_t)(uint32_t const isr_timestamp)

RRX_END event handler callback type.

Is called with timestamp in IEEE 802.15.4 symbols and frame length. See hal_set_trx_end_event_handler().

Definition at line 363 of file hal.h.

typedef void(* hal_trx_end_isr_event_handler_t)(uint32_t const isr_timestamp)

RRX_END event handler callback type.

Is called with timestamp in IEEE 802.15.4 symbols and frame length. See hal_set_trx_end_event_handler().

Definition at line 492 of file hal.h.


Function Documentation

void hal_frame_read ( hal_rx_frame_t rx_frame)

Transfer a frame from the radio transceiver to a RAM buffer.

This version is optimized for use with contiki RF230BB driver. The callback routine and CRC are left out for speed in reading the rx buffer. Any delays here can lead to overwrites by the next packet!

If the frame length is out of the defined bounds, the length, lqi and crc are set to zero.

Parameters:
rx_framePointer to the data structure where the frame is stored.

Definition at line 590 of file halbb.c.

References hal_rx_frame_t::crc, hal_rx_frame_t::data, HAL_MAX_FRAME_LENGTH, HAL_MIN_FRAME_LENGTH, HAL_SPI_TRANSFER_OPEN, hal_rx_frame_t::length, and hal_rx_frame_t::lqi.

void hal_frame_read ( hal_rx_frame_t rx_frame,
rx_callback_t  rx_callback 
)

This function will upload a frame from the radio transceiver's frame buffer.

If the frame currently available in the radio transceiver's frame buffer is out of the defined bounds. Then the frame length, lqi value and crc be set to zero. This is done to indicate an error.

Parameters:
rx_framePointer to the data structure where the frame is stored.
rx_callbackPointer to callback function for receiving one byte at a time.

Definition at line 430 of file hal.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, hal_rx_frame_t::crc, hal_rx_frame_t::data, HAL_CALCULATED_CRC_OK, HAL_MAX_FRAME_LENGTH, HAL_MIN_FRAME_LENGTH, HAL_SS_HIGH, HAL_SS_LOW, HAL_TRX_CMD_FR, hal_rx_frame_t::length, and hal_rx_frame_t::lqi.

void hal_frame_write ( uint8_t *  write_buffer,
uint8_t  length 
)

This function will download a frame to the radio transceiver's frame buffer.

Parameters:
write_bufferPointer to data that is to be written to frame buffer.
lengthLength of data. The maximum length is 127 bytes.

Definition at line 681 of file halbb.c.

References HAL_SPI_TRANSFER_OPEN.

Referenced by radio_send_data().

uint8_t hal_get_bat_low_flag ( void  )

This function returns the current value of the BAT_LOW flag.

The BAT_LOW flag is incremented each time a BAT_LOW event is signaled from the radio transceiver. This way it is possible for the end user to poll the flag for new event occurances.

Definition at line 187 of file hal.c.

uint8_t hal_get_pll_lock_flag ( void  )

This function returns the current value of the PLL_LOCK flag.

The PLL_LOCK flag is incremented each time a PLL_LOCK event is signaled from the radio transceiver. This way it is possible for the end user to poll the flag for new event occurances.

Definition at line 278 of file hal.c.

Referenced by radio_calibrate_pll().

hal_rx_start_isr_event_handler_t hal_get_rx_start_event_handler ( void  )

This function returns the active RX_START event handler.

Returns:
Current RX_START event handler registered.

Definition at line 242 of file hal.c.

uint8_t hal_register_read ( uint8_t  address)

This function reset the interrupt flags and interrupt event handlers (Callbacks) to their default value.

This function reads data from one of the radio transceiver's registers.

This function returns the current value of the BAT_LOW flag.

The BAT_LOW flag is incremented each time a BAT_LOW event is signaled from the radio transceiver. This way it is possible for the end user to poll the flag for new event occurances.This function clears the BAT_LOW flag.This function is used to set new TRX_END event handler, overriding old handler reference.This function is used to set new TRX_END event handler, overriding old handler reference.Remove event handler reference.This function returns the active RX_START event handler

Returns:
Current RX_START event handler registered.This function is used to set new RX_START event handler, overriding old handler reference.Remove event handler reference.This function returns the current value of the PLL_LOCK flag.

The PLL_LOCK flag is incremented each time a PLL_LOCK event is signaled from the radio transceiver. This way it is possible for the end user to poll the flag for new event occurances.This function clears the PLL_LOCK flag.This function reads data from one of the radio transceiver's registers.

Parameters:
addressRegister address to read from. See datasheet for register map.
See also:
Look at the at86rf230_registermap.h file for register address definitions.
Returns:
The actual value of the read register.
Parameters:
addressRegister address to read from. See datasheet for register map.
See also:
Look at the at86rf230_registermap.h file for register address definitions.
Returns:
The actual value of the read register.

Definition at line 484 of file halbb.c.

References HAL_SPI_TRANSFER_OPEN.

Referenced by hal_subregister_read(), hal_subregister_write(), radio_get_extended_address(), radio_get_pan_id(), radio_get_short_address(), and radio_init().

void hal_register_write ( uint8_t  address,
uint8_t  value 
)

This function writes a new value to one of the radio transceiver's registers.

See also:
Look at the at86rf230_registermap.h file for register address definitions.
Parameters:
addressAddress of register to write.
valueValue to write.

Definition at line 513 of file halbb.c.

References HAL_SPI_TRANSFER_OPEN.

Referenced by hal_subregister_write(), radio_configure_csma(), radio_init(), radio_set_extended_address(), radio_set_pan_id(), and radio_set_short_address().

void hal_sram_read ( uint8_t  address,
uint8_t  length,
uint8_t *  data 
)

Read SRAM.

This function reads from the SRAM of the radio transceiver.

Parameters:
addressAddress in the TRX's SRAM where the read burst should start
lengthLength of the read burst
dataPointer to buffer where data is stored.

Definition at line 559 of file hal.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, HAL_DUMMY_READ, HAL_SS_HIGH, HAL_SS_LOW, and HAL_TRX_CMD_SR.

void hal_sram_write ( uint8_t  address,
uint8_t  length,
uint8_t *  data 
)

Write SRAM.

This function writes into the SRAM of the radio transceiver.

Parameters:
addressAddress in the TRX's SRAM where the write burst should start
lengthLength of the write burst
dataPointer to an array of bytes that should be written

Definition at line 598 of file hal.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, HAL_SS_HIGH, HAL_SS_LOW, and HAL_TRX_CMD_SW.

uint8_t hal_subregister_read ( uint8_t  address,
uint8_t  mask,
uint8_t  position 
)

This function reads the value of a specific subregister.

See also:
Look at the at86rf230_registermap.h file for register and subregister definitions.
Parameters:
addressMain register's address.
maskBit mask of the subregister.
positionBit position of the subregister
Return values:
Valueof the read subregister.

Definition at line 538 of file halbb.c.

References hal_register_read().

Referenced by radio_batmon_get_status(), radio_batmon_get_voltage_range(), radio_batmon_get_voltage_threshold(), radio_calibrate_filter(), radio_calibrate_pll(), radio_get_cca_mode(), radio_get_clock_speed(), radio_get_device_role(), radio_get_ed_threshold(), radio_get_operating_channel(), radio_get_rssi_value(), radio_get_trx_state(), and radio_get_tx_power_level().

void hal_subregister_write ( uint8_t  address,
uint8_t  mask,
uint8_t  position,
uint8_t  value 
)

This function writes a new value to one of the radio transceiver's subregisters.

See also:
Look at the at86rf230_registermap.h file for register and subregister definitions.
Parameters:
addressMain register's address.
maskBit mask of the subregister.
positionBit position of the subregister
valueValue to write into the subregister.

Definition at line 560 of file halbb.c.

References hal_register_read(), and hal_register_write().

Referenced by mac_init(), radio_batmon_configure(), radio_calibrate_filter(), radio_calibrate_pll(), radio_configure_csma(), radio_init(), radio_reset_state_machine(), radio_set_cca_mode(), radio_set_clock_speed(), radio_set_device_role(), radio_set_operating_channel(), radio_set_trx_state(), radio_set_tx_power_level(), and radio_use_auto_tx_crc().

void RADIO_VECT ( void  )

Read SRAM.

ISR for the radio IRQ line, triggered by the input capture.

This function reads from the SRAM of the radio transceiver.

Parameters:
addressAddress in the TRX's SRAM where the read burst should start
lengthLength of the read burst
dataPointer to buffer where data is stored.Write SRAM

This function writes into the SRAM of the radio transceiver. It can reduce SPI transfers if only part of a frame is to be changed before retransmission.

Parameters:
addressAddress in the TRX's SRAM where the write burst should start
lengthLength of the write burst
dataPointer to an array of bytes that should be writtenISR for the radio IRQ line, triggered by the input capture. This is the interrupt service routine for timer1.ICIE1 input capture. It is triggered of a rising edge on the radio transceivers IRQ line.

This is the interrupt service routine for timer1.ICIE1 input capture. It is triggered of a rising edge on the radio transceivers IRQ line.