I added the battery detect mechanism. In my design our battery charger has indications of the charge. When the battery is detected the usb is enabled and initialized.
Unfortunately it still does not work. Any advice?
Here is my code as an example:
static void HT_Check_Battery_Status (void ) {
#if defined ( POWER_SAVING )
if ((BATT_STAT2) && (BATT_STAT1)) {
osal_pwrmgr_device( PWRMGR_BATTERY );
if (osal_pwrmgr_get_device()==PWRMGR_ALWAYS_ON) {
HAL_USB_INT_DISABLE();
HAL_USB_PULLUP_DISABLE();
}
}
else {
if (osal_pwrmgr_get_device()==PWRMGR_BATTERY) {
while (!CC2540_IS_XOSC_STABLE());
HalUARTInitUSB();
}
osal_pwrmgr_device( PWRMGR_ALWAYS_ON );
}
#endif
if (BATT_STAT2) {
PICTL|=BV(3);
}
else {
PICTL&=~BV(3);
}
if (BATT_STAT1) {
PICTL|=BV(2);
}
else {
PICTL&=~BV(2);
}
}
HAL_ISR_FUNCTION( HTport1Isr, P1INT_VECTOR )
{
HT_Check_Battery_Status();
P1IFG=0xff^BV(7);
P1IF=0;
}