Application file - main.c
#include "EO3100I_API.h"
#include "EO3100I_CFG.h"
#include "mod_button.h"
code uint8 VERSION_APP[] = {0xE0,'V','E','R','S','I','O','N',1,0,1,1,'A','R', 'E', 'M', 'O', 'T', 'E','C','O','N','T','R','O','L',0x00,0xE0};
BTN_STRUCT buttonA = { ADIO_3,
0,
10,
100 };
BTN_STRUCT buttonB = { ADIO_4,
0,
10,
100 };
void main()
{
mainInit();
rTel2.raw.
bytes[5] = 0x00;
while (1)
{
if (btn_getState(&buttonA)==BTN_PRESSED)
{
rTel2.raw.
bytes[5] = 0x50;
}
if (btn_getState(&buttonB)==BTN_PRESSED)
{
rTel2.raw.
bytes[5] = 0x70;
}
}
}
Module for handling buttons - mod_button.c
#include <EO3100I_API.h>
#include "mod_button.h"
BTN_STATE btn_getState(BTN_STRUCT *pBtn)
{
code uint8 transition_table[8][4]={ 0, 1, 0, 1,
5, 2, 5, 1,
5, 2, 5, 3,
5, 4, 5, 4,
5, 4, 5, 4,
6, 1, 0, 1,
6, 1, 7, 1,
0, 1, 0, 1 };
register uint8 u8Input;
u8Input = (u8Input == pBtn->u8ActiveState)?1:0;
pBtn->u8State = transition_table[pBtn->u8State][u8Input];
switch (pBtn->u8State)
{
case 1:
break;
case 5:
break;
}
return pBtn->u8State;
}
Module for handling buttons - mod_button.h
#ifndef _MOD_BUTTON_H_INCLUDED
#define _MOD_BUTTON_H_INCLUDED
#include <EO3100I_API.h>
typedef struct
{
uint8 u8Pin;
uint8 u8ActiveState;
uint16 u16TimeOutON;
uint16 u16TimeOutOFF;
uint8 u8State;
} BTN_STRUCT;
typedef enum
{
BTN_IDLE = 0,
BTN_EDGE1,
BTN_TRIGGERED,
BTN_PRESSED,
BTN_PRESS_HOLD,
BTN_EDGE2,
BTN_RELEASE_HOLD,
BTN_RELEASED
} BTN_STATE;
BTN_STATE btn_getState(BTN_STRUCT *pBtn);
#endif //_MOD_BUTTON_H_INCLUDED
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,
0x00,
0x00,
0x00,
0x03,
0x00,
0xFF,
0x0C,
0x00,
0x00,
0x00,
0x00,
};