Transceiver Access Functions
[Radio Library libradio_<board>.a]


Detailed Description

The low level interface to the radio chip.

The Transceiver function interface is described in transceiver.h

This group of functions provides the basic host access to the transceiver chip.

Various examples on how to use this module can be found here.


Defines

#define BPSK20_HSH   (0x52)
#define BPSK20_STR   "BPSK20"
#define BPSK40_HSH   (0x92)
#define BPSK40_STR   "BPSK40"
#define INVALID_PART_NUM   (2)
#define INVALID_REV_NUM   (1)
#define OQPSK1000_HSH   (0x34)
#define OQPSK1000_STR   "OQPSK1000"
#define OQPSK100_HSH   (0x90)
#define OQPSK100_STR   "OQPSK100"
#define OQPSK2000_HSH   (0x54)
#define OQPSK2000_STR   "OQPSK2000"
#define OQPSK200_HSH   (0x93)
#define OQPSK200_STR   "OQPSK200"
#define OQPSK250_HSH   (0x33)
#define OQPSK250_STR   "OQPSK250"
#define OQPSK400_HSH   (0x95)
#define OQPSK400_STR   "OQPSK400"
#define OQPSK500_HSH   (0x94)
#define OQPSK500_STR   "OQPSK500"
#define RATE_NONE_HSH   (0xFF)
#define TRX_IRQ_AMI_DI()   trx_bit_write(SR_MASK_AMI, 0);
 Disable AMI IRQ.
#define TRX_IRQ_AMI_EI()   trx_bit_write(SR_MASK_AMI, 1);
 Enable AMI IRQ.
#define TRX_IRQ_BAT_LOW_DI()   trx_bit_write(SR_MASK_BAT_LOW, 0);
 Disable BAT_LOW IRQ.
#define TRX_IRQ_BAT_LOW_EI()   trx_bit_write(SR_MASK_BAT_LOW, 1);
 Enable BAT_LOW IRQ.
#define TRX_IRQ_CCA_ED_READY_DI()   trx_bit_write(SR_MASK_CCA_ED_READY, 0);
 Disable CCA_ED_READY IRQ.
#define TRX_IRQ_CCA_ED_READY_EI()   trx_bit_write(SR_MASK_CCA_ED_READY, 1);
 Enable CCA_ED_READY IRQ.
#define TRX_IRQ_PLL_UNLOCK_DI()   trx_bit_write(SR_MASK_PLL_UNLOCK, 0);
 Disable PLL_UNLOCK IRQ.
#define TRX_IRQ_PLL_UNLOCK_EI()   trx_bit_write(SR_MASK_PLL_UNLOCK, 1);
 Enable PLL_UNLOCK IRQ.
#define TRX_IRQ_RX_START_DI()   trx_bit_write(SR_MASK_RX_START, 0);
 Disable RX_START IRQ.
#define TRX_IRQ_RX_START_EI()   trx_bit_write(SR_MASK_RX_START, 1);
 Enable RX_START IRQ.
#define TRX_IRQ_TRX_IRQ_END_DI()   trx_bit_write(SR_MASK_TRX_IRQ_END, 0);
 Disable TRX_IRQ_END IRQ.
#define TRX_IRQ_TRX_IRQ_END_EI()   trx_bit_write(SR_MASK_TRX_IRQ_END, 1);
 Enable TRX_IRQ_END IRQ.
#define TRX_IRQ_TRX_IRQ_START_DI()   trx_bit_write(SR_MASK_TRX_IRQ_START, 0);
 Disable TRX_IRQ_START IRQ.
#define TRX_IRQ_TRX_IRQ_START_EI()   trx_bit_write(SR_MASK_TRX_IRQ_START, 1);
 Enable TRX_IRQ_START IRQ.
#define TRX_IRQ_UR_DI()   trx_bit_write(SR_MASK_UR, 0);
 Disable TX/RX underun IRQ.
#define TRX_IRQ_UR_EI()   trx_bit_write(SR_MASK_UR, 1);
 Enable TX/RX underun IRQ.
