160 lines
3.9 KiB
C
Executable File
160 lines
3.9 KiB
C
Executable File
#include <string.h>
|
|
#include <plat/sdio.h>
|
|
#include <plat/strg_def.h>
|
|
#include <hdal.h>
|
|
#include <FileSysTsk.h>
|
|
#include "sys_filesys.h"
|
|
#include "sys_mempool.h"
|
|
#include "FileDB.h"
|
|
#include "gpio.h"
|
|
#include <FreeRTOS.h>
|
|
#include <task.h>
|
|
#include "sys_fastboot.h"
|
|
#include "PrjCfg.h"
|
|
#include "DxHunting.h"
|
|
#if (HUNTING_CAMERA_MODEL == ENABLE)
|
|
|
|
#include "IOCfg.h"
|
|
|
|
#define GPIO_CARD_INSERT_LEVEL (FALSE) // low active
|
|
#define MAX_OPENED_FILE_NUM 10
|
|
|
|
static THREAD_HANDLE task_hdl;
|
|
|
|
static void card_insert_job(void)
|
|
{
|
|
UINT32 uiPoolAddr;
|
|
int ret;
|
|
|
|
FILE_TSK_INIT_PARAM Param = {0};
|
|
FS_HANDLE StrgDXH;
|
|
|
|
printf("filesys_init b\r\n");
|
|
memset(&Param, 0, sizeof(FILE_TSK_INIT_PARAM));
|
|
#if defined(_EMBMEM_EMMC_)
|
|
StrgDXH = (FS_HANDLE)sdio3_getStorageObject(STRG_OBJ_FAT1);
|
|
#else
|
|
StrgDXH = (FS_HANDLE)sdio_getStorageObject(STRG_OBJ_FAT1);
|
|
#endif
|
|
|
|
uiPoolAddr = mempool_filesys;
|
|
Param.FSParam.WorkBuf = uiPoolAddr;
|
|
Param.FSParam.WorkBufSize = (POOL_SIZE_FILESYS);
|
|
// support exFAT
|
|
Param.FSParam.bSupportExFAT = TRUE;
|
|
//Param.pDiskErrCB = (FileSys_CB)Card_InitCB;
|
|
strncpy(Param.FSParam.szMountPath, "/mnt/sd", sizeof(Param.FSParam.szMountPath) - 1); //only used by FsLinux
|
|
Param.FSParam.szMountPath[sizeof(Param.FSParam.szMountPath) - 1] = '\0';
|
|
Param.FSParam.MaxOpenedFileNum = MAX_OPENED_FILE_NUM;
|
|
if (FST_STA_OK != FileSys_Init(FileSys_GetOPS_uITRON())) {
|
|
printf("FileSys_Init failed\r\n");
|
|
}
|
|
ret = FileSys_OpenEx('A', StrgDXH, &Param);
|
|
if (FST_STA_OK != ret) {
|
|
printf("FileSys_Open err %d\r\n", ret);
|
|
}
|
|
// call the function to wait init finish
|
|
FileSys_WaitFinishEx('A');
|
|
FileSys_SetParamEx('A', FST_PARM_UPDATE_FSINFO , TRUE);
|
|
fastboot_set_done(BOOT_INIT_FILESYSOK);
|
|
printf("filesys_init e\r\n");
|
|
}
|
|
|
|
#if !defined(_EMBMEM_EMMC_)
|
|
static void card_remove_job(void)
|
|
{
|
|
FileSys_WaitFinishEx('A');
|
|
FileSys_CloseEx('A', FST_TIME_INFINITE);
|
|
}
|
|
#endif
|
|
|
|
static void sys_detect_card_task(void)
|
|
{
|
|
#if defined(_EMBMEM_EMMC_)
|
|
THREAD_ENTRY();
|
|
|
|
card_insert_job();
|
|
|
|
THREAD_RETURN(0);
|
|
#else
|
|
UINT32 old_detect;
|
|
UINT32 card_det_tsk_run = 1;
|
|
|
|
THREAD_ENTRY();
|
|
|
|
// force 1st time card detect
|
|
old_detect = !GPIO_CARD_INSERT_LEVEL;
|
|
|
|
//coverity[no_escape]
|
|
while (card_det_tsk_run) {
|
|
UINT32 curr_detect;
|
|
|
|
curr_detect= gpio_getPin(GPIO_CARD_DETECT);
|
|
if (old_detect != curr_detect) {
|
|
if (curr_detect == GPIO_CARD_INSERT_LEVEL) {
|
|
printf("%s: Card Insert\r\n", __func__);
|
|
card_insert_job();
|
|
card_det_tsk_run = 0;
|
|
} else {
|
|
printf("%s: Card Remove\r\n", __func__);
|
|
card_remove_job();
|
|
}
|
|
}
|
|
|
|
old_detect = curr_detect;
|
|
|
|
vTaskDelay(pdMS_TO_TICKS(1000));
|
|
}
|
|
|
|
THREAD_RETURN(0);
|
|
#endif
|
|
}
|
|
#endif
|
|
|
|
void filesys_init(void)
|
|
{
|
|
#if 0
|
|
UINT32 uiPoolAddr;
|
|
int ret;
|
|
|
|
FILE_TSK_INIT_PARAM Param = {0};
|
|
FS_HANDLE StrgDXH;
|
|
|
|
printf("filesys_init b\r\n");
|
|
memset(&Param, 0, sizeof(FILE_TSK_INIT_PARAM));
|
|
StrgDXH = (FS_HANDLE)sdio_getStorageObject(STRG_OBJ_FAT1);
|
|
|
|
uiPoolAddr = mempool_filesys;
|
|
Param.FSParam.WorkBuf = uiPoolAddr;
|
|
Param.FSParam.WorkBufSize = (POOL_SIZE_FILESYS);
|
|
// support exFAT
|
|
Param.FSParam.bSupportExFAT = TRUE;
|
|
//Param.pDiskErrCB = (FileSys_CB)Card_InitCB;
|
|
strncpy(Param.FSParam.szMountPath, "/mnt/sd", sizeof(Param.FSParam.szMountPath) - 1); //only used by FsLinux
|
|
Param.FSParam.szMountPath[sizeof(Param.FSParam.szMountPath) - 1] = '\0';
|
|
#endif
|
|
|
|
FileSys_InstallID(FileSys_GetOPS_uITRON());
|
|
|
|
#if (HUNTING_CAMERA_MODEL == ENABLE)
|
|
if(DrvGPIO_GetHuntingWorkMode() != HUNTING_NORMAL_MODE){
|
|
task_hdl = vos_task_create(sys_detect_card_task, 0, "SysDetectCard", 12, 4096);
|
|
vos_task_resume(task_hdl);
|
|
}
|
|
#endif
|
|
|
|
#if 0
|
|
if (FST_STA_OK != FileSys_Init(FileSys_GetOPS_uITRON())) {
|
|
printf("FileSys_Init failed\r\n");
|
|
}
|
|
ret = FileSys_OpenEx('A', StrgDXH, &Param);
|
|
if (FST_STA_OK != ret) {
|
|
printf("FileSys_Open err %d\r\n", ret);
|
|
}
|
|
// call the function to wait init finish
|
|
FileSys_WaitFinishEx('A');
|
|
printf("filesys_init e\r\n");
|
|
#endif
|
|
FileDB_InstallID();
|
|
}
|