DolphinV4 API  1.6.1.0
Standby Example



Application file - main.c

/************************************************************************-
EVA Board:
EVA320-2
Input PIN:
WAKE_0
wakes the CPU
WAKE_1
wakes the CPU
ADIO_5
external signal wakes the CPU
Output PIN:
ADIO_7
signalising a wake event
Description:
This application demonstrates the standby mode and several
wake soruces that can wake up the CPU from standby mode.
The program can be compiled with 3 different defines. Each
mode is focusing on different wake sources.
#define PIN_RX_WAKESRC
With this compilation is demonstrated how can the CPU wake up by following events:
PIN_WAKE0_WAKE
when WAKE0 pressed, the CPU wakes up from standby, ADIO_7 toggles 2 times
PIN_WAKE1_WAKE
when WAKE1 pressed, the CPU wakes up from standby, ADIO_7 toggles 3 times
PIN_EXT_WAKE
when there is a signal on pin ADIO5 the CPU wakes up from standby, ADIO_7 toggles 4 times
You can emulate the ADIO5 wakeup on the EVA board by pressing the BUTTON2, waiting
few seconds (until the CPU goes to standby) and releasing the button. After the button
is released the wakup is signalised with the ADIO_7 pin.
RX_RADIO_TEL_WAKE
When telegram is received, the CPU wakes up from standby, the ADIO_7
blinks 5 times
#define TX_WAKESRC
With this compilation is demonstrated how can the CPU wake up when telegram transmission is finished.
You can force transmission of a telegram using WAKE0 button. When the telegram transmission
is finished the ADIO_7 pin will go on. You can clear the ADIO_7 pin by pressing WAKE_1.
#define TIMER0_WAKESRC
With this compilation is demonstrated how can the CPU wakeup from TIMER0 scheduller.
Each 1 ms when the scheduller is called the ADIO_7 pin is toggled.
#define PWRFAIL_WAKESRC
With this compilation is demonstrated how can the CPU wakeup when VDD crosses the VON threshold.
You can demonstrate it by pulling the USB plug or by attaching an external power source and
modifying VDD level. When this happens the ADIO_7 pin is toggled.
Notes:
Be sure to use to enable at least 1 compilation define.
Use oscyloskop to debug define TIMER0_WAKESRC and PWRFAIL_WAKESRC.
-************************************************************************/
#include "EO3100I_API.h"
#include "EO3100I_CFG.h"
code uint8 VERSION_APP[] = {0xE0,'V','E','R','S','I','O','N',1,0,1,0,'A','S','T','A','N','D','B','Y',0x00,0xE0};
//#define PIN_RX_WAKESRC
#define TX_WAKESRC
//#define TIMER0_WAKESRC
//#define PWRFAIL_WAKESRC
void CallbackFN()
{
//dummy callback function
}
void CallbackVddFailFN()
{
//dummy callback function
}
void main()
{
uint8 u8Wake=0;
WAKE_TYPE u8Res;
uint8 pu8No=0;
uint8 u8Blink=0;
mainInit();
// Header: Only 32 bit Originator-ID, no extended Header, RPS telegram
// SourceID: set to 0x0000000, will be replaced in radio_sendTelegram() by the Module ID
rTel2.raw.bytes[1] = 0;
rTel2.raw.bytes[2] = 0;
rTel2.raw.bytes[3] = 0;
rTel2.raw.bytes[4] = 0;
// Data
rTel2.raw.bytes[5] = 0x00;
// Length
rTel2.raw.u8Length = 7;
// Telegram paraters: subtelegram count
pTel2.p_tx.u8SubTelNum = 3; // Send 3 subtelegrams
//configure callbac activated by ADIO5
io_ADIO46initCB((void *)&CallbackFN);
//configure callbac activated by VDD Fail
pwr_vddFailInitCB((void*)&CallbackVddFailFN);
isr_sysInit(TRUE);
while(1)
{
u8Res=0;
// TODO check, pwr_standbySleep always returning NOT_VALID_WAKEUP
#ifdef TIMER0_WAKESRC
//this is for testing TIMER0_WAKE event, in this case we wake up by each timer0 tick, i.e. each 1ms
#else
//this is for testing all the other events
#endif
//demonstrating wakeup with PIN and RADIO_RX wakeup src
#ifdef PIN_RX_WAKESRC
u8Blink=0;
switch (u8Res)
{
case PIN_WAKE0_WAKE: u8Blink=2; break;
case PIN_WAKE1_WAKE: u8Blink=3; break;
case PIN_EXT_WAKE: u8Blink=4; break;
case RX_RADIO_TEL_WAKE: u8Blink=5; break;
case NOT_VALID_WAKEUP: u8Blink=10; break;
}
uart_sendByte(u8Res);
for (i=0; i<u8Blink; i++)
{
io_setDigital(ADIO_7,1);
time_wait(150);
io_setDigital(ADIO_7,0);
time_wait(150);
}
#endif
//demonstrating wakeup with TX_FINISHED, telegram sending is triggered by PIN_WAKE0:
#ifdef TX_WAKESRC
switch (u8Res)
{
io_setDigital(ADIO_7,0);
//Since API version 2.2.0.0 there is always 1 radio buffer free for sending so no deadlock can happen if all radio Rx buffers are full
while (radio_sendTelegram2(&rTel2, &pTel2)==BUFF_FULL);
//wait until the timer0 interrupt triggers the Tx transmission and buffers are empty
do
while(pu8No);
break;
io_setDigital(ADIO_7,0);
break;
io_setDigital(ADIO_7,1);
break;
}
#endif
//demonstrating wakeup with VDD FAIL
#ifdef PWRFAIL_WAKESRC
if (u8Res == VDD_FAIL)
io_setDigital(ADIO_7,1);
io_setDigital(ADIO_7,0);
#endif
//demonstrating wakeup with VDD FAIL
#ifdef TIMER0_WAKESRC
if (u8Res == TIMER0_WAKE)
io_setDigital(ADIO_7,1);
io_setDigital(ADIO_7,0);
#endif
}
}



Config file - EO3100I_CFG.h

// Generated on 2013-06-07 15:47:55 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:52:02 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[] = {
0x0040, // IDX_TIMER1_PERIODE
0x0000, // IDX_TIMER1_POSTSCALER
0x0040, // IDX_TIMER1_DUTYCYCLE
0x0000 // IDX_TIMER1_MODE
};
//*********************IO PARAM******************************
uint8 code io_param[] = {
0x07, //IDX_GPIO_CONF
0x00, //IDX_GPIO0_CONF
0x0F, //IDX_GPIO0_PULL_CONF
0x00, //IDX_GPIO0_DIR
0x00, //IDX_GPIO1_AN
0x00, //IDX_GPIO1_CONF0
0x00, //IDX_GPIO1_CONF1
0x43, //IDX_GPIO1_DIG_CONF
0x80, //IDX_GPIO1_DIR
0x7F, //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 : Digital I/O In Up 0 No
// SCLKDIO1 : Digital I/O In Up 0 No
// WSDADIO2 : Digital I/O In Up 0 No
// RSDADIO3 : Digital I/O In Up 0 No
// ADIO0 : Digital I/O In Up 0 No
// ADIO1 : Digital I/O In Up 0 No
// ADIO2 : Digital I/O In Up 0 No
// ADIO3 : Digital I/O In Up 0 No
// ADIO4 : Digital I/O In Up 0 No
// ADIO5 : Digital I/O In Up 0 Falling
// ADIO6 : Digital I/O In Up 0 No
// ADIO7 : Digital I/O Out 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