#define TRX_NEXT_CHANNEL(x)   ((channel_t)(x+1) > TRX_MAX_CHANNEL ? TRX_MAX_CHANNEL : x+1)
#define TRX_NEXT_CHANNEL_WRAP(x)   ((channel_t)(x+1) > TRX_MAX_CHANNEL ? TRX_MIN_CHANNEL : x+1 )
#define TRX_PREV_CHANNEL(x)   ((channel_t)(x-1) < TRX_MIN_CHANNEL ? TRX_MIN_CHANNEL : x-1)
#define TRX_PREV_CHANNEL_WRAP(x)   ((channel_t)(x-1) < TRX_MIN_CHANNEL ? TRX_MAX_CHANNEL : x-1 )

Typedefs

typedef void(* trx_irq_handler_t )(uint8_t cause)
typedef uint8_t trx_ramaddr_t
typedef uint8_t trx_regaddr_t
typedef uint8_t trx_regval_t

Enumerations

enum  trx_cfg_t { CFG_FLASH, CFG_EEPROM, CFG_NONE }

Functions

trx_regval_t trx_bit_read (trx_regaddr_t addr, trx_regval_t mask, uint8_t pos)
 subregister read
void trx_bit_write (trx_regaddr_t addr, trx_regval_t mask, uint8_t pos, trx_regval_t value)
 subregister write
uint8_t trx_decode_datarate (uint8_t rhash, char *rstr, uint8_t nlen)
 Decodes a hash value and returns a datarate string pointer.
void * trx_decode_datarate_p (uint8_t rhash)
 Decodes a hash value and returns a datarate string pointer in program memory.
uint8_t trx_frame_get_length (void)
 Get length of a received frame.
uint8_t trx_frame_read (uint8_t *data, uint8_t datasz, uint8_t *lqi)
 Frame Read.
uint8_t trx_frame_read_crc (uint8_t *data, uint8_t datasz, bool *crc_ok)
 Frame Read with CRC check (and crc value kept).
uint8_t trx_frame_read_data_crc (uint8_t *data, uint8_t datasz, uint8_t *lqi, bool *crc_ok)
 Frame Read with CRC check (and crc value suppressed).
void trx_frame_write (uint8_t length, uint8_t *data)
 Frame Write.
uint8_t trx_get_datarate (void)
 get current adjusted data rate.
uint8_t trx_get_datarate_str (uint8_t idx, char *rstr, uint8_t nlen)
 return a copy of a data rate in a buffer.
void * trx_get_datarate_str_p (uint8_t idx)
 return a pointer to a datarate string in the programm memory.
uint8_t trx_get_number_datarates (void)
 return the number of supported data rates.
static int trx_identify (void)
 Verify that correct radio type is used.
static void trx_init (void)
 Basic radio initialization function,.
void trx_io_init (uint8_t spirate)
 SPI Initialization (RADIO_TYPE == AT86RF230).
void trx_parms_get (trx_param_t *p)
 Get static transceiver parameters.
uint8_t trx_parms_set (trx_param_t *p)
 Set static transceiver parameters.
uint8_t trx_reg_read (trx_regaddr_t addr)
 Read Register.
void trx_reg_write (trx_regaddr_t addr, trx_regval_t val)
 Write Register.
uint8_t trx_set_datarate (uint8_t rate_type)
 set data rate
void trx_set_irq_handler (trx_irq_handler_t irqhandler)
static void trx_set_panid (uint16_t panid)
 Write the PANID to the address filter registers.
static void trx_set_shortaddr (uint16_t shortaddr)
 Write the 16 bit short address to the address filter registers.
void trx_sram_read (trx_ramaddr_t addr, uint8_t length, uint8_t *data)
 Read SRAM.
void trx_sram_write (trx_ramaddr_t addr, uint8_t length, uint8_t *data)
 Write SRAM.


Define Documentation

#define INVALID_PART_NUM   (2)

flag for invalid part number

Definition at line 101 of file transceiver.h.

