µracoli Manual Version foo

- µracoli
- User Guide
- Reference Guide

Data Structures
Transceiver API

The low level interface to the radio transceiver.
More...

## Data Structures
struct | trx_param_t

## Detailed Description

### Overview

Tranceiver API in liburacoli_<board>.a

Usage

This group of functions provides the register level access to the radio transceivers. The `trx` interface is given in transceiver.hThe use of the Transceiver API is illustrated by the following examples.

#include "board.h"
#include "transceiver.h"
mcu_init();
trx_io_init(SPI_RATE_1_2);
TRX_RESET_LOW();
TRX_SLPTR_LOW();
DELAY_US(TRX_RESET_TIME_US);
TRX_RESET_HIGH();
trx_reg_write(RG_TRX_STATE,CMD_TRX_OFF);

Examples

- xmpl_trx_base.c
- xmpl_trx_tx.c
- xmpl_trx_rx.c
- xmpl_trx_echo.c
- xmpl_trx_txaret.c
- xmpl_trx_rxaack.c

## Functions

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

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

1 pos = 4, mask = 0xf0
2 register value = 0xA5
3 *data = 0x0A

Examples:
  xmpl_radio_range.c, xmpl_trx_base.c, xmpl_trx_echo.c, xmpl_trx_rx.c, xmpl_trx_rxaack.c, xmpl_trx_tx.c, and xmpl_trx_txaret.c.

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

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

1 pos = 4, mask = 0xf0
2 register value = 0xA5 (before operation)
3 value = 0x05
4 register value = 0x55 (after operation)

Examples:
  xmpl_trx_echo.c, xmpl_trx_rx.c, xmpl_trx_rxaack.c, xmpl_trx_tx.c, and xmpl_trx_txaret.c.

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

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 | ) |

Parameters

  rhash | Hash value of a data rate.

Returns
  a string pointer in the programm memory

uint8_t trx_frame_get_length | ( | void |  | ) |

Returns
  length of the received frame

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

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])

Examples:
  xmpl_trx_echo.c, and xmpl_trx_rx.c.

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

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 two crc bytes are 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

  crc_ok | Result of the CRC16 check.

Returns
  length of the downloaded frame (including the LQI byte [RADIO_TYPE == AT86RF230])

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

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 two 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])

void trx_frame_write | ( | uint8_t | length,
|  | uint8_t * | data
| ) |  |

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)

Examples:
  xmpl_trx_echo.c, xmpl_trx_tx.c, and xmpl_trx_txaret.c.

uint8_t trx_get_datarate | ( | void |  | ) |

Returns
  hash code of currently set data rate.

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

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 | ) |

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.

static int trx_identify | ( | void |  | ) |
| static

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 532 of file transceiver.h.

void trx_io_init | ( | uint8_t | spirate | ) |

Parameters

  spirate | Configuration Byte of the SPI Control Register (SPCR) in case of RFA1, RFR2, ... this parameter is a dummy.

Examples:
  xmpl_trx_base.c, xmpl_trx_echo.c, xmpl_trx_rx.c, xmpl_trx_rxaack.c, xmpl_trx_tx.c, and xmpl_trx_txaret.c.

void trx_parms_get | ( | trx_param_t * | p | ) |

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 | ) |

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 | ) |

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

Examples:
  xmpl_radio_range.c, xmpl_trx_base.c, xmpl_trx_echo.c, xmpl_trx_rx.c, xmpl_trx_rxaack.c, xmpl_trx_tx.c, and xmpl_trx_txaret.c.

void trx_reg_write | ( | trx_regaddr_t | addr,
|  | trx_regval_t | val
| ) |  |

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

Examples:
  xmpl_trx_base.c, xmpl_trx_echo.c, xmpl_trx_rx.c, xmpl_trx_rxaack.c, xmpl_trx_tx.c, and xmpl_trx_txaret.c.

uint8_t trx_set_datarate | ( | uint8_t | rate_type | ) |

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, e.g. *PSK macros) of the desired data rate.

Returns
  the value of rate_type parameter or RATE_NONE

void trx_set_irq_handler | ( | trx_irq_handler_t | irqhandler | ) |

set function pointer for IRQ handler

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

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
| ) |  |

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

## Data Structure Documentation

struct trx_param_t

Transceiver parameter structure

Definition at line 341 of file const.h.

Data Fields
unsigned int | cca: 2 | CCA mode see sub register SR_CCA_MODE
channel_t | chan | current channel see sub register SR_CHANNEL
unsigned int | clkm: 3 | clkm control see sub register SR_CLKM_CTRL
unsigned int | edt: 4 | ED threshold see sub register SR_CCA_ED_THRES
unsigned int | txp: 4 | TX power index see sub register SR_TX_PWR

