Controller application example files
Controller Application file - main.c
#include "EO3100I_API.h"
#include "EO3100I_CFG.h"
#include "main.h"
code uint8 VERSION_APP[] = {0xE0,'V','E','R','S','I','O','N',1,0,2,0,'A','S','M','A','C','K','C','O','N','T','R','O','L','L','E','R',0x00,0xE0};
#define LED_ADIO5 SCSEDIO_0 // Rx telegram
#define LED_CH2 SCLKDIO_1 // Data in mailbox
#define LED_LMI RSDADIO_3 // learn mode
#define BTN_LEARN ADIO_3 // learn mode control
#define BTN_CLEAR ADIO_4 // reply data simulation (fill mailbox)
#define ledRxOff() io_setDigital(LED_ADIO5, 0)
#define ledRxToggle() io_togDigital(LED_ADIO5)
#define ledDataToggle() io_togDigital(LED_CH2)
#define ledLmiOn() io_setDigital(LED_LMI, 1)
#define ledLmiOff() io_setDigital(LED_LMI, 0)
#define BTN_ACTIVE 0 // switch to gnd -> ext. 100k pullup
BTN_STRUCT LEARN_BUTTON = { BTN_LEARN,
BTN_ACTIVE,
5,
100 };
BTN_STRUCT DATA_BUTTON = { BTN_CLEAR,
BTN_ACTIVE,
5,
100 };
uint8 xdata u8ShadowBuffer[256] _at_ 0x0;
uint8 Send_something(void);
uint8 Action_something(void);
uint8 Write_Flash(void);
uint8 GetFunctionCodes(void);
void WaitTime(uint16*);
void main()
{
uint8 u8Count;
bit1 bLearnModeOn = FALSE;
mainInit();
mem_readFlash((uint8 xdata *)&smSensors,APP_FLASH_LEARN_TABLE,
sizeof(smSensors));
ledRxOff();
ledLmiOff();
u8gGERssiDbm = 0x80;
while (1)
{
{
ledRxToggle();
}
if (btn_getState(&LEARN_BUTTON)==BTN_PRESSED)
{
bLearnModeOn = ~bLearnModeOn;
if (bLearnModeOn)
{
ledLmiOn();
}
else
{
ledLmiOff();
}
}
{
{
executeLearn();
break;
}
{
bLearnModeOn = ~bLearnModeOn;
ledLmiOff();
}
default:
break;
}
if (btn_getState(&DATA_BUTTON)==BTN_PRESSED)
{
ledDataToggle();
for(u8Count=0; u8Count<MAX_SMACK_SENSORS; u8Count++)
{
if(smSensors[u8Count].u32SensorId != NO_SENSOR_ID)
{
r4bs.t4bs.u8Data3 = 0xAF;
r4bs.t4bs.u8Data2 = 0xFE;
r4bs.t4bs.u8Data1 = 0x00;
r4bs.t4bs.u8Data0 = u8Count;
r4bs.t4bs.u32Id = 0x0410007F;
r4bs.t4bs.u8Status = 0x00;
}
}
}
}
}
Controller Application include file - main.h
#ifndef _TESTMAIN_H_INCLUDED
#define _TESTMAIN_H_INCLUDED
#include "EO3100I_API.h"
#include "string.h"
#include "mod_button.h"
#define APP_FLASH_LEARN_TABLE 0x7600
#define MAX_SMACK_SENSORS 2
#define NO_SENSOR_ID 0xFFFFFFFF
#define RESPONSE_TIME 0x0080
typedef struct
{
uint32 u32SensorId;
uint32 u32PostMasterId;
uint8 u8LearnCount;
}LEARNED_SENSORS;
void executeLearn();
#endif
Controller Application file for learn - executeLearn.c
#include "main.h"
void executeLearn()
{
uint8 u8Count;
for(u8Count=0;u8Count<MAX_SMACK_SENSORS;u8Count++)
{
if(smSensors[u8Count].u32SensorId==smResult.
u32SensorId)
{
smSensors[u8Count].u32SensorId = NO_SENSOR_ID;
mem_writeFlash((uint8)smSensors,APP_FLASH_LEARN_TABLE,
sizeof(smSensors));
return;
}
}
{
for(u8Count=0;u8Count<MAX_SMACK_SENSORS;u8Count++)
{
if(smSensors[u8Count].u32SensorId == NO_SENSOR_ID)
break;
}
if(u8Count == MAX_SMACK_SENSORS)
{
return;
}
mem_writeFlash((uint8)smSensors,APP_FLASH_LEARN_TABLE,
sizeof(smSensors));
return;
}
else
}
Config file - EO3100I_CFG.h
#ifndef _EO3100I_CFG_H_INCLUDED
#define _EO3100I_CFG_H_INCLUDED
void startupInit();
void mainInit();
#define MAILBOX_COUNT 10
#define MAILBOX_FLASH_ADDR 0x7500
extern volatile MAILBOX_XRAM xdata gMailBoxXRam[MAILBOX_COUNT];
extern uint16 code smack_param[];
extern uint8 code u8gSmartAckFlash[256];
#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[];
#define RADIO_BUFF_NUM 10
#define RADIO_MATURITY_TIME 100
#define FILTER_NUM 1
extern volatile uint32 xdata u32gFilterValue[FILTER_NUM];
extern volatile uint8 xdata u8gFilterCfg[FILTER_NUM];
extern uint8 code io_param[];
#endif //_EO3100I_CFG_H_INCLUDED
Config file - EO3100I_CFG.c
#include "EO3100I_API.h"
#include "EO3100I_CFG.h"
void startupInit()
{
}
void mainInit()
{
}
uint16 code smack_param[] = {
MAILBOX_COUNT,
MAILBOX_FLASH_ADDR
};
uint8 code u8gSmartAckFlash[256] _at_ MAILBOX_FLASH_ADDR;
volatile uint8 xdata u8RxRing[RX_RING_SIZE];
volatile uint8 xdata u8TxRing[TX_RING_SIZE];
uint8 uart_param[] = {
RX_RING_SIZE,
TX_RING_SIZE,
};
volatile uint32 xdata u32gFilterValue[FILTER_NUM];
volatile uint8 xdata u8gFilterCfg[FILTER_NUM];
uint8 code io_param[] = {
0x07,
0x00,
0x04,
0x0B,
0x00,
0x00,
0xC0,
0x03,
0x80,
0x7F,
0x0C,
0x00,
0x00,
0x00,
0x00,
};