DolphinV4 API  1.6.1.0
Actuator example



Advanced application demonstrating how to creata an actuator with DolphinV4.



Application file - main.c

/************************************************************************-
EVA Board:
EVA300-3
Pin configuration:
Refer to "I/O Configuration overview" in EO3100I_CFG.h
Notes:
The example uses custom initialization, the mainInit generated by DolphinV4Suite is disabled.
Instead it was shifted to main. The UART_INIT is called in the gatway.c module initialization.
This example is a reduced version of the RemanESP3 example. It contains the same learn-in
functionality but does not support RemoteManagement.
************************************************************************/
#include "main.h"
#include "EO3100I_CFG.h"
#include "mod_button.h"
#include "mod_id.h"
// Application tasks
#include "gateway.h"
#include "switch.h"
#include "learn.h"
// Variables
APP_CONTEXT gContext; // Global context
// Globally define buttons
BTN_STRUCT btnLearn = { ADIO_3, // Pin
0, // Active state
200, // Time the button has to be in 'Active state' (pressed) to be recognized as pressed
200 }; // Time the button has to be out of 'Active state' (released) to be recognized as released
BTN_STRUCT btnClear = { ADIO_4, // Pin
0, // Active state
200, // Time the button has to be in 'Active state' (pressed) to be recognized as pressed
200 }; // Time the button has to be out of 'Active state' (released) to be recognized as released
// Version string
code uint8 VERSION_APP[] = {0xE0,'V','E','R','S','I','O','N',1,0,0,0,'A','A','C','T','U','A','T','O','R','_','V','4',0x00,0xE0};
// Therefore, mainInit() in EO3100I_CFG.c is commented
void mainInit()
{
radio_init(RADIO_BUFF_NUM, RADIO_MATURITY_TIME);
filter_init(filter_param, SET_ALL_PARAM);
}
void main()
{
mainInit();
// Init global variables
gContext.bTel = 0;
gContext.u8State = STATE_NORMAL;
gContext.u8BtnLearn = BTN_IDLE;
gContext.u8BtnClear = BTN_IDLE;
// Init modules
id_init();
// Init all tasks
gateway_init();
switch_init();
learn_init();
// Application loop
while (1)
{
// Receive radio telegram, update global context information so all tasks can use the received telegram
gContext.bTel = radio_getTelegram(&gContext.rTel, &gContext.pTel) == OK;
// Check Buttons
gContext.u8BtnLearn = btn_getState(&btnLearn);
gContext.u8BtnClear = btn_getState(&btnClear);
// Switch task is only executed in NORMAL state
if (gContext.u8State == STATE_NORMAL)
{
switch_exec();
}
// Execute the other tasks
gateway_exec();
learn_exec();
}
}



Config file - EO3100I_CFG.h

// Generated on 2013-07-12 10:29:01 by DolphinV4 API Configurator 1.2.0.7
#ifndef _EO3100I_CFG_H_INCLUDED
#define _EO3100I_CFG_H_INCLUDED
void startupInit();
void mainInit();
//*********************UART PARAM***************************
#define RX_RING_SIZE 34
#define TX_RING_SIZE 34
extern volatile uint8 xdata u8RxRing[RX_RING_SIZE];
extern volatile uint8 xdata u8TxRing[TX_RING_SIZE];
extern uint8 uart_param[];
//*********************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 4
extern volatile uint32 xdata u32gFilterValue[FILTER_NUM];
extern volatile uint8 xdata u8gFilterCfg[FILTER_NUM];
extern uint8 filter_param[];
//*********************IO PARAM******************************
extern uint8 code io_param[];
#endif //_EO3100I_CFG_H_INCLUDED



Config file - EO3100I_CFG.c

// Generated on 2013-07-12 10:29:01 by DolphinV4 API Configurator 1.2.0.7
#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_mod(CFG_ALL);
radio_init(RADIO_BUFF_NUM, RADIO_MATURITY_TIME);
UART_INIT(uart_param, SET_ALL_PARAM);
filter_init(filter_param, SET_ALL_PARAM);
isr_timer0Init();
misc_init();
pwr_selectXTAL();
}
*/
//*********************UART PARAM***************************
volatile uint8 xdata u8RxRing[RX_RING_SIZE];
volatile uint8 xdata u8TxRing[TX_RING_SIZE];
uint8 uart_param[] = {
BAUD_57600, //IDX_BAUD
RX_RING_SIZE, //IDX_RX_RING_SIZE
TX_RING_SIZE, //IDX_TX_RING_SIZE
};
//*********************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];
uint8 filter_param[] = {
FILTER_NUM, //IDX_FILTER_MAX
FILTER_ALL_AND //IDX_FILTER_OPERATOR
};
//*********************IO PARAM******************************
uint8 code io_param[] = {
0x07, //IDX_GPIO_CONF
0x00, //IDX_GPIO0_CONF
0x00, //IDX_GPIO0_PULL_CONF
0x0F, //IDX_GPIO0_DIR
0x00, //IDX_GPIO1_AN
0x00, //IDX_GPIO1_CONF0
0xC0, //IDX_GPIO1_CONF1
0x03, //IDX_GPIO1_DIG_CONF
0xA0, //IDX_GPIO1_DIR
0x5F, //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 Out None 0 No
// SCLKDIO1 : Digital I/O Out None 0 No
// WSDADIO2 : Digital I/O Out None 0 No
// RSDADIO3 : Digital I/O Out None 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 Out None 0 No
// ADIO6 : UART In Up 0 No
// ADIO7 : UART 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