Sensor 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,1,0,'A','S','M','A','C','K','S','E','N','S','O','R',0x00,0xE0};
#define MANUFACTURERID 0xff
#define EEP1 0xBB
#define EEP2 0xAA
#define EEP3 0xCC
#define RSSI_SENSOR 0
#define REPEATERID 0
#define STATUS_LRN_REQ 0x0F
#define MAX_RECLAIMS 6
#define RECLAIM_PAUSE 60
#define MAILBOX_INDEX 0
FLASH_DATA code u8gFlashData _at_ FLASH_START_DATA;
RAM0_SHADOW_STRUCT xdata ram0;
uint8 u8ReclaimCounter=0;
void sendMyTelegram()
{
do
{
} while (ram0.seed.u16Seed == 0);
}
void sendSMACKLearnRequest()
{
rTel.sm_lrn_req.u11ManufacturerId = MANUFACTURERID;
rTel.sm_lrn_req.u8EEP[0] = EEP1;
rTel.sm_lrn_req.u8EEP[1] = EEP2;
rTel.sm_lrn_req.u8EEP[2] = EEP3;
rTel.sm_lrn_req.u8RssiDbm = RSSI_SENSOR;
rTel.sm_lrn_req.u32RepeaterId = REPEATERID;
rTel.sm_lrn_req.u32SenderId = 0;
rTel.sm_lrn_req.u8Status = STATUS_LRN_REQ;
sendMyTelegram();
}
void sendDataTelegram()
{
uint16 u16Value;
sint16 s16negref;
sint16 s16posref;
sint16 s16adio0value;
sint16 s16adio1value;
sint16 s16adio2value;
rTel.t4bs.u8Data3 = ram0.u8ReclaimCounter;
rTel.t4bs.u8Data0 = (uint8)(u16Value);
rTel.t4bs.u8Data1 = (uint8)(u16Value);
rTel.t4bs.u8Data2 = (uint8)(u16Value);
rTel.t4bs.u32Id = 0;
rTel.t4bs.u8Status = 0;
sendMyTelegram();
}
void main()
{
uint8 u8state=0;
bit bReclaim = FALSE;
uint32 u32WatchdogPeriode;
mainInit();
mem_readRAM0((uint8*)&ram0, 0x00,
sizeof(RAM0_SHADOW_STRUCT));
mem_readFlash((uint8*)&u8gFlashShadow, FLASH_START_DATA,
sizeof(FLASH_DATA));
if (u8gFlashShadow.u16ResponseTime == 0xffff)
switch (u8ResetSrc)
{
ram0.u8ReclaimCounter = 0xff;
sendDataTelegram();
if (u8gFlashShadow.u32ControllerId != 0xffffffff)
bReclaim = TRUE;
else
{
ram0.u8ReclaimCounter = 0xEE;
}
break;
if (!(u8state & 0x04))
{
sendDataTelegram();
if (u8gFlashShadow.u32ControllerId != 0xffffffff)
bReclaim = TRUE;
else
{
ram0.u8ReclaimCounter = 0xDD;
}
}
break;
if (!(u8state & 0x08))
{
sendSMACKLearnRequest();
bReclaim = TRUE;
}
break;
default:
break;
}
if (bReclaim)
{
while (u8ReclaimCounter++ < MAX_RECLAIMS)
{
u8Result =
smack_reclaim(u8ReclaimType, MAILBOX_INDEX, &rTel, &pTel);
{
smartack_Evaluation();
break;
}
rTel.t1bs.u8Data = u8Result;
sendMyTelegram();
}
ram0.u8ReclaimCounter = u8ReclaimCounter;
}
while(1)
{
}
}
Sensor Application include file - main.h
#ifndef _MAIN_H_INCLUDED
#define _MAIN_H_INCLUDED
#define FLASH_START_DATA 0x6000
typedef struct
{
uint8 u8ReclaimCounter;
union
{
uint16 u16Seed;
struct
{
uint8 u8SeedHi;
uint8 u8SeedLo;
} seed;
} seed;
} RAM0_SHADOW_STRUCT;
typedef struct
{
uint16 u16ResponseTime;
uint8 u8MailboxIndex;
uint32 u32ControllerId;
} FLASH_DATA;
extern FLASH_DATA code u8gFlashData;
extern FLASH_DATA xdata u8gFlashShadow;
extern uint8 u8ReclaimCounter;
void smartack_Evaluation();
#endif
Sensor Application evaluation file - evaluation.c
#include "EO3100I_API.h"
#include "stdio.h"
#include "string.h"
#include "main.h"
#ifdef SMACK_TEST
char smack_sensor_buf[70];
#endif
FLASH_DATA xdata u8gFlashShadow;
void smartack_Evaluation()
{
{
{
{
u8gFlashShadow.u16ResponseTime = rTel.sm_lrn_ans.u56Data.answer_acknowledge.u16ResponseTime;
u8gFlashShadow.u8MailboxIndex = rTel.sm_lrn_ans.u56Data.answer_acknowledge.u8MailBoxIdx;
u8gFlashShadow.u32ControllerId = rTel.sm_lrn_ans.u32SenderId;
}
else
{
u8gFlashShadow.u16ResponseTime = 0xffff;
u8gFlashShadow.u8MailboxIndex = 0xff;
u8gFlashShadow.u32ControllerId = 0xffffffff;
}
mem_writeFlash((uint8*)(&u8gFlashShadow), FLASH_START_DATA,
sizeof(FLASH_DATA));
#ifdef SMACK_TEST
sprintf(smack_sensor_buf, " Learn Acknowledge ");
sprintf(smack_sensor_buf, " Response time %u ms ", rTel.sm_lrn_ans.u56Data.answer_acknowledge.u16ResponseTime);
sprintf(smack_sensor_buf, " Mailbox index %u ", rTel.sm_lrn_ans.u56Data.answer_acknowledge.u8MailBoxIdx);
sprintf(smack_sensor_buf, " Ack code %u ", rTel.sm_lrn_ans.u56Data.answer_acknowledge.u8AckCode);
sprintf(smack_sensor_buf, " Controller-ID %u ", rTel.sm_lrn_ans.u32SenderId);
#endif
break;
}
{
u8ReclaimCounter = 0x05;
#ifdef SMACK_TEST
switch (u8SignalIdx)
{
{
sprintf(smack_sensor_buf, " Mailbox empty ");
break;
}
{
sprintf(smack_sensor_buf, " Mailbox does not exist ");
break;
}
{
sprintf(smack_sensor_buf, " Reset signal ");
break;
}
default:
{
sprintf(smack_sensor_buf, " Unknown signal msg %d ", u8SignalIdx);
break;
}
}
#endif
break;
}
default:
{
#ifdef SMACK_TEST
uint8 i;
char * pBuf = smack_sensor_buf;
char tmp[4];
sprintf(smack_sensor_buf, " Data Telegramm ");
{
sprintf(tmp,
"%2x ", rTel.raw.
bytes[i]);
*pBuf++=tmp[0];
*pBuf++=tmp[1];
*pBuf++=0x20;
}
*pBuf=0;
#endif
break;
}
}
}
Config file - EO3100I_CFG.h
#ifndef _EO3100I_CFG_H_INCLUDED
#define _EO3100I_CFG_H_INCLUDED
void startupInit();
void mainInit();
#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()
{
}
volatile uint32 xdata u32gFilterValue[FILTER_NUM];
volatile uint8 xdata u8gFilterCfg[FILTER_NUM];
uint8 code io_param[] = {
0x07,
0x00,
0x0F,
0x00,
0x07,
0x00,
0x00,
0x03,
0x80,
0x7F,
0x0C,
0x00,
0x00,
0x00,
0x00,
};