/** DevMan, Service command function implementation @file DeviceUsbMan.c @ingroup mDEVMAN Copyright Novatek Microelectronics Corp. 2012. All rights reserved. */ //global debug level: PRJ_DBG_LVL #include "PrjInc.h" //local debug level: THIS_DBGLVL #define THIS_DBGLVL 2 // 0=FATAL, 1=ERR, 2=WRN, 3=UNIT, 4=FUNC, 5=IND, 6=MSG, 7=VALUE, 8=USER /////////////////////////////////////////////////////////////////////////////// #define __MODULE__ SysStrgExe #define __DBGLVL__ ((THIS_DBGLVL>=PRJ_DBG_LVL)?THIS_DBGLVL:PRJ_DBG_LVL) #define __DBGFLT__ "*" //*=All, [mark]=CustomClass #include /////////////////////////////////////////////////////////////////////////////// //#include "SysKer.h" //#include "Debug.h" //#include "NvtUser.h" //#NT#2016/09/19#Niven Cho -begin //#NT#SD_HOTPLUG //#include "NVTUserCommand.h" //#NT#2016/09/19#Niven Cho -end //#include "NvtSystem.h" //#include "GxSystem.h" //#include "AppControl.h" //#include "SysMain.h" ///////////////////////////////////////////////////////////////////////////// // CARD #if (FS_FUNC == ENABLE) #include "GxStrg.h" #include "FileSysTsk.h" #if HUNTING_CAMERA_MCU == ENABLE #include #include #include "sf_sd_common.h" #include "SF_SysStrgMng.h" #endif void Strg_CB(UINT32 event, UINT32 param1, UINT32 param2); void Strg_CB(UINT32 event, UINT32 param1, UINT32 param2) { UINT32 status; #if HUNTING_CAMERA_MCU == ENABLE SF_MESSAGE_BUF_S stMessageBuf = {0}; #endif printf("Strg_CB: strg_id = %d, status = %d\n", param1, param2); switch (event) { // part-1 case SYSTEM_CB_CONFIG: //2.�]�wCB��, //3.���USxJob�A�� ---------> System Job //4.���USxTimer�A�� ---------> Detect Job //5.���USxCmd�A�� ---------> Cmd Function //System_AddSxCmd(Storage_OnCommand); //GxStorage break; case STRG_CB_INSERTED: //call after card inserted DBG_IND("CARD-%d inserted\r\n", param1 + 1); //#NT#2016/03/02#Niven Cho -begin //#NT#Fix FAST_BOOT + LINUX + without card, boot failed. #if defined(_CPU2_LINUX_) if (System_GetState(SYS_STATE_POWERON) == SYSTEM_POWERON_NORMAL) { Ux_PostEvent(NVTEVT_STRG_CHANGE, 1, param1); } #endif //#NT#2016/03/02#Niven Cho -end Ux_PostEvent(NVTEVT_STRG_INSERT, 1, param1); break; case STRG_CB_REMOVED: //call after card removed DBG_IND("CARD-%d removed\r\n", param1 + 1); //#NT#2016/03/02#Niven Cho -begin //#NT#Fix FAST_BOOT + LINUX + without card, boot failed. #if defined(_CPU2_LINUX_) if (System_GetState(SYS_STATE_POWERON) == SYSTEM_POWERON_NORMAL) { Ux_PostEvent(NVTEVT_STRG_CHANGE, 1, param1); } #endif //#NT#2016/03/02#Niven Cho -end //#NT#2016/09/19#Niven Cho -begin //#NT#SD_HOTPLUG #if (SDHOTPLUG_FUNCTION) //Post to UI window to stop capturing or recording Ux_PostEvent(NVTEVT_STORAGE_CHANGE, 1, param1); #endif //#NT#2016/09/19#Niven Cho -end Ux_PostEvent(NVTEVT_STRG_REMOVE, 1, param1); break; case STRG_CB_UNKNOWN: //call if card status is unknown DBG_IND("CARD-%d unknown\r\n", param1 + 1); DBG_IND("File abort\r\n"); { // abort file system ///FileSys_SetState(FST_STATE_ABORT,FST_CMD_CLOSE_FILE); ///FileSys_SetState(FST_STATE_ABORT,FST_CMD_DELETE_FILE); ///FileSys_SetState(FST_STATE_ABORT,FST_CMD_FORMAT); } DBG_ERR("^RCard unknown\r\n"); { //System_PowerOff(SYS_POWEROFF_NORMAL); } break; case STRG_CB_UNMOUNT_FINISH: status = param2; switch (status) { case FST_STA_OK: DBG_MSG("card-%d unmount OK\r\n", param1 + 1); break; default: DBG_MSG("^Rcard-%d unmount FAIL\r\n", param1 + 1); break; } Ux_PostEvent(NVTEVT_STRG_DETACH, 2, param1, status); break; case STRG_CB_MOUNT_FINISH: //after finish change storage status = param2; switch (status) { case FST_STA_OK: DBG_MSG("card-%d mount OK\r\n", param1 + 1); break; case FST_STA_DISK_UNFORMAT: DBG_MSG("^Rcard-%d mount FAIL: Unformat\r\n", param1 + 1); break; case FST_STA_DISK_UNKNOWN_FORMAT: DBG_MSG("^Rcard-%d mount FAIL: Unknown Format\r\n", param1 + 1); break; case FST_STA_CARD_ERR: DBG_MSG("^Rcard-%d mount FAIL: Card Error\r\n", param1 + 1); break; #if 0 case FST_STA_OUT_OF_ID: DBG_MSG("^Rcard-%d mount FAIL: Out of ID\r\n", stg_id + 1); break; #endif default: DBG_MSG("^Rcard-%d mount FAIL: ErrID=%d\r\n", param1 + 1, status); } { static BOOL bFirst = TRUE; if (bFirst) { TM_BOOT_END("sdio", "mount_fs"); } bFirst = FALSE; } #if (POWERON_FAST_BOOT == ENABLE) INIT_SETFLAG(FLGINIT_MOUNTFS); #endif Ux_PostEvent(NVTEVT_STRG_ATTACH, 2, param1, status); break; default: DBG_ERR("Strg_CB Err event(%d)", event); break; } #if HUNTING_CAMERA_MCU == ENABLE if((STRG_CB_MOUNT_FINISH == event) && (FST_STA_OK == param2) && (CMD_FORMAT_SD_STA != sf_get_card_statu())) { DBG_MSG("card-%d mount OK\r\n", param1 + 1); } else if((CMD_FORMAT_SD_STA != sf_get_card_statu())) { stMessageBuf.arg1 = event; stMessageBuf.arg2 = param1; stMessageBuf.arg3 = param2; stMessageBuf.cmdId = CMD_SD; sf_com_message_send_to_app(&stMessageBuf); printf("strg_cb send MOUNT! dev_id = %d\n", param1); #if USE_MMC_DEV_CHECK SF_StrgRegister(&stMessageBuf); #endif } #endif } #endif