Other Parts Discussed in Thread: CC2540
hello everyone...
i am making cc2540 based device in that i want call chargingStatus() function every 1 sec . for this i made following code but it isn't
working.i don't know what's the problem. i take this from keyfobdemo code.
in maintask.h file
#define CHARGER_STATUS_CHECK_EVT 0x0080 //SP
in maintask.c file
// How often to check status (in ms)
#define BATTERY_STATUS_CHECK_PERIOD 1000 // 1 sec check
if ( events & CHARGER_STATUS_CHECK_EVT )
{
if ( BATTERY_STATUS_CHECK_PERIOD )
{
osal_start_timerEx( mainTask_TaskID, CHARGER_STATUS_CHECK_EVT, BATTERY_STATUS_CHECK_PERIOD );
}
chargingStatus();
return (events ^ CHARGER_STATUS_CHECK_EVT);
}
void chargingStatus()
{
TURN_ON_CHARGER_OUTPUT();
if(CHARGER_INPUT_BV == 0x00) // check if 0
{
P1_0 = 1; // charging chargingSetState(0x00);
TURN_OFF_CHARGER_OUTPUT();
}
else
{
TURN_OFF_CHARGER_OUTPUT();
CHARGER_OUTPUT_DIR &= ~CHARGER_OUTPUT_BV; // Select direction as input
P1INP |= CHARGER_OUTPUT_BV; //make P1.5 high impedance
if(CHARGER_INPUT_BV == 0x00) // check if 0
{
P1_1 = 1; // nearlyfull chargingSetState(0x01);
}
else
{
P0_4 = 1; // fullycharged/not chargingSetState(0x02);
}
CHARGER_OUTPUT_DIR |= CHARGER_OUTPUT_BV; // Select direction as output
P1INP &= ~CHARGER_OUTPUT_BV; //make P1.5 inverse of high impedance
}
}
thanks in advance..