AVR Z-LINKŪ


Hardware Abstraction Layer API Functions


Detailed Description

This set of functions (Some defined as macros) is the API for the Hardware Abstraction Layer. These functions gives complete access to all of the low level functionality of the radio transceiver (IO, SPI and ISR).


Defines

#define hal_disable_trx_interrupt()   ( HAL_DISABLE_INPUT_CAPTURE_INTERRUPT( ) )
 Disable the interrupt from the radio transceiver.
#define hal_enable_trx_interrupt()   ( HAL_ENABLE_INPUT_CAPTURE_INTERRUPT( ) )
 Enable the interrupt from the radio transceiver.
#define hal_get_rst()   ( ( PIN_RST & ( 1 << RST ) ) >> RST )
 Read current state of the RST pin (High/Low).
#define hal_get_slptr()   ( ( PIN_SLP_TR & ( 1 << SLP_TR ) ) >> SLP_TR )
 Read current state of the SLP_TR pin (High/Low).
#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_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.

Functions

void hal_clear_bat_low_flag (void)
 This function clears the BAT_LOW flag.
void hal_clear_pll_lock_flag (void)
 This function clears the PLL_LOCK flag.
void hal_clear_pll_unlock_flag (void)
 This function clears the PLL_UNLOCK flag.
void hal_clear_rx_start_event_handler (void)
 Remove event handler reference.
void hal_clear_rx_start_flag (void)
 This function clears the RX_START flag.
void hal_clear_trx_end_event_handler (void)
 Remove event handler reference.
void hal_clear_trx_end_flag (void)
 This function clears the TRX_END flag.
void hal_clear_trx_ur_flag (void)
 This function clears the TRX_UR flag.
void hal_clear_unknown_isr_flag (void)
 This function clears the UNKNOWN_ISR flag.
__z void hal_frame_read (hal_rx_frame_t *rx_frame)
 This function will upload a frame from the radio transceiver's frame buffer.
__z void hal_frame_write (uint8_t *write_buffer, uint8_t length)
 This function will download a frame to the radio transceiver's frame buffer.
uint8_t hal_get_bat_low_flag (void)
 This function returns the current value of the BAT_LOW flag.
uint8_t hal_get_pll_lock_flag (void)
 This function returns the current value of the PLL_LOCK flag.
uint8_t hal_get_pll_unlock_flag (void)
 This function returns the current value of the PLL_UNLOCK flag.
uint8_t hal_get_rx_start_flag (void)
 This function returns the current value of the RX_START flag.
uint32_t hal_get_system_time (void)
 This function returns the system time in symbols, as defined in the IEEE 802.15.4 standard.
uint8_t hal_get_trx_end_flag (void)
 This function returns the current value of the TRX_END flag.
uint8_t hal_get_trx_ur_flag (void)
 This function returns the current value of the TRX_UR flag.
uint8_t hal_get_unknown_isr_flag (void)
 This function returns the current value of the UNKNOWN_ISR flag.
void hal_init (void)
 This function initializes the Hardware Abstraction Layer.
uint8_t hal_register_read (uint8_t address)
 This function reads data from one of the radio transceiver's registers.
void hal_register_write (uint8_t address, uint8_t value)
 This function writes a new value to one of the radio transceiver's registers.
void hal_reset_flags (void)
 This function reset the interrupt flags and interrupt event handlers (Callbacks) to their default value.