#define INVALID_REV_NUM   (1)

flag for invalid revision number

Definition at line 102 of file transceiver.h.

 
#define TRX_IRQ_AMI_DI (  )     trx_bit_write(SR_MASK_AMI, 0);

Disable AMI IRQ.

Definition at line 138 of file transceiver.h.

 
#define TRX_IRQ_AMI_EI (  )     trx_bit_write(SR_MASK_AMI, 1);

Enable AMI IRQ.

Definition at line 136 of file transceiver.h.

 
#define TRX_IRQ_BAT_LOW_DI (  )     trx_bit_write(SR_MASK_BAT_LOW, 0);

Disable BAT_LOW IRQ.

Definition at line 145 of file transceiver.h.

 
#define TRX_IRQ_BAT_LOW_EI (  )     trx_bit_write(SR_MASK_BAT_LOW, 1);

Enable BAT_LOW IRQ.

Definition at line 143 of file transceiver.h.

 
#define TRX_IRQ_CCA_ED_READY_DI (  )     trx_bit_write(SR_MASK_CCA_ED_READY, 0);

Disable CCA_ED_READY IRQ.

Definition at line 152 of file transceiver.h.

 
#define TRX_IRQ_CCA_ED_READY_EI (  )     trx_bit_write(SR_MASK_CCA_ED_READY, 1);

Enable CCA_ED_READY IRQ.

Definition at line 150 of file transceiver.h.

 
#define TRX_IRQ_PLL_UNLOCK_DI (  )     trx_bit_write(SR_MASK_PLL_UNLOCK, 0);

Disable PLL_UNLOCK IRQ.

Definition at line 159 of file transceiver.h.

 
#define TRX_IRQ_PLL_UNLOCK_EI (  )     trx_bit_write(SR_MASK_PLL_UNLOCK, 1);

Enable PLL_UNLOCK IRQ.

Definition at line 157 of file transceiver.h.

 
#define TRX_IRQ_RX_START_DI (  )     trx_bit_write(SR_MASK_RX_START, 0);

Disable RX_START IRQ.

Definition at line 166 of file transceiver.h.

 
#define TRX_IRQ_RX_START_EI (  )     trx_bit_write(SR_MASK_RX_START, 1);

Enable RX_START IRQ.

Definition at line 164 of file transceiver.h.

 
#define TRX_IRQ_TRX_IRQ_END_DI (  )     trx_bit_write(SR_MASK_TRX_IRQ_END, 0);

Disable TRX_IRQ_END IRQ.

Definition at line 173 of file transceiver.h.

 
#define TRX_IRQ_TRX_IRQ_END_EI (  )     trx_bit_write(SR_MASK_TRX_IRQ_END, 1);

Enable TRX_IRQ_END IRQ.

Definition at line 171 of file transceiver.h.

 
#define TRX_IRQ_TRX_IRQ_START_DI (  )     trx_bit_write(SR_MASK_TRX_IRQ_START, 0);

Disable TRX_IRQ_START IRQ.

Definition at line 180 of file transceiver.h.

 
#define TRX_IRQ_TRX_IRQ_START_EI (  )     trx_bit_write(SR_MASK_TRX_IRQ_START, 1);

Enable TRX_IRQ_START IRQ.

Definition at line 178 of file transceiver.h.

 
#define TRX_IRQ_UR_DI (  )     trx_bit_write(SR_MASK_UR, 0);

Disable TX/RX underun IRQ.

Definition at line 187 of file transceiver.h.

 
#define TRX_IRQ_UR_EI (  )     trx_bit_write(SR_MASK_UR, 1);

Enable TX/RX underun IRQ.

Definition at line 185 of file transceiver.h.


Typedef Documentation

typedef void(* trx_irq_handler_t)(uint8_t cause)

Data Type for Transceiver IRQ callback function

Definition at line 89 of file transceiver.h.

typedef uint8_t trx_ramaddr_t

Data Type for Transceiver SRAM address

Definition at line 75 of file transceiver.h.