## Typedefs

typedef uint8_t ccamode_t

transceiver cca mode, 1 : ED, 2: CS, 3: CS & ED

Definition at line 334 of file const.h.

typedef int8_t channel_t

transceiver channel type

Definition at line 323 of file const.h.

typedef bool rxidle_t

radio idle state, if true radio idles in state PX_ON

Definition at line 331 of file const.h.

typedef void(* trx_irq_handler_t) (uint8_t cause)

Data Type for Transceiver IRQ callback function

Definition at line 95 of file transceiver.h.

typedef uint8_t trx_ramaddr_t

Data Type for Transceiver SRAM address

Definition at line 81 of file transceiver.h.

typedef uint8_t trx_regaddr_t

Data Type for Transceiver register address

Definition at line 89 of file transceiver.h.

typedef uint8_t trx_regval_t

Data Type for Transceiver register value

Definition at line 85 of file transceiver.h.

typedef int8_t txpwr_t

transceiver transmit type

Definition at line 326 of file const.h.

## Defines

#define DEFAULT_PAN_ID (0xb5c2)

Default PAN-ID value used by applications

Definition at line 308 of file const.h.

#define DEFAULT_SHORT_ADDRESS (0x6172)

Default short address value used by applications

Definition at line 310 of file const.h.

#define FCTL_ACK _BV(5)

ack request in frame control field

Definition at line 296 of file const.h.

#define FCTL_DATA _BV(0)

data frame fype in frame control field

Definition at line 295 of file const.h.

#define FCTL_DST_LONG 0x0c00

destination long address in frame control field

Examples:
  xmpl_radio_stream.c.

Definition at line 299 of file const.h.

#define FCTL_DST_SHORT 0x0800

destination short address in frame control field

Examples:
  xmpl_radio_stream.c.

Definition at line 298 of file const.h.

#define FCTL_IPAN _BV(6)

intra pan bit in frame control field

Definition at line 297 of file const.h.

#define FCTL_SRC_LONG 0xc000

source long address in frame control field

Examples:
  xmpl_radio_stream.c.

Definition at line 301 of file const.h.

#define FCTL_SRC_SHORT 0x8000

source short address in frame control field

Examples:
  xmpl_radio_stream.c.

Definition at line 300 of file const.h.

#define INVALID_PART_NUM (2)

flag for invalid part number

Definition at line 113 of file transceiver.h.

#define INVALID_REV_NUM (1)

flag for invalid revision number

Definition at line 114 of file transceiver.h.

#define MAX_FRAME_SIZE (127)

Maximum size in bytes of an IEEE 802.15.4 frame

Examples:
  xmpl_radio_range.c, xmpl_radio_stream.c, xmpl_trx_echo.c, and xmpl_trx_rx.c.

Definition at line 140 of file transceiver.h.

#define SPI_RATE_1_128 (3)

SPI clock running is 0.0078125 (1/128) of cpuclock

Definition at line 279 of file const.h.

#define SPI_RATE_1_16 (1)

SPI clock running is 0.0635 (1/16) of cpu clock

Definition at line 276 of file const.h.

#define SPI_RATE_1_2 (4)

SPI clock running is 0.5 (1/2) of cpu clock

Examples:
  xmpl_trx_base.c, xmpl_trx_echo.c, xmpl_trx_rx.c, xmpl_trx_rxaack.c, xmpl_trx_tx.c, and xmpl_trx_txaret.c.

Definition at line 273 of file const.h.

#define SPI_RATE_1_32 (6)

SPI clock running is 0.03125 (1/32)of cpu clock

Definition at line 277 of file const.h.

#define SPI_RATE_1_4 (0)

SPI clock running is 0.25 (1/4) of cpu clock

Definition at line 274 of file const.h.

#define SPI_RATE_1_64 (2)

SPI clock running is 0.015625 (1/64)of cpu clock

Definition at line 278 of file const.h.

#define SPI_RATE_1_8 (5)

SPI clock running is 0.125 (1/8) of cpu clock

Definition at line 275 of file const.h.

#define TRX_INIT_FAIL (1)

trx init function failed (TRX_OFF not reached after reset)

Definition at line 109 of file transceiver.h.

#define TRX_OK (0)

trx function succeeded

Definition at line 107 of file transceiver.h.

#define TRX_PLL_FAIL (2)

trx pll check function failed (PLL_LOCK coult not be observed in PLL_ON)

Definition at line 111 of file transceiver.h.