Contiki 3.x
Functions
radioeng.c File Reference

Copyright (c) 2014, Analog Devices, Inc. More...

#include "aducrf101-include.h"

Go to the source code of this file.

Functions

RIE_Responses RadioGetAPIVersion (RIE_U32 *pVersion)
 Return the Radio Interface Engine API Version. More...
 
RIE_Responses RadioSwitchConfig (RIE_BaseConfigs BaseConfig)
 Change the Radio to using specified configuration. More...
 
RIE_Responses RadioInit (RIE_BaseConfigs BaseConfig)
 Initialise the Radio, using specified configuration. More...
 
RIE_Responses RadioDeInit (void)
 Deinitialise the Radio, and power it down. More...
 
RIE_Responses RadioPowerOff (void)
 Shutdown the radio and place it in its lowest power sleep mode. More...
 
RIE_Responses RadioTerminateRadioOp (void)
 Terminate a currently running radio RX or TX operation. More...
 
RIE_Responses RadioSetFrequency (RIE_U32 Frequency)
 Set frequency for radio communications. More...
 
RIE_Responses RadioSetModulationType (RIE_ModulationTypes ModulationType)
 Set the Radio Transmitter Modulation Type. More...
 
RIE_Responses RadioPayldManchesterEncode (RIE_BOOL bEnable)
 Enable or Disable Manchester Encoding of payload data. More...
 
RIE_Responses RadioPayldDataWhitening (RIE_BOOL bEnable)
 Enable or Disable Data Whitening of payload data. More...
 
RIE_Responses RadioTxPacketFixedLen (RIE_U8 Len, RIE_U8 *pData)
 Transmit a fixed length packet. More...
 
RIE_Responses RadioTxPacketVariableLen (RIE_U8 Len, RIE_U8 *pData)
 Transmit a Variable length packet. More...
 
RIE_BOOL RadioTxPacketComplete (void)
 Checks if a packet has finished transmitting. More...
 
RIE_Responses RadioTxSetPA (RIE_PATypes PAType, RIE_PAPowerLevel Power)
 Set PA Type and the Transmit Power Level for Radio Transmission. More...
 
RIE_Responses RadioTxCarrier (void)
 Transmit a carrier tone using the current radio configuration. More...
 
RIE_Responses RadioTxPreamble (void)
 Transmit a pre-amble (alternating ones and zeros) using the current radio configuration. More...
 
RIE_Responses RadioRxPacketFixedLen (RIE_U8 Len)
 Enter receive mode and wait for a packet to be received. More...
 
RIE_Responses RadioRxPacketVariableLen (void)
 Enter receive mode and wait for a packet to be received. More...
 
RIE_BOOL RadioRxPacketAvailable (void)
 Checks if a packet has been received. More...
 
RIE_Responses RadioRxPacketRead (RIE_U8 BufferLen, RIE_U8 *pPktLen, RIE_U8 *pData, RIE_S8 *pRSSIdBm)
 Read the packet that was received by the radio. More...
 
RIE_Responses RadioRxBERTestMode (void)
 Enter receiver Bit Error Rate (BER) test mode where the clock and data appear on GPIO pins. More...
 
void aducrf101_rx_packet_hook (void)
 Trigger function called by ADI radio engine upon packet RX.
 
RIE_Responses RadioRadioGetRSSI (RIE_S8 *pRSSIdBm)
 Return a Received Signal Strength Indicator value. More...
 
RIE_Responses RadioTxSetPower (RIE_PAPowerLevel Power)
 Set the Transmit Power Level for Radio Transmission. More...
 

Detailed Description

Copyright (c) 2014, Analog Devices, Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met:

NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Radio Interface Engine Functions

Version
v1.0
Author
PAD CSE group, Analog Devices Inc
Date
May 08th 2013

Definition in file radioeng.c.

Function Documentation

RIE_U32 RadioDeInit ( void  )

Deinitialise the Radio, and power it down.

Note
This can be called independently of all other functions to power down the radio
Returns
RIE_Responses Error code.