typedef uint8_t trx_regaddr_t

Data Type for Transceiver register address

Definition at line 83 of file transceiver.h.

typedef uint8_t trx_regval_t

Data Type for Transceiver register value

Definition at line 79 of file transceiver.h.


Function Documentation

trx_regval_t trx_bit_read ( trx_regaddr_t  addr,
trx_regval_t  mask,
uint8_t  pos 
)

subregister read

Parameters:
addr offset of the register
mask bit mask of the subregister
pos bit position of the subregister
Return values:
data pointer where the read and demuxed value is stored
   pos = 4, mask = 0xf0
   register value = 0xA5
   *data = 0x0A

void trx_bit_write ( trx_regaddr_t  addr,
trx_regval_t  mask,
uint8_t  pos,
trx_regval_t  value 
)

subregister write

Parameters:
addr offset of the register
mask bit mask of the subregister
pos bit position of the subregister
Return values:
value data, which is muxed into the register
   pos = 4, mask = 0xf0
   register value = 0xA5 (before operation)
   value = 0x05
   register value = 0x55 (after operation)

uint8_t trx_decode_datarate ( uint8_t  rhash,
char *  rstr,
uint8_t  nlen 
)

Decodes a hash value and returns a datarate string pointer.

Parameters:
rhash Hash value of a data rate.
Return values:
rstr pointer to the buffer, where data rate is copied,
Parameters:
nlen maximum length of rstr
Returns:
255 in case the hashvalue rhash is not supported by the transceiver or invalid, otherwise 0.

void* trx_decode_datarate_p ( uint8_t  rhash  ) 

Decodes a hash value and returns a datarate string pointer in program memory.

Parameters:
rhash Hash value of a data rate.
Returns:
a string pointer in the programm memory

uint8_t trx_frame_get_length ( void   ) 

Get length of a received frame.

Returns:
length of the received frame

uint8_t trx_frame_read ( uint8_t *  data,
uint8_t  datasz,
uint8_t *  lqi 
)

Frame Read.

This function reads a frame from the transceiver.

Return values:
data Pointer to an array of (Payload-) bytes that should be sent
Parameters:
datasz maximum number of bytes, which fit in the data buffer.
Return values:
lqi Pointer where the LQI value is stored
Returns:
length of the downloaded frame (including the LQI byte [RADIO_TYPE == AT86RF230])

uint8_t trx_frame_read_crc ( uint8_t *  data,
uint8_t  datasz,
bool *  crc_ok 
)

Frame Read with CRC check (and crc value kept).

This function reads a frame from the transceiver. While the upload is in progress, the CRC16 value is caluculated and compared against the last two bytes.

Return values:
data Pointer to an array of (Payload-) bytes that should be sent
Parameters:
datasz maximum number of bytes, which fit in the data buffer.
Return values:
crc_ok Result of the CRC16 check.
Returns:
length of the downloaded frame (including the LQI byte [RADIO_TYPE == AT86RF230])
Todo:
implement this function

uint8_t trx_frame_read_data_crc ( uint8_t *  data,
uint8_t  datasz,
uint8_t *  lqi,
bool *  crc_ok 
)

Frame Read with CRC check (and crc value suppressed).

This function reads a frame from the transceiver. While the upload is in progress, the CRC16 value is caluculated and compared against the last two bytes. The crc bytes are not copied in the data buffer.

Return values:
data Pointer to an array of (Payload-) bytes that should be sent
Parameters:
datasz maximum number of bytes, which fit in the data buffer.
Return values:
lqi Pointer where the LQI value is stored
crc_ok Result of the CRC16 check.
Returns:
length of the downloaded frame (including the LQI byte [RADIO_TYPE == AT86RF230])
Todo:
implement this function

void trx_frame_write ( uint8_t  length,
uint8_t *  data 
)

Frame Write.

This function writes a frame to the transceiver.

Parameters:
length Length of the frame that should be written into the frame buffer
data Pointer to an array of (Payload-) bytes that should be sent
Note:
SLP_TR! (RADIO_TYPE == AT86RF230)

