DolphinV4 API  1.6.1.0
Radio To ESP3 Example

Simple application demonstrating receiving telegrams with the radio module and sending it to the serial port using the ESP3 protocol

Application file - main.c

#include "EO3100I_API.h"
#include "EO3100I_CFG.h"
#include <string.h>
/************************************************************************-
EVA Board:
EVA300-3
Input PIN:
ADIO_6 for UART communication
Output PIN:
ADIO_7 for UART communication
SCSEDIO_0 indicates that an telegram ERP1 was send/received
SCLKDIO_1 indicates that an telegram ERP2 was send/received
Description:
This example demonstrates a serial (ESP3) gateway. All the radio telegrams that are received
from the AIR are sent to the UART and vice versa, all serial telegrams that are
received from the UART are send to the AIR.
Notes:
The return values of the radio_senTelegram are not checked!
The incoming radio telegram parameters pTel ARE transmitted through the UART!
-************************************************************************/
#define MODE_ESP3_TYPE_0A // MODE_ESP3_TYPE_01 = ESP3 packet DATA contains a ERP1 telegram.
// MODE_ESP3_TYPE_0A = ESP3 packet DATA a ERP2 telegram.
code uint8 VERSION_APP[] = {0xE0,'V','E','R','S','I','O','N',1,0,0,1,'A','R','A','D','I','O','T','O','E','S','P','3',0x00,0xE0};
#define MAX_DATA_SIZE 512
// Telegram types
uint8 u8PacketBuffer[MAX_DATA_SIZE];
uint8 u8Mode = 0; // 0 = ERP1 in ESP3 telegrams. 1 = ERP2 in ESP3 packets
void main()
{
// Init packet buffer pointer
pPacket.u8DataBuffer = u8PacketBuffer;
pTel2.p_tx.u8SubTelNum = 3;
// Init telegram param
pTel.p_tx.u8SubTelNum = 3;
pTel.p_tx.u32DestinationId = 0;
mainInit();
// We want to get the correct amount of sub telegrams in TEL_PARAM_TYPE
while(1)
{
// Handle radio to uart traffic
memset(&rTel, 0x00, sizeof(rTel));
memset(&rTel2, 0x00, sizeof(rTel2));
// Handle uart to radio traffic
if (uart_getPacket(&pPacket, MAX_DATA_SIZE) == OK)
{
switch (pPacket.u8Type)
{
if (misc_packetToRadio(&pPacket, &rTel, &pTel)==OK)
{
io_togDigital(SCSEDIO_0);
while (radio_sendTelegram(&rTel, &pTel) == BUFF_FULL); // not later than 100 ms the telegram is sent
}
break;
io_togDigital(SCLKDIO_1);
if (misc_packetToRadio2(&pPacket, &rTel2, &pTel2) == OK)
{
while (radio_sendTelegram2(&rTel2, &pTel2) == BUFF_FULL);
}
break;
if(pPacket.u8DataBuffer[0] == CO_WR_MODE)
{
if(pPacket.u8DataBuffer[1]<=1)
u8Mode = pPacket.u8DataBuffer[1];
}
break;
default:
break;
}
}
// Sending ESP3 with ERP1 or ERP2 format
if(u8Mode == 0)
{
if (radio_getTelegram(&rTel, &pTel) == OK)
{
io_togDigital(SCSEDIO_0);
misc_radioToPacket(&rTel, &pTel, &pPacket);
while (uart_sendPacket(&pPacket) != OK);
}
}
else
{
if (radio_getTelegram2(&rTel2, &pTel2) == OK)
{
io_togDigital(SCLKDIO_1);
misc_radio2ToPacket(&rTel2, &pTel2, &pPacket);
while (uart_sendPacket(&pPacket) != OK);
}
}
}
}



Config file - EO3100I_CFG.h

// Generated on 2013-06-07 13:28:38 by DolphinAPIConfigurator 1.1.0.20
#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 1
extern volatile uint32 xdata u32gFilterValue[FILTER_NUM];
extern volatile uint8 xdata u8gFilterCfg[FILTER_NUM];
//*********************IO PARAM******************************
extern uint8 code io_param[];
#endif //_EO3100I_CFG_H_INCLUDED



Config file - EO3100I_CFG.c

// Generated on 2013-06-07 13:28:13 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);
UART_INIT(uart_param, SET_ALL_PARAM);
}
//*********************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];
//*********************IO PARAM******************************
uint8 code io_param[] = {
0x07, //IDX_GPIO_CONF
0x00, //IDX_GPIO0_CONF
0x0C, //IDX_GPIO0_PULL_CONF
0x03, //IDX_GPIO0_DIR
0x00, //IDX_GPIO1_AN
0x00, //IDX_GPIO1_CONF0
0xC0, //IDX_GPIO1_CONF1
0x03, //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 Out None 0 No
// SCLKDIO1 : Digital I/O Out None 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 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