Definition at line 472 of file radioeng.c.

References NVIC_DisableIRQ(), RIE_Success, and UHFTRX_IRQn.

RIE_Responses RadioGetAPIVersion ( RIE_U32 *  pVersion)

Return the Radio Interface Engine API Version.

Parameters
pVersion:{} pVersion Storage for Radio Interface Engine API version.
RIE_U32 Version;
Response = RadioGetAPIVersion(&Version);
Returns
RIE_Responses Error code.

Definition at line 347 of file radioeng.c.

References RIE_Success.

RIE_U32 RadioInit ( RIE_BaseConfigs  BaseConfig)

Initialise the Radio, using specified configuration.

Parameters
BaseConfig:{DR_1_0kbps_Dev10_0kHz , DR_38_4kbps_Dev20kHz ,DR_300_0kbps_Dev75_0kHz }
  • DR_1_0kbps_Dev10_0kHz Base configuration of 1 kbps datarate, 10.0 kHz frequency deviation.
  • DR_38_4kbps_Dev20kHz Base configuration of 38.4 kbps datarate, 20 kHz frequency deviation.
  • DR_300_0kbps_Dev75_0kHz Base configuration of 300 kbps datarate, 75 kHz frequency deviation.
Note
This must be called before any other function is called.
Returns
RIE_Responses Error code.

Definition at line 396 of file radioeng.c.

References NVIC_ClearPendingIRQ(), NVIC_DisableIRQ(), NVIC_EnableIRQ(), NVIC_SetPriority(), RadioPowerOff(), RIE_Success, and UHFTRX_IRQn.

RIE_Responses RadioPayldDataWhitening ( RIE_BOOL  bEnable)

Enable or Disable Data Whitening of payload data.

     Data whitening can be employed to avoid long runs of 1s or 0s
     in the transmitted data stream. 

     This ensures sufficient bit transitions in the packet, which 
     aids in receiver clock and data recovery because the encoding 
     breaks up long runs of 1s or 0s in the transmit packet. 

     The data, excluding the preamble and sync word, is automatically
     whitened before transmission by XORing the data with an 8-bit 
     pseudorandom sequence. 

     At the receiver, the data is XORed with the same pseudorandom 
     sequence, thereby reversing the whitening. 

     The linear feedback shift register polynomial used is x7 + x1 + 1.
Parameters
bEnable:{RIE_FALSE, RIE_TRUE}
  • RIE_TRUE if Manchester Encoding is to be enabled.
  • RIE_FALSE if disabled.
Precondition
RadioInit() must be called before this function is called.
Note
Data Whitening is disabled by default.
Returns
RIE_Responses Error code

Definition at line 729 of file radioeng.c.

References RIE_FALSE, RIE_Success, RIE_TRUE, and RIE_UnsupportedRadioConfig.

RIE_Responses RadioPayldManchesterEncode ( RIE_BOOL  bEnable)

Enable or Disable Manchester Encoding of payload data.

   Manchester encoding can be used to ensure a dc-free (zero mean) 
   transmission. 

   A Binary 0 is mapped to 10, and a Binary 1 is mapped to 01. 

   Manchester encoding and decoding are applied to the payload data 
   and the CRC. 
Parameters
bEnable:{RIE_FALSE,RIE_TRUE}
  • RIE_TRUE if Manchester Encoding is to be enabled.
  • RIE_FALSE if disabled.
Precondition
RadioInit() must be called before this function is called.
Note
Manchester Encoding is disabled by default.
Returns
RIE_Responses Error code

Definition at line 670 of file radioeng.c.

References RIE_FALSE, RIE_Success, RIE_TRUE, and RIE_UnsupportedRadioConfig.

RIE_Responses RadioPowerOff ( void  )

Shutdown the radio and place it in its lowest power sleep mode.

Precondition
RadioInit() must be called before this function is called.
Returns
RIE_Response Error code.

Definition at line 521 of file radioeng.c.

References RIE_Success.

Referenced by RadioInit().

