DolphinV4 API  1.6.1.0
RSSI Example

Simple application demonstrating how to show the Receive Radio Strength Indication (RSSI) and the usage of PWM.

Application file - main.c

/************************************************************************-
EVA Board:
EVA300-3
Input PIN:
none
Output PIN:
SCSEDIO0 PWM signal
Description:
This example demonstrates a RSSI signal interface. From the radio telegrams that are received
from the AIR the RSSI value will be transformed in a PWM signal depending of the value.
In order to show really the lowest dBm value from all the subtelegrams, we wait until all the subtelegrams
are received using the radio_waitEndMaturity(TRUE);
-************************************************************************/
#include "EO3100I_API.h"
#include "EO3100I_CFG.h"
//*********************PWM PARAM***************************
#define RADIO_TRHD_3 45
#define RADIO_TRHD_2 60
#define RADIO_TRHD_1 70
#define RADIO_TRHD_0 93
#define IO_PWM_PERIOD 320
#define IO_PWM_DUTY_4 (1.0 * IO_PWM_PERIOD)
#define IO_PWM_DUTY_3 (0.7 * IO_PWM_PERIOD)
#define IO_PWM_DUTY_2 (0.5 * IO_PWM_PERIOD)
#define IO_PWM_DUTY_1 (0.3 * IO_PWM_PERIOD)
#define IO_PWM_DUTY_0 (0.1 * IO_PWM_PERIOD)
#define IO_PWM_DUTY_INIT (IO_PWM_DUTY_0)
#define IO_PWM_HOLD 500
//************************* GLOBAL VARIABLES **************************
code uint8 RSSI_VERSION[] = {0xE0,'V','E','R','S','I','O','N',1,0,2,0,'A','R','S','S','I',0x00,0xE0}; // RSSI SW Version
//************************* END GLOBAL VARIABLES **************************
void main()
{
//
TEL_RADIO_TYPE2 rTel2; // Structure to intepret Radiodata as ...see docu
TEL_PARAM_TYPE2 pTel2; //param structure for received telegrams
TIMER_TYPE timer_Out_PWM;// SW timer structure for output of PWM signal
// Configuration of the low level peripherals, interrupts, pins and buffers
mainInit() ;
// Enable the radio reception
//Make sure that we wait for all subtelegrams in order to really get the lowest dBm value for the telegram
while(1)
{
// Watchdogtimerreset
// If there is a telegram in the buffer
if(radio_getTelegram2(&rTel2, &pTel2) == OK)
{
// dependent of the db value switch the duty cycle of the PWM output
if(pTel2.p_rx.u8Dbm < RADIO_TRHD_3)
{
timer1_param[IDX_TIMER1_DUTYCYCLE] = IO_PWM_DUTY_4;
}
else if(pTel2.p_rx.u8Dbm < RADIO_TRHD_2)
{
timer1_param[IDX_TIMER1_DUTYCYCLE] = IO_PWM_DUTY_3;
}
else if(pTel2.p_rx.u8Dbm < RADIO_TRHD_1)
{
timer1_param[IDX_TIMER1_DUTYCYCLE] = IO_PWM_DUTY_2;
}
else if(pTel2.p_rx.u8Dbm < RADIO_TRHD_0)
{
timer1_param[IDX_TIMER1_DUTYCYCLE] = IO_PWM_DUTY_1;
}
else
{
timer1_param[IDX_TIMER1_DUTYCYCLE] = IO_PWM_DUTY_0;
}
// Enables the timer for IO_PWM_HOLD to generate the PWM signal
// Start a sw timer for duration how long the PWM signal will be active
time_setTimerCount(&timer_Out_PWM, IO_PWM_HOLD);
}
// check if the PWM signal has to switched off when timeout of the sw timer occurs
if (time_getTimeOut(&timer_Out_PWM) == TIME_OUT)
}
}



Config file - EO3100I_CFG.h

