#include #include #include #include #include #include "SxTimer/SxTimer.h" #include "hwpower.h" #include "KeyDef.h" #include "UsbDevDef.h" #include "usb_define.h" #include "usb2dev.h" #include "gpio.h" #include "DxHunting.h" #define KEYSCAN_FUNC DISABLE #define PWRON_SRC_PWR_VBUS POWER_ID_PSW3 #define GPIO_CARD_DETECT P_GPIO_12 extern BOOL DrvCARD_DetStrgCard(void); UINT32 flow_system_get_usb_status(void) { UINT32 ret = USB_CONNECT_NONE; USB_CHARGER_STS RetUSB = 0; if (gpio_getIntStatus(GPIO_INT_USBPLUGIN)) { // if use 562, need modify this for different vbus pin usb2dev_power_on_init(TRUE); usb2dev_set_config(USB_CONFIG_ID_STANDARD_CHARGER, FALSE); usb2dev_state_change(); RetUSB = usb2dev_check_charger(0); if (RetUSB == USB_CHARGER_STS_NONE) { ret = USB_CONNECT_PC; } else if (RetUSB == USB_CHARGER_STS_CHARGING_DOWNSTREAM_PORT) { ret = USB_CONNECT_CHARGING_PC; } else if (RetUSB == USB_CHARGER_STS_CHARGER) { ret = USB_CONNECT_CHARGER; } else { ret = USB_CONNECT_UNKNOWN; } if (ret == USB_CONNECT_PC || ret == USB_CONNECT_CHARGING_PC) { if (!gpio_getPin(GPIO_CARD_DETECT)) { // SD card inserted DrvGPIO_SetPhotoMovieModeFromMonitor(DX_HUNTING_MODE_CAMERA_MSDC); } else { // No SD card DrvGPIO_SetPhotoMovieModeFromMonitor(DX_HUNTING_MODE_CAMERA_UVAC); } } } return ret; } #if (KEYSCAN_FUNC == ENABLE) int SX_TIMER_FASTBOOT_DET_ID = -1; static void _detkey(void) { // sample code for key detection if (hwpower_get_power_key(POWER_ID_PSW1)) { // Reset shutdown timer hwpower_set_power_key(POWER_ID_PSW1, 0xf0); printf("Get power key\r\n"); } } SX_TIMER_ITEM(Fastboot_DetKey, _detkey, 5, FALSE) #endif int flow_system_init(void) { #if (KEYSCAN_FUNC == ENABLE) SxTimer_Init(); // detect system SxTimer_Open(); //start sxtimer task SX_TIMER_FASTBOOT_DET_ID = SxTimer_AddItem(&Timer_Fastboot_DetKey); SxTimer_SetFuncActive(SX_TIMER_FASTBOOT_DET_ID, TRUE); #endif return 0; }