RIE_Responses RadioRadioGetRSSI ( RIE_S8 *  pRSSIdBm)

Return a Received Signal Strength Indicator value.

Parameters
pRSSIdBm:{} detected RSSI in dBm.
Precondition
RadioInit() must be called before this function is called.
RIE_S8 RSSIdBm;
if (RIE_Response == RIE_Success)
RIE_Response = RadioRadioGetRSSI(&RSSIdBm);
Returns
RIE_Responses Error code

Definition at line 1692 of file radioeng.c.

References RIE_Success.

RIE_Responses RadioRxBERTestMode ( void  )

Enter receiver Bit Error Rate (BER) test mode where the clock and data appear on GPIO pins.

      Clock on P0.6 and Data on P2.6
Precondition
RadioInit() must be called before this function is called.
Response = RadioRxBERTestMode();
Note
Terminate this mode by calling RadioTerminateRadioOp();
Returns
RIE_Responses Error code

Definition at line 1185 of file radioeng.c.

References RIE_Success, and RIE_TRUE.

RIE_BOOL RadioRxPacketAvailable ( void  )

Checks if a packet has been received.

Precondition
RadioInit() must be called before this function is called.
RadioRxPacketFixedLen() or equivalent should be called first.
if (RIE_Response == RIE_Success)
RIE_Response = RadioRxPacketFixedLen(12);
if (RIE_Response == RIE_Success)
{
}
if (RIE_Response == RIE_Success)
{
unsigned char Buffer[0x20];
RIE_U8 PktLen;
RIE_S8 RSSI;
RIE_Response = RadioRxPacketRead(sizeof(Buffer),&PktLen,Buffer,&RSSI);
}
Returns
RIE_BOOL RIE_TRUE if packet received, else RIE_FALSE

Definition at line 1092 of file radioeng.c.

Referenced by RadioRxPacketRead().

RIE_Responses RadioRxPacketFixedLen ( RIE_U8  Len)

Enter receive mode and wait for a packet to be received.

Radio will stay in Receive Mode until 1) A packet is received. 2) User manually exits Receive Mode with a call to RadioTerminateRadioOp()

Parameters
Len:{1-240} Fixed Length of packet to be received.
Precondition
RadioInit() must be called before this function is called.
Returns
RIE_Responses Error code

Definition at line 1017 of file radioeng.c.

References RIE_FALSE, RIE_InvalidParamter, and RIE_Success.

RIE_Responses RadioRxPacketRead ( RIE_U8  BufferLen,
RIE_U8 *  pPktLen,
RIE_U8 *  pData,
RIE_S8 *  pRSSIdBm 
)

Read the packet that was received by the radio.

Parameters
BufferLen:{1-240} Size of passed in buffer
pPktLen:{1-240} Storage for size of actual received packet
pData:{} Received Packet will be stored here.
pRSSIdBm:{} RSSI of received packet in dBm.
Precondition
RadioInit() must be called before this function is called.
RadioRxPacketFixedLen() or equivalent should be called first.
if (RIE_Response == RIE_Success)
RIE_Response = RadioRxPacketFixedLen(12);
if (RIE_Response == RIE_Success)
{
}
if (RIE_Response == RIE_Success)
{
unsigned char Buffer[0x20];
RIE_U8 PktLen;
RIE_S8 RSSI;
RIE_Response = RadioRxPacketRead(sizeof(Buffer),&PktLen,Buffer,&RSSI);
}
Note
Check for the presence of a packet by calling RadioRxPacketAvailable();
Returns
RIE_Responses Error code

Definition at line 1125 of file radioeng.c.

References RadioRxPacketAvailable(), and RIE_Success.

RIE_Responses RadioRxPacketVariableLen ( void  )

Enter receive mode and wait for a packet to be received.

    Radio will stay in Receive Mode until 
    1) A packet is received. 
    2) User manually exits Receive Mode with a call to RadioTerminateRadioOp()
Precondition
RadioInit() must be called before this function is called.
Returns
RIE_Responses Error code