// Generated on 2013-06-07 15:18:43 by DolphinAPIConfigurator 1.1.0.20
#ifndef _EO3100I_CFG_H_INCLUDED
#define _EO3100I_CFG_H_INCLUDED
void startupInit();
void mainInit();
//*********************RADIO PARAM***************************
#define RADIO_BUFF_NUM 10
#define RADIO_MATURITY_TIME 100
extern volatile RADIO_BUFFER_TYPE xdata gRadioBuff[RADIO_BUFF_NUM];
//*********************FILTER PARAM***************************
#define FILTER_NUM 1
extern volatile uint32 xdata u32gFilterValue[FILTER_NUM];
extern volatile uint8 xdata u8gFilterCfg[FILTER_NUM];
//*********************TIMER1 PARAM***************************
extern uint16 timer1_param[];
//*********************IO PARAM******************************
extern uint8 code io_param[];
#endif //_EO3100I_CFG_H_INCLUDED



Config file - EO3100I_CFG.c

// Generated on 2013-06-07 15:18:56 by DolphinAPIConfigurator 1.1.0.20
#include "EO3100I_API.h"
#include "EO3100I_CFG.h"
//*********************API INIT***************************
//Note: Function is called from startup.a51. Global variables are not yet initialized!
void startupInit()
{
io_init(io_param);
}
void mainInit()
{
radio_init(RADIO_BUFF_NUM, RADIO_MATURITY_TIME);
timer1_init(timer1_param, SET_ALL_PARAM);
}
//*********************RADIO PARAM***************************
volatile RADIO_BUFFER_TYPE xdata gRadioBuff[RADIO_BUFF_NUM];
//*********************FILTER PARAM***************************
volatile uint32 xdata u32gFilterValue[FILTER_NUM];
volatile uint8 xdata u8gFilterCfg[FILTER_NUM];
//*********************TIMER1 PARAM***************************
uint16 timer1_param[] = {
0x0140, // IDX_TIMER1_PERIODE
0x0000, // IDX_TIMER1_POSTSCALER
0x0020, // IDX_TIMER1_DUTYCYCLE
0x0001 // IDX_TIMER1_MODE
};
//*********************IO PARAM******************************
uint8 code io_param[] = {
0x07, //IDX_GPIO_CONF
0x04, //IDX_GPIO0_CONF
0x00, //IDX_GPIO0_PULL_CONF
0x01, //IDX_GPIO0_DIR
0x00, //IDX_GPIO1_AN
0x00, //IDX_GPIO1_CONF0
0x00, //IDX_GPIO1_CONF1
0x03, //IDX_GPIO1_DIG_CONF
0x00, //IDX_GPIO1_DIR
0x00, //IDX_GPIO1_PULL
0x0C, //IDX_GPIO2_CONF
0x00, //IDX_GPIO2_DIR
0x00, //IDX_GPIO0
0x00, //IDX_GPIO1
0x00, //IDX_GPIO2
};
// I/O Configuration overview
//
// Pin : Interface Direction Pull InitValue Interrupt
// SCSEDIO0 : PWM Out None 0 No
// SCLKDIO1 : Digital I/O In None 0 No
// WSDADIO2 : Digital I/O In None 0 No
// RSDADIO3 : Digital I/O In None 0 No
// ADIO0 : Digital I/O In None 0 No
// ADIO1 : Digital I/O In None 0 No
// ADIO2 : Digital I/O In None 0 No
// ADIO3 : Digital I/O In None 0 No
// ADIO4 : Digital I/O In None 0 No
// ADIO5 : Digital I/O In None 0 No
// ADIO6 : Digital I/O In None 0 No
// ADIO7 : Digital I/O In None 0 No
// WXIDIO : Digital I/O In Up 0 No
// WXODIO : Digital I/O In Up 0 No
// WAKE0 : Digital I/O In None 0 No
// WAKE1 : Digital I/O In None 0 No