uint8_t trx_get_datarate ( void   ) 

get current adjusted data rate.

Returns:
hash code of currently set data rate.

uint8_t trx_get_datarate_str ( uint8_t  idx,
char *  rstr,
uint8_t  nlen 
)

return a copy of a data rate in a buffer.

Parameters:
idx Index of the data rate.
Return values:
rstr pointer to the buffer, where data rate is copied,
Parameters:
nlen maximum length of rstr
Returns:
255 in case the index idx is out of range, otherwise 0.

void* trx_get_datarate_str_p ( uint8_t  idx  ) 

return a pointer to a datarate string in the programm memory.

This function can be used to get a list of data rates, supported of the current radio transceiver.

Parameters:
idx Index of the data rate.
Returns:
Program memory string pointer.

uint8_t trx_get_number_datarates ( void   ) 

return the number of supported data rates.

static int trx_identify ( void   )  [static]

Verify that correct radio type is used.

Returns:
status value, with the following meaning:
  • 0 if part and revision number match
  • 1 if revision number does not match
  • 2 if part number does not match
  • 3 if part and revision number does not match

Definition at line 496 of file transceiver.h.

static void trx_init ( void   )  [static]

Basic radio initialization function,.

Definition at line 467 of file transceiver.h.

void trx_io_init ( uint8_t  spirate  ) 

SPI Initialization (RADIO_TYPE == AT86RF230).

Init the Serial Peripherial Interface of the AVR

Parameters:
spirate Configuration Byte of the SPI Control Register (SPCR)

void trx_parms_get ( trx_param_t p  ) 

Get static transceiver parameters.

This function reads the static transceiver parameters, defined in a structure and protects it with a CRC16.

Parameters:
p pointer to the data structure.

uint8_t trx_parms_set ( trx_param_t p  ) 

Set static transceiver parameters.

This function writes the static transceiver parameters, defined in a structure protects it with a CRC16.

Parameters:
p pointer to the data structure.
no_crc_check if this parameter is true, the the CRC given in the sructure is not checked.
Returns:
0 if OK, 1 if error.

uint8_t trx_reg_read ( trx_regaddr_t  addr  ) 

Read Register.

This function reads a transceiver register.

Parameters:
addr Address of the Register in the Transceiver (Offset) that should be read
Returns:
Contents of the Register

void trx_reg_write ( trx_regaddr_t  addr,
trx_regval_t  val 
)

Write Register.

This function write to a transceiver register.

Parameters:
addr Address of the Register in the Transceiver (Offset) that should be written
val Byte that will be written into the Register

uint8_t trx_set_datarate ( uint8_t  rate_type  ) 

set data rate

The transceiver is forced to state TRX_OFF in order to switch the data rate.

Parameters:
rate_type type code (the data rate hash codes, e.g. OQPSK250_HSH, e.g. *PSK_HSH macros) of the desired data rate.
Returns:
the value of rate_type parameter or RATE_NONE_HSH

void trx_set_irq_handler ( trx_irq_handler_t  irqhandler  ) 

set function pointer for IRQ handler

static void trx_set_panid ( uint16_t  panid  )  [static]

Write the PANID to the address filter registers.

Definition at line 515 of file transceiver.h.

static void trx_set_shortaddr ( uint16_t  shortaddr  )  [static]

Write the 16 bit short address to the address filter registers.

Definition at line 525 of file transceiver.h.

void trx_sram_read ( trx_ramaddr_t  addr,
uint8_t  length,
uint8_t *  data 
)

Read SRAM.

Parameters:
addr Address in the TRX's SRAM where the read burst should start
length Length of the write burst
Return values:
data Pointer to an array of bytes that should be read

void trx_sram_write ( trx_ramaddr_t  addr,
uint8_t  length,
uint8_t *  data 
)

Write SRAM.

This function writes into the SRAM of the transceiver.

Parameters:
addr 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


This documentation for µracoli was generated on 21 Jan 2010 by  doxygen 1.5.5