Definition at line 1050 of file radioeng.c.

References RIE_FALSE, and RIE_Success.

RIE_Responses RadioSetFrequency ( RIE_U32  Frequency)

Set frequency for radio communications.

Parameters
Frequency:{431000000-928000000}
  • This must be within the available bands of the radio:
    • 431000000Hz to 464000000Hz and
    • 862000000Hz to 928000000Hz.
Precondition
RadioInit() must be called before this function is called.
if (RIE_Response == RIE_Success)
RIE_Response = RadioSetFrequency(915000000);
Returns
RIE_Responses Error code

Definition at line 574 of file radioeng.c.

References RIE_Success, and RIE_TRUE.

RIE_Responses RadioSetModulationType ( RIE_ModulationTypes  ModulationType)

Set the Radio Transmitter Modulation Type.

Can be FSK_Modulation or GFSK_Modulation.

Parameters
ModulationType:{DR_1_0kbps_Dev10_0kHz , DR_38_4kbps_Dev20kHz ,DR_300_0kbps_Dev75_0kHz }
  • DR_1_0kbps_Dev10_0kHz Base configuration of 1 kbps datarate, 10.0 kHz frequency deviation.
  • DR_38_4kbps_Dev20kHz Base configuration of 38.4 kbps datarate, 20 kHz frequency deviation.
  • DR_300_0kbps_Dev75_0kHz Base configuration of 300 kbps datarate, 75 kHz frequency deviation.
Precondition
RadioInit() must be called before this function is called.
Note
FSK_Modulation is used by default.
Returns
RIE_Responses Error code

Definition at line 612 of file radioeng.c.

References FSK_Modulation, GFSK_Modulation, RIE_Success, RIE_TRUE, and RIE_UnsupportedRadioConfig.

RIE_U32 RadioSwitchConfig ( RIE_BaseConfigs  BaseConfig)

Change the Radio to using specified configuration.

Parameters
BaseConfig:{DR_1_0kbps_Dev10_0kHz, DR_38_4kbps_Dev20kHz, DR_300_0kbps_Dev75_0kHz}
  • DR_1_0kbps_Dev10_0kHz Base configuration of 1 kbps datarate, 10.0 kHz frequency deviation.
  • DR_38_4kbps_Dev20kHz Base configuration of 38.4 kbps datarate, 20 kHz frequency deviation.
  • DR_300_0kbps_Dev75_0kHz Base configuration of 300 kbps datarate, 75 kHz frequency deviation.
Precondition
RadioInit() must be called before this function is called.
Returns
RIE_Responses Error code.

Definition at line 369 of file radioeng.c.

References RIE_Success.

RIE_Responses RadioTerminateRadioOp ( void  )

Terminate a currently running radio RX or TX operation.

Precondition
RadioInit() must be called before this function is called.
if (RIE_Response == RIE_Success)
RIE_Response = RadioRxPacketFixedLen(12);
// Delay for a while waiting for a packet
if (RIE_Response == RIE_Success)
{
// Abort the waiting
RIE_Response = RadioTerminateRadioOp();
}
Returns
RIE_Responses Error code

Definition at line 551 of file radioeng.c.

References RIE_Success.

RIE_Responses RadioTxCarrier ( void  )

Transmit a carrier tone using the current radio configuration.

Precondition
RadioInit() must be called before this function is called.
Response = RadioTxCarrier();
Note
Terminate this mode by calling RadioTerminateRadioOp();
Returns
RIE_Responses Error code

Definition at line 959 of file radioeng.c.

References RIE_Success, and RIE_TRUE.

RIE_BOOL RadioTxPacketComplete ( void  )

Checks if a packet has finished transmitting.

Precondition
RadioInit() must be called before this function is called.
RadioRxPacketFixedLen() or equivalent should be called first.
if (RIE_Response == RIE_Success)
RIE_Response = RadioTxSetPA(DifferentialPA,PowerLevel15);
if (RIE_Response == RIE_Success)
RIE_Response = RadioTxPacketFixedLen(12, "HELLO WORLD");
Returns
RIE_BOOL RIE_TRUE if packet has finished transmitting, else RIE_FALSE

Definition at line 858 of file radioeng.c.

RIE_Responses RadioTxPacketFixedLen ( RIE_U8  Len,
RIE_U8 *  pData 
)

Transmit a fixed length packet.

Parameters
Len:{1-240} Length of packet to be transmitted.
pData:{} Data bytes to be transmitted.
Precondition
RadioInit() must be called before this function is called.
if (RIE_Response == RIE_Success)
RIE_Response = RadioTxSetPA(DifferentialPA,PowerLevel15);
if (RIE_Response == RIE_Success)
RIE_Response = RadioTxPacketFixedLen(12, "HELLO WORLD");
Returns
RIE_Responses Error code

Definition at line 772 of file radioeng.c.

References RIE_FALSE, RIE_InvalidParamter, and RIE_Success.

RIE_Responses RadioTxPacketVariableLen ( RIE_U8  Len,
RIE_U8 *  pData 
)

Transmit a Variable length packet.

Parameters
Len:{1-240} Length of packet to be transmitted.
pData:{} Data bytes to be transmitted.
Precondition
RadioInit() must be called before this function is called.
if (RIE_Response == RIE_Success)
RIE_Response = RadioTxSetPA(DifferentialPA,PowerLevel15);
if (RIE_Response == RIE_Success)
RIE_Response = RadioTxPacketVariableLen(12, "HELLO WORLD");
Returns
RIE_Responses Error code

Definition at line 813 of file radioeng.c.

References RIE_FALSE, RIE_InvalidParamter, and RIE_Success.

RIE_Responses RadioTxPreamble ( void  )

Transmit a pre-amble (alternating ones and zeros) using the current radio configuration.

Precondition
RadioInit() must be called before this function is called.
Response = RadioTxPreamble();
Note
Terminate this mode by calling RadioTerminateRadioOp();
Returns
RIE_Responses Error code

Definition at line 987 of file radioeng.c.

References RIE_Success, and RIE_TRUE.

RIE_Responses RadioTxSetPA ( RIE_PATypes  PAType,
RIE_PAPowerLevel  Power 
)

Set PA Type and the Transmit Power Level for Radio Transmission.

Parameters
PAType:{DifferentialPA, SingleEndedPA} Select Single Ended or Differential PA Type
Power:{PowerLevel0 ,PowerLevel1 ,PowerLevel2 ,PowerLevel3, PowerLevel4 ,PowerLevel5 ,PowerLevel6 ,PowerLevel7, PowerLevel8 ,PowerLevel9 ,PowerLevel10,PowerLevel11, PowerLevel12,PowerLevel13,PowerLevel14,PowerLevel15}
Precondition
RadioInit() must be called before this function is called.
Response = RadioTxSetPA(SingleEndedPA,PowerLevel8);
Note
Differential PA is enabled by default.
Max TX Power is used by default.
Returns
RIE_Responses Error code

Definition at line 879 of file radioeng.c.

References DifferentialPA, RIE_Success, RIE_TRUE, RIE_UnsupportedRadioConfig, and SingleEndedPA.

RIE_Responses RadioTxSetPower ( RIE_PAPowerLevel  Power)

Set the Transmit Power Level for Radio Transmission.

Parameters
Power:{PowerLevel0 ,PowerLevel1 ,PowerLevel2 ,PowerLevel3, PowerLevel4 ,PowerLevel5 ,PowerLevel6 ,PowerLevel7, PowerLevel8 ,PowerLevel9 ,PowerLevel10,PowerLevel11, PowerLevel12,PowerLevel13,PowerLevel14,PowerLevel15}
Precondition
RadioInit() must be called before this function is called.
Response = RadioTxSetPower(PowerLevel8);
Note
Max TX Power is used by default.
Returns
RIE_Responses Error code

Definition at line 1727 of file radioeng.c.

References RIE_Success, and RIE_UnsupportedRadioConfig.