void hal_set_rx_start_event_handler (hal_trx_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_set_trx_end_event_handler (hal_trx_isr_event_handler_t trx_end_callback_handle)
 This function is used to set new TRX_END event handler, overriding old handler reference.
__z void hal_sram_read (uint8_t address, uint8_t length, uint8_t *data)
 Read SRAM.
__z void hal_sram_write (uint8_t address, uint8_t length, uint8_t *data)
 Write SRAM.
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.


Define Documentation

 
#define hal_disable_trx_interrupt (  )     ( HAL_DISABLE_INPUT_CAPTURE_INTERRUPT( ) )

Disable the interrupt from the radio transceiver.

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

Definition at line 247 of file hal_avr.h.

 
#define hal_enable_trx_interrupt (  )     ( HAL_ENABLE_INPUT_CAPTURE_INTERRUPT( ) )

Enable the interrupt from the radio transceiver.

Definition at line 239 of file hal_avr.h.

Referenced by hal_init().

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

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

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

Definition at line 160 of file hal_avr.h.

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

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

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

Definition at line 119 of file hal_avr.h.

Referenced by is_sleeping().

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

This macro pulls the RST pin high.

Definition at line 146 of file hal_avr.h.

Referenced by tat_reset_trx().

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

This macro pulls the RST pin low.

Definition at line 152 of file hal_avr.h.

Referenced by tat_reset_trx().

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

This macro pulls the SLP_TR pin high.

Definition at line 105 of file hal_avr.h.

Referenced by tat_enter_sleep_mode(), tat_send_data(), and tat_send_data_with_retry().

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

This macro pulls the SLP_TR pin low.

Definition at line 111 of file hal_avr.h.

Referenced by tat_leave_sleep_mode(), tat_reset_state_machine(), tat_reset_trx(), tat_send_data(), and tat_send_data_with_retry().


Function Documentation

void hal_clear_bat_low_flag ( void   ) 

This function clears the BAT_LOW flag.

Definition at line 203 of file hal_avr.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, and hal_bat_low_flag.

00203                                    {
00204     
00205     AVR_ENTER_CRITICAL_REGION( );
00206     hal_bat_low_flag = 0;
00207     AVR_LEAVE_CRITICAL_REGION( );
00208 }

void hal_clear_pll_lock_flag ( void   ) 

This function clears the PLL_LOCK flag.

Definition at line 387 of file hal_avr.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, and hal_pll_lock_flag.

Referenced by tat_calibrate_pll().

00387                                     {
00388     
00389     AVR_ENTER_CRITICAL_REGION( );
00390     hal_pll_lock_flag = 0;
00391     AVR_LEAVE_CRITICAL_REGION( );
00392 }

void hal_clear_pll_unlock_flag ( void   ) 

This function clears the PLL_UNLOCK flag.

Definition at line 364 of file hal_avr.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, and hal_pll_unlock_flag.

00364                                       {
00365     
00366     AVR_ENTER_CRITICAL_REGION( );
00367     hal_pll_unlock_flag = 0;
00368     AVR_LEAVE_CRITICAL_REGION( );
00369 }

void hal_clear_rx_start_event_handler ( void   ) 

Remove event handler reference.

Definition at line 318 of file hal_avr.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, and rx_start_callback.

00318                                              {
00319     
00320     AVR_ENTER_CRITICAL_REGION( );
00321     rx_start_callback = NULL;
00322     AVR_LEAVE_CRITICAL_REGION( );
00323 }

void hal_clear_rx_start_flag ( void   ) 

This function clears the RX_START flag.

Definition at line 295 of file hal_avr.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, and hal_rx_start_flag.

00295                                     {
00296     
00297     AVR_ENTER_CRITICAL_REGION( );
00298     hal_rx_start_flag = 0;
00299     AVR_LEAVE_CRITICAL_REGION( );
00300 }

void hal_clear_trx_end_event_handler ( void   ) 

Remove event handler reference.

Definition at line 272 of file hal_avr.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, and trx_end_callback.

00272                                             {
00273     
00274     AVR_ENTER_CRITICAL_REGION( );
00275     trx_end_callback = NULL;
00276     AVR_LEAVE_CRITICAL_REGION( );
00277 }

void hal_clear_trx_end_flag ( void   ) 

This function clears the TRX_END flag.

Definition at line 249 of file hal_avr.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, and hal_trx_end_flag.

Referenced by tat_send_data_with_retry().

00249                                    {
00250     
00251     AVR_ENTER_CRITICAL_REGION( );
00252     hal_trx_end_flag = 0;
00253     AVR_LEAVE_CRITICAL_REGION( );
00254 }

void hal_clear_trx_ur_flag ( void   ) 

This function clears the TRX_UR flag.

Definition at line 226 of file hal_avr.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, and hal_trx_ur_flag.

00226                                   {
00227     
00228     AVR_ENTER_CRITICAL_REGION( );
00229     hal_trx_ur_flag = 0;
00230     AVR_LEAVE_CRITICAL_REGION( );
00231 }

void hal_clear_unknown_isr_flag ( void   ) 

This function clears the UNKNOWN_ISR flag.

Definition at line 341 of file hal_avr.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, and hal_unknown_isr_flag.

00341                                        {
00342     
00343     AVR_ENTER_CRITICAL_REGION( );
00344     hal_unknown_isr_flag = 0;
00345     AVR_LEAVE_CRITICAL_REGION( );
00346 }

__z void hal_frame_read ( hal_rx_frame_t *  rx_frame  ) 

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_frame Pointer to the data structure where the frame is stored.

Definition at line 527 of file hal_avr.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, HAL_CALCULATED_CRC_OK, HAL_DUMMY_READ, HAL_SS_HIGH, HAL_SS_LOW, and HAL_TRX_CMD_FR.

00527                                                    {
00528     
00529     AVR_ENTER_CRITICAL_REGION( );
00530     
00531     HAL_SS_LOW( );
00532     
00533     /*Send frame read command.*/
00534     SPDR = HAL_TRX_CMD_FR;
00535     while ((SPSR & (1 << SPIF)) == 0) {;}
00536     uint8_t frame_length = SPDR;
00537     
00538     /*Read frame length.*/    
00539     SPDR = HAL_DUMMY_READ;
00540     while ((SPSR & (1 << SPIF)) == 0) {;}
00541     frame_length = SPDR;
00542     
00543     /*Check for correct frame length.*/
00544     if ((frame_length >= HAL_MIN_FRAME_LENGTH) && (frame_length <= HAL_MAX_FRAME_LENGTH)) {
00545         
00546         /*Initialize some local variables.*/
00547         uint16_t crc = 0;
00548         uint8_t *rx_data = (rx_frame->data);
00549         
00550         rx_frame->length = frame_length; //Store frame length.
00551         
00552         /*Upload frame buffer to data pointer. Calculate CRC.*/
00553         do {
00554             
00555             SPDR = HAL_DUMMY_READ;
00556             while ((SPSR & (1 << SPIF)) == 0) {;}
00557             *rx_data = SPDR;
00558             crc = crc_ccitt_update( crc, *rx_data++ );
00559         } while (--frame_length > 0);
00560         
00561         /*Read LQI value for this frame.*/
00562         SPDR = HAL_DUMMY_READ;
00563         while ((SPSR & (1 << SPIF)) == 0) {;}
00564         rx_frame->lqi = SPDR;
00565         
00566         HAL_SS_HIGH( );
00567         
00568         /*Check calculated crc, and set crc field in hal_rx_frame_t accordingly.*/
00569         if (crc == HAL_CALCULATED_CRC_OK) { 
00570             rx_frame->crc = true; 
00571         } else { rx_frame->crc = false; }
00572     } else {
00573         
00574         rx_frame->length = 0;
00575         rx_frame->lqi    = 0;
00576         rx_frame->crc    = false;
00577         
00578         HAL_SS_HIGH( );    
00579     }
00580     
00581     AVR_LEAVE_CRITICAL_REGION( );
00582 }

__z 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_buffer Pointer to data that is to be written to frame buffer.
length Length of data. The maximum length is 127 bytes.

Definition at line 592 of file hal_avr.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, HAL_SS_HIGH, HAL_SS_LOW, HAL_TRX_CMD_FW, and HAL_TRX_CMD_RADDRM.

Referenced by tat_send_data(), and tat_send_data_with_retry().

00592                                                                  {
00593     
00594     length &= HAL_TRX_CMD_RADDRM; //Truncate length to maximum frame length.
00595     
00596     AVR_ENTER_CRITICAL_REGION( );
00597     
00598     HAL_SS_LOW( ); //Initiate the SPI transaction.
00599     
00600     /*SEND FRAME WRITE COMMAND AND FRAME LENGTH.*/
00601     SPDR = HAL_TRX_CMD_FW;
00602     while ((SPSR & (1 << SPIF)) == 0) {;}
00603     uint8_t dummy_read = SPDR;
00604         
00605     SPDR = length;
00606     while ((SPSR & (1 << SPIF)) == 0) {;}
00607     dummy_read = SPDR;
00608     
00609     //Download to the Frame Buffer.
00610     do {
00611         
00612         SPDR = *write_buffer++;
00613         while ((SPSR & (1 << SPIF)) == 0) {;}
00614         dummy_read = SPDR;
00615     } while (--length > 0);
00616     
00617     HAL_SS_HIGH( ); //Terminate SPI transaction.
00618     
00619     AVR_LEAVE_CRITICAL_REGION( );
00620 }

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 195 of file hal_avr.c.

References hal_bat_low_flag.

00195                                     {
00196     return hal_bat_low_flag;
00197 }

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 379 of file hal_avr.c.

References hal_pll_lock_flag.

Referenced by tat_calibrate_pll().

00379                                      {
00380     return hal_pll_lock_flag;
00381 }

uint8_t hal_get_pll_unlock_flag ( void   ) 

This function returns the current value of the PLL_UNLOCK flag.

The PLL_UNLOCK flag is incremented each time a PLL_UNLOCK 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 356 of file hal_avr.c.

References hal_pll_unlock_flag.

00356                                        {
00357     return hal_pll_unlock_flag;
00358 }

uint8_t hal_get_rx_start_flag ( void   ) 

This function returns the current value of the RX_START flag.

The RX_START flag is incremented each time a RX_START 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 287 of file hal_avr.c.

References hal_rx_start_flag.

00287                                      {
00288     return hal_rx_start_flag;
00289 }

uint32_t hal_get_system_time ( void   ) 

This function returns the system time in symbols, as defined in the IEEE 802.15.4 standard.

Returns:
The system time with symbol resolution.

Definition at line 707 of file hal_avr.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, and hal_system_time.

00707                                     {
00708     
00709     uint32_t system_time = hal_system_time; //Read current system time (MSB).
00710     system_time <<= 16;
00711     
00712     /*Disable interrupts. This is done since the TCNT1 value should not 
00713       be read when the timer is running.*/
00714     AVR_ENTER_CRITICAL_REGION( );
00715     
00716     system_time |= TCNT1; //Add 16 LSB. 
00717     
00718     AVR_LEAVE_CRITICAL_REGION( );
00719     
00720     //Return the system time in symbols.
00721     return ((system_time / HAL_US_PER_SYMBOL) & HAL_SYMBOL_MASK);
00722 }

uint8_t hal_get_trx_end_flag ( void   ) 

This function returns the current value of the TRX_END flag.

The TRX_END flag is incremented each time a TRX_END 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 241 of file hal_avr.c.

References hal_trx_end_flag.

Referenced by tat_send_data_with_retry().

00241                                     {
00242     return hal_trx_end_flag;
00243 }

uint8_t hal_get_trx_ur_flag ( void   ) 

This function returns the current value of the TRX_UR flag.

The TRX_UR flag is incremented each time a TRX_UR 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 218 of file hal_avr.c.

References hal_trx_ur_flag.

00218                                    {
00219     return hal_trx_ur_flag;
00220 }

uint8_t hal_get_unknown_isr_flag ( void   ) 

This function returns the current value of the UNKNOWN_ISR flag.

The UNKNOWN_ISR flag is incremented each time an UNKNOWN_ISR 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 333 of file hal_avr.c.

References hal_unknown_isr_flag.

00333                                         {
00334     return hal_unknown_isr_flag;
00335 }

void hal_init ( void   ) 

This function initializes the Hardware Abstraction Layer.

Definition at line 138 of file hal_avr.c.

References DDR_RST, DDR_SLP_TR, HAL_DD_MOSI, HAL_DD_SCK, HAL_DD_SS, HAL_DDR_SPI, HAL_ENABLE_OVERFLOW_INTERRUPT, hal_enable_trx_interrupt, HAL_PORT_SPI, hal_reset_flags(), hal_system_time, RST, and SLP_TR.

Referenced by tat_init().

00138                      {
00139     
00140     /*Reset variables used in file.*/
00141     hal_system_time = 0;
00142     hal_reset_flags( );
00143     
00144     /*IO Specific Initialization.*/
00145     DDR_SLP_TR |= (1 << SLP_TR); //Enable SLP_TR as output.
00146     DDR_RST    |= (1 << RST);    //Enable RST as output.
00147     
00148     /*SPI Specific Initialization.*/    
00149     //Set SS, CLK and MOSI as output.
00150     HAL_DDR_SPI  |= (1 << HAL_DD_SS) | (1 << HAL_DD_SCK) | (1 << HAL_DD_MOSI);
00151     HAL_PORT_SPI |= (1 << HAL_DD_SS) | (1 << HAL_DD_SCK); //Set SS and CLK high
00152     SPCR         = (1 << SPE) | (1 << MSTR); //Enable SPI module and master operation.
00153     SPSR         = (1 << SPI2X); //Enable doubled SPI speed in master mode.
00154 
00155     /*TIMER1 Specific Initialization.*/    
00156     TCCR1B = HAL_TCCR1B_CONFIG;       //Set clock prescaler  
00157     TIFR1 |= (1 << ICF1);             //Clear Input Capture Flag.
00158     HAL_ENABLE_OVERFLOW_INTERRUPT( ); //Enable Timer1 overflow interrupt. 
00159     hal_enable_trx_interrupt( );    //Enable interrupts from the radio transceiver.
00160 }

Here is the call graph for this function:

uint8_t hal_register_read ( uint8_t  address  ) 

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

Parameters:
address Register 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 405 of file hal_avr.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, HAL_DUMMY_READ, HAL_SS_HIGH, HAL_SS_LOW, HAL_TRX_CMD_RADDRM, and HAL_TRX_CMD_RR.

Referenced by hal_subregister_read(), hal_subregister_write(), ISR(), tat_do_cca(), tat_do_ed_scan(), tat_get_extended_address(), tat_get_pan_id(), tat_get_short_address(), and tat_init().

00405                                             {
00406     
00407     //Add the register read command to the register address.
00408     address &= HAL_TRX_CMD_RADDRM;
00409     address |= HAL_TRX_CMD_RR;
00410     
00411     AVR_ENTER_CRITICAL_REGION( );
00412     
00413     HAL_SS_LOW( ); //Start the SPI transaction by pulling the Slave Select low.
00414     
00415     /*Send Register address and read register content.*/
00416     SPDR = address;
00417     while ((SPSR & (1 << SPIF)) == 0) {;}
00418     uint8_t register_value = SPDR;
00419     
00420     SPDR = HAL_DUMMY_READ;
00421     while ((SPSR & (1 << SPIF)) == 0) {;}
00422     register_value = SPDR;
00423 
00424     HAL_SS_HIGH( ); //End the transaction by pulling the Slave Select High.  
00425     
00426     AVR_LEAVE_CRITICAL_REGION( );
00427     
00428     return register_value;
00429 }

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:
address Address of register to write.
value Value to write.

Definition at line 441 of file hal_avr.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, HAL_SS_HIGH, HAL_SS_LOW, HAL_TRX_CMD_RADDRM, and HAL_TRX_CMD_RW.

Referenced by hal_subregister_write(), ISR(), tat_do_ed_scan(), tat_init(), tat_set_extended_address(), tat_set_pan_id(), and tat_set_short_address().

00441                                                          {
00442                                        
00443     //Add the Register Write command to the address.
00444     address = HAL_TRX_CMD_RW | (HAL_TRX_CMD_RADDRM & address);
00445     
00446     AVR_ENTER_CRITICAL_REGION( );    
00447     
00448     HAL_SS_LOW( ); //Start the SPI transaction by pulling the Slave Select low.
00449     
00450     /*Send Register address and write register content.*/
00451     SPDR = address;
00452     while ((SPSR & (1 << SPIF)) == 0) {;}
00453     uint8_t dummy_read = SPDR;
00454     
00455     SPDR = value;
00456     while ((SPSR & (1 << SPIF)) == 0) {;}
00457     dummy_read = SPDR;
00458     
00459     HAL_SS_HIGH( ); //End the transaction by pulling the Slave Slect High.
00460     
00461     AVR_LEAVE_CRITICAL_REGION( );
00462 }

void hal_reset_flags ( void   ) 

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

Definition at line 167 of file hal_avr.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, hal_bat_low_flag, hal_pll_lock_flag, hal_pll_unlock_flag, hal_rx_start_flag, hal_trx_end_flag, hal_trx_ur_flag, hal_unknown_isr_flag, rx_start_callback, and trx_end_callback.

Referenced by hal_init().

00167                             {
00168     
00169     AVR_ENTER_CRITICAL_REGION( );
00170     
00171     //Reset Flags.
00172     hal_bat_low_flag     = 0;
00173     hal_trx_ur_flag      = 0;
00174     hal_trx_end_flag     = 0;
00175     hal_rx_start_flag    = 0;  
00176     hal_unknown_isr_flag = 0;
00177     hal_pll_unlock_flag  = 0;
00178     hal_pll_lock_flag    = 0;
00179     
00180     //Reset Associated Event Handlers.
00181     rx_start_callback = NULL;
00182     trx_end_callback  = NULL;
00183     
00184     AVR_LEAVE_CRITICAL_REGION( )
00185 }

void hal_set_rx_start_event_handler ( hal_trx_isr_event_handler_t  rx_start_callback_handle  ) 

This function is used to set new RX_START event handler, overriding old handler reference.

Definition at line 307 of file hal_avr.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, and rx_start_callback.

00307                                                                                            {
00308     
00309     AVR_ENTER_CRITICAL_REGION( );
00310     rx_start_callback = rx_start_callback_handle;
00311     AVR_LEAVE_CRITICAL_REGION( );
00312 }

void hal_set_trx_end_event_handler ( hal_trx_isr_event_handler_t  trx_end_callback_handle  ) 

This function is used to set new TRX_END event handler, overriding old handler reference.

Definition at line 261 of file hal_avr.c.

References AVR_ENTER_CRITICAL_REGION, AVR_LEAVE_CRITICAL_REGION, and trx_end_callback.

00261                                                                                          {
00262     
00263     AVR_ENTER_CRITICAL_REGION( );
00264     trx_end_callback = trx_end_callback_handle;
00265     AVR_LEAVE_CRITICAL_REGION( );
00266 }

__z 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:
address Address in the TRX's SRAM where the read burst should start
length Length of the read burst
data Pointer to buffer where data is stored.

Definition at line 632 of file hal_avr.c.

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

00632                                                                         {
00633     
00634     AVR_ENTER_CRITICAL_REGION( );
00635     
00636     HAL_SS_LOW( ); //Initiate the SPI transaction.
00637     
00638     /*Send SRAM read command.*/
00639     SPDR = HAL_TRX_CMD_SR;
00640     while ((SPSR & (1 << SPIF)) == 0) {;}
00641     uint8_t dummy_read = SPDR;
00642     
00643     /*Send address where to start reading.*/    
00644     SPDR = address;
00645     while ((SPSR & (1 << SPIF)) == 0) {;}
00646     dummy_read = SPDR;
00647     
00648     /*Upload the chosen memory area.*/
00649     do {
00650         
00651         SPDR = HAL_DUMMY_READ;
00652         while ((SPSR & (1 << SPIF)) == 0) {;}
00653         *data++ = SPDR;
00654     } while (--length > 0);
00655 
00656     HAL_SS_HIGH( );
00657     
00658     AVR_LEAVE_CRITICAL_REGION( );
00659 }

__z 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:
address Address in the TRX's SRAM where the write burst should start
length Length of the write burst
data Pointer to an array of bytes that should be written

Definition at line 671 of file hal_avr.c.

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

00671                                                                          {
00672     
00673     AVR_ENTER_CRITICAL_REGION( );
00674         
00675     HAL_SS_LOW( );
00676     
00677     /*Send SRAM write command.*/
00678     SPDR = HAL_TRX_CMD_SW;
00679     while ((SPSR & (1 << SPIF)) == 0) {;}
00680     uint8_t dummy_read = SPDR;
00681     
00682     /*Send address where to start writing to.*/
00683     SPDR = address;
00684     while ((SPSR & (1 << SPIF)) == 0) {;}
00685     dummy_read = SPDR;
00686     
00687     /*Upload the chosen memory area.*/
00688     do {
00689         
00690         SPDR = *data++;
00691         while ((SPSR & (1 << SPIF)) == 0) {;}
00692         dummy_read = SPDR;
00693     } while (--length > 0);
00694     
00695     HAL_SS_HIGH( );
00696     
00697     AVR_LEAVE_CRITICAL_REGION( );
00698 }

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:
address Main register's address.
mask Bit mask of the subregister.
position Bit position of the subregister
Return values:
Value of the read subregister.

Definition at line 476 of file hal_avr.c.

References hal_register_read().

Referenced by tat_batmon_get_status(), tat_batmon_get_voltage_range(), tat_batmon_get_voltage_threshold(), tat_calibrate_filter(), tat_calibrate_pll(), tat_get_cca_mode(), tat_get_clock_speed(), tat_get_ed_threshold(), tat_get_operating_channel(), tat_get_rssi_value(), tat_get_trx_state(), tat_get_tx_power_level(), and tat_send_data_with_retry().

00476                                                                                {
00477     
00478     //Read current register value and mask out subregister.
00479     uint8_t register_value = hal_register_read( address );
00480     register_value &= mask;
00481     register_value >>= position; //Align subregister value.
00482     
00483     return register_value;
00484 }

Here is the call graph for this function:

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:
address Main register's address.
mask Bit mask of the subregister.
position Bit position of the subregister
value Value to write into the subregister.

Definition at line 499 of file hal_avr.c.

References hal_register_read(), and hal_register_write().

Referenced by tat_batmon_configure(), tat_calibrate_filter(), tat_calibrate_pll(), tat_configure_csma(), tat_do_cca(), tat_init(), tat_reset_state_machine(), tat_set_cca_mode(), tat_set_clock_speed(), tat_set_operating_channel(), tat_set_trx_state(), tat_set_tx_power_level(), and tat_use_auto_tx_crc().

00500                                            {
00501     
00502     //Read current register value and mask area outside the subregister.
00503     uint8_t register_value = hal_register_read( address );
00504     register_value &= ~mask;
00505     
00506     //Start preparing the new subregister value. shift in place and mask.
00507     value <<= position;
00508     value &= mask;
00509     
00510     value |= register_value; //Set the new subregister value.
00511 
00512     //Write the modified register value.
00513     hal_register_write( address, value );
00514 }

Here is the call graph for this function:

@DOC_TITLE@
Generated on Wed Jul 11 18:16:32 2007 for AVR2001 AT86RF230 Software Programmer's Manual by doxygen 1.4.7