/******************************************************************************* * * FUNCTION * FT_PowerOff * * DESCRIPTION * Power off sequence in META mode * * CALLS * custom_ft_util_check_if_usb_enable_support for check the USB_ENABLE compile option * USB_PowerControl * DclRTC_Open/DclRTC_Control (RTC_CMD_FT_POWEROFF command)/DclRTC_Close for RTC power off sequence (scramble PDN1 bit 7 for flashtool entering META mode) * DclPW_Open/DclPW_Control (PW_CMD_POWEROFF command)/DclPW_Close for Driver power off sequence * DclWDT_Open/DclWDT_Control (WDT_CMD_DRV_RESET command)/DclWDT_Close for Driver reset sequence * * PARAMETERS * void * * RETURNS * void * * GLOBALS AFFECTED * N/A * *******************************************************************************/ void FT_PowerOff(void) { #if (!defined(__SMART_PHONE_MODEM__)) kal_bool toolUsbReset = KAL_FALSE; if(true == custom_ft_util_check_if_usb_enable_support()) { // shutdown USB module /** * USB_PowerControl(KAL_FALSE) is no longer * to disable the usb power anymore. **/ #if defined(__USB_ENABLE__) DCL_BOOL dcl_data = DCL_TRUE; DCL_HANDLE usb_dcl_handle; usb_dcl_handle = DclUSB_DRV_Open(DCL_USB, FLAGS_NONE); DclUSB_DRV_Control(usb_dcl_handle, USB_DRV_CMD_PDN_ENABLE, (DCL_CTRL_DATA_T *)&dcl_data); DclUSB_DRV_Close(usb_dcl_handle); // USB_PDNmode(KAl_TRUE); #endif //#if defined(__USB_ENABLE__) } Custom_META_USBVirtualComDisconnect(); toolUsbReset = FT_ClearPowerKey(); if(tst_hal_USBDL_Is_USB_Download_Mode() == KAL_TRUE || /* Note: FEATURE compile option and references should be checked before patch-back */ tst_hal_USBDL_Is_USB_Fast_Meta_Mode() == KAL_TRUE) { // Driver power off sequence { DCL_HANDLE dcl_pmu_handle; dcl_pmu_handle=DclPW_Open(DCL_PW, FLAGS_NONE); DclPW_Control(dcl_pmu_handle,PW_CMD_POWEROFF,NULL); DclPW_Close(dcl_pmu_handle); } // really turn off the target because USB will provide power automatically to target side if(toolUsbReset == KAL_FALSE) { DCL_HANDLE dcl_wdt_handle; dcl_wdt_handle = DclWDT_Open(DCL_WDT, FLAGS_NONE); DclWDT_Control(dcl_wdt_handle, WDT_CMD_DRV_RESET, FLAGS_NONE); DclWDT_Close(dcl_wdt_handle); } else { while(1); } } #endif // #if (!defined(__SMART_PHONE_MODEM__)) }
void ft_util_watch_dog_start(FT_UTILITY_COMMAND_REQ *req, FT_UTILITY_COMMAND_CNF *cnf,peer_buff_struct *peer_buff_ret) { DCL_HANDLE dcl_wdt_handle; WDT_CTRL_SET_VALUE_T interval; WDT_CTRL_ENABLE_T enable; dcl_wdt_handle = DclWDT_Open(DCL_WDT, FLAGS_NONE); // set interval interval.u2Value = req->cmd.WatchDog.interval; DclWDT_Control(dcl_wdt_handle, WDT_CMD_SET_VALUE, (DCL_CTRL_DATA_T*)&interval); // send confirm first cnf->status = FT_CNF_OK; FT_UTIL_SendCnf(cnf,peer_buff_ret); kal_sleep_task(50); // disable all interrupt mask SaveAndSetIRQMask(); // restart timer DclWDT_Control(dcl_wdt_handle, WDT_CMD_RESTART, 0); // enable watch dog count down enable.fgEnable = KAL_TRUE; DclWDT_Control(dcl_wdt_handle, WDT_CMD_ENABLE, (DCL_CTRL_DATA_T*)&enable); DclWDT_Close(dcl_wdt_handle); Custom_META_USBVirtualComDisconnect(); while(1); }