646 lines
13 KiB
C
646 lines
13 KiB
C
#include "sys_api.h"
|
||
#include "rtthread.h"
|
||
#include "rthw.h"
|
||
#include "string.h"
|
||
#include "math.h"
|
||
#include "stdio.h"
|
||
#include "ctype.h"
|
||
#include "tools.h"
|
||
#include "mywin_inc.h"
|
||
#include "char_encode.h"
|
||
#include "crc8_16.h"
|
||
#include "flash_manager.h"
|
||
#include "system_file.h"
|
||
#include "system_updata.h"
|
||
#include "date.h"
|
||
#include "elf.h"
|
||
#include "mp3play.h"
|
||
|
||
#include "bsp_init.h"
|
||
|
||
|
||
|
||
|
||
// index=333
|
||
|
||
|
||
|
||
#define API_TABLE_PTR (*((void ***)0x20000008))
|
||
|
||
|
||
typedef struct{
|
||
int api_num;
|
||
void **fun_table;
|
||
}api_table_struct;
|
||
|
||
// api函数表,这个表在初始化向量中引用
|
||
api_table_struct g_api_table;
|
||
|
||
static int api_table_init(void)
|
||
{
|
||
extern const unsigned int sys_api_start;
|
||
extern const unsigned int sys_api_end;
|
||
|
||
api_item_struct *start=(api_item_struct *)&sys_api_start;
|
||
api_item_struct *end=(api_item_struct *)&sys_api_end;
|
||
|
||
if(g_api_table.fun_table==0)
|
||
{
|
||
g_api_table.api_num=end-start;
|
||
g_api_table.api_num+=10;
|
||
g_api_table.fun_table=malloc(sizeof(void *)*g_api_table.api_num);
|
||
// memset(g_api_table.fun_table,0x55,sizeof(void *)*g_api_table.api_num);
|
||
|
||
for(;start<end;start++)
|
||
{
|
||
if(start->index<g_api_table.api_num-1)
|
||
{
|
||
g_api_table.fun_table[start->index]=start->fun;
|
||
}
|
||
else
|
||
{
|
||
printf("%s:fun init err item->index=%d\r\n",__func__,start->index);
|
||
}
|
||
}
|
||
}
|
||
|
||
API_TABLE_PTR=g_api_table.fun_table;
|
||
|
||
return 0;
|
||
}
|
||
|
||
extern_init(sys_api,api_table_init);
|
||
|
||
|
||
// 所有可能用到的api都在这里调一遍,防止被优化掉
|
||
|
||
|
||
|
||
|
||
|
||
// 操作系统内核相关api
|
||
api_item(rt_hw_interrupt_disable,1);
|
||
api_item(rt_hw_interrupt_enable,2);
|
||
api_item(rt_enter_critical,3);
|
||
api_item(rt_exit_critical,4);
|
||
api_item(rt_thread_mdelay,5);
|
||
api_item(rt_thread_create,6);
|
||
api_item(rt_thread_startup,7);
|
||
api_item(rt_thread_delete,8);
|
||
|
||
api_item(rt_timer_create,9);
|
||
api_item(rt_timer_delete,10);
|
||
api_item(rt_timer_start,11);
|
||
api_item(rt_timer_stop,12);
|
||
|
||
api_item(rt_sem_create,13);
|
||
api_item(rt_sem_delete,14);
|
||
api_item(rt_sem_take,15);
|
||
api_item(rt_sem_release,16);
|
||
|
||
api_item(rt_mutex_create,17);
|
||
api_item(rt_mutex_delete,18);
|
||
api_item(rt_mutex_take,19);
|
||
api_item(rt_mutex_release,20);
|
||
|
||
api_item(rt_event_create,21);
|
||
api_item(rt_event_delete,22);
|
||
api_item(rt_event_send,23);
|
||
api_item(rt_event_recv,24);
|
||
|
||
api_item(rt_mb_create,25);
|
||
api_item(rt_mb_delete,26);
|
||
api_item(rt_mb_send,27);
|
||
api_item(rt_mb_send_wait,28);
|
||
api_item(rt_mb_recv,29);
|
||
|
||
api_item(rt_mq_create,30);
|
||
api_item(rt_mq_delete,31);
|
||
api_item(rt_mq_send,32);
|
||
api_item(rt_mq_urgent,33);
|
||
api_item(rt_mq_recv,34);
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// c语言库相关api
|
||
api_item(fputc,35);
|
||
api_item(rand,36);
|
||
api_item(calloc,37);
|
||
api_item(free,38);
|
||
api_item(malloc,39);
|
||
api_item(realloc,40);
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// 工具模块相关api
|
||
api_item(tools_updata_on,41);
|
||
api_item(tools_updata_off,42);
|
||
|
||
|
||
|
||
|
||
|
||
// 设置模块相关api
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// soft相关api
|
||
api_item(uni2utf8_str,43);
|
||
api_item(utf82uni_str,44);
|
||
api_item(gbk2uni_str,45);
|
||
api_item(uni2gbk_str,46);
|
||
api_item(gbk2utf8_str,47);
|
||
api_item(utf82gbk_str,48);
|
||
|
||
api_item(FLASH_ReadData,49);
|
||
api_item(FLASH_WriteData,50);
|
||
api_item(FLASH_EraseOneSector,51);
|
||
api_item(FLASH_EraseAllSector,52);
|
||
api_item(FLASH_GetFlashSize,53);
|
||
api_item(FLASH_CheckErase,54);
|
||
api_item(FLASH_LoopWrite,55);
|
||
api_item(FLASH_AddFile,56);
|
||
api_item(FLASH_ReadFile,57);
|
||
api_item(FLASH_FindFile,58);
|
||
api_item(FLASH_GetUsed,59);
|
||
api_item(FLASH_GetFileNum,60);
|
||
api_item(FLASH_GetFileInfo,61);
|
||
api_item(FLASH_DeleteFile,62);
|
||
api_item(FLASH_SaveFile,63);
|
||
|
||
api_item(SysFile_GetFileByName,64);
|
||
api_item(SysFile_Updata,65);
|
||
api_item(SysFile_UpdataByIrq,66);
|
||
|
||
api_item(date_is_leap_year,67);
|
||
api_item(date_get_month_day_max,68);
|
||
api_item(date_get_week_by_day,69);
|
||
api_item(date_get_year_max,70);
|
||
api_item(date_get_year_min,71);
|
||
api_item(date_get_next_day,72);
|
||
api_item(date_get_last_day,73);
|
||
api_item(date_get_next_n_day,74);
|
||
api_item(date_get_last_n_day,75);
|
||
api_item(date_rtc_get_date,76);
|
||
api_item(date_rtc_get_time,77);
|
||
api_item(date_rtc_set_date,78);
|
||
api_item(date_rtc_set_time,79);
|
||
|
||
api_item(app_run_path,80);
|
||
api_item(app_run,81);
|
||
api_item(appm_find,82);
|
||
api_item(appm_get,83);
|
||
api_item(appm_get_running_num,84);
|
||
api_item(app_exit,85);
|
||
api_item(app_get_name_from_file,86);
|
||
|
||
api_item(mp3_get_support,87);
|
||
api_item(mp3_get_support_name,88);
|
||
api_item(mp3_play_song,89);
|
||
api_item(mp3_get_name,90);
|
||
api_item(mp3_get_artist,91);
|
||
api_item(mp3_get_time,92);
|
||
api_item(mp3_stop,93);
|
||
api_item(mp3_play,94);
|
||
api_item(mp3_suspend,95);
|
||
api_item(mp3_set_vol,96);
|
||
api_item(mp3_add_val,97);
|
||
api_item(mp3_sub_val,98);
|
||
api_item(mp3_get_vol,99);
|
||
|
||
|
||
|
||
// GUI相关api
|
||
|
||
|
||
|
||
|
||
/* 以下函数对同一对象只能在同一线程调用 */
|
||
|
||
api_item(QUEUE_Init,100);
|
||
api_item(QUEUE_Delete,101);
|
||
api_item(QUEUE_Out,102);
|
||
api_item(QUEUE_In,103);
|
||
api_item(QUEUE_CheckStart,104);
|
||
api_item(QUEUE_Check,105);
|
||
|
||
/* 以下函数线程安全 */
|
||
|
||
api_item(POS_RoundPix,106);
|
||
api_item(POS_InRect,107);
|
||
api_item(POS_RectIntersection,108);
|
||
api_item(POS_RectContain,109);
|
||
api_item(POS_RectSub,110);
|
||
api_item(POS_RectEqual,111);
|
||
|
||
|
||
|
||
|
||
/* 以下函数只能在ui线程调用 */
|
||
|
||
api_item(WIN_CreatThread,112);
|
||
api_item(WIN_CreatThreadPro,113);
|
||
api_item(WIN_GetExWorkFunStat,114);
|
||
api_item(WIN_ExWorkFunClear,115);
|
||
api_item(WIN_GetWordData,116);
|
||
|
||
/* 以下函数线程安全 */
|
||
|
||
api_item(WIN_DecodeImg,117);
|
||
|
||
|
||
|
||
|
||
/* 以下函数线程安全 */
|
||
|
||
api_item(WIN_PlaceExtData,118);
|
||
api_item(WIN_RunInWindow,119);
|
||
|
||
/* 以下函数只能在ui线程调用 */
|
||
|
||
// WIN_Init,
|
||
api_item(WIN_GetWinStruct,120);
|
||
api_item(WIN_SetRunCallBack,121);
|
||
api_item(WIN_SetBlockWinReturn,122);
|
||
api_item(WIN_GetBlockWinReturn,123);
|
||
//api_item(WIN_GetBlockWinNum,124);
|
||
api_item(WIN_GetExtData,124);
|
||
api_item(WIN_RunMsgFunction,125);
|
||
api_item(WIN_GetBaseWindow,126);
|
||
api_item(WIN_GetCurrentWindow,127);
|
||
api_item(WIN_CreatWindow,128);
|
||
api_item(WIN_CreatWindowExt,129);
|
||
api_item(WIN_DeleteWindow,130);
|
||
api_item(WIN_SetAsTopWin,131);
|
||
api_item(WIN_ResetAsTopWin,132);
|
||
api_item(WIN_GetWindowStructById,133);
|
||
api_item(WIN_DelFromChidList,134);
|
||
api_item(WIN_AddToChidList,135);
|
||
api_item(WIN_CheckChidWin,136);
|
||
api_item(WIN_FindTopWinByPos,137);
|
||
api_item(WIN_FindTopWin,138);
|
||
api_item(WIN_SetChidWinTop,139);
|
||
//api_item(WIN_SetChidWinBottom,140);
|
||
api_item(WIN_GetWinPosOnLcd,140);
|
||
api_item(WIN_FindPrent,141);
|
||
api_item(WIN_SetWinInvalidRect,142);
|
||
api_item(WIN_GetWinInvalidRect,143);
|
||
api_item(WIN_SetWinTitle,144);
|
||
api_item(WIN_GetWinByTitle,145);
|
||
api_item(WIN_FindBlock,146);
|
||
api_item(WIN_SetChildWinkeyShield,147);
|
||
api_item(WIN_PaintBackGround,148);
|
||
api_item(WIN_SetBackPic,149);
|
||
api_item(WIN_SetBackPicPath,150);
|
||
api_item(WIN_SetBackFun,151);
|
||
api_item(WIN_SetColor,152);
|
||
api_item(WIN_SetBkColor,153);
|
||
api_item(WIN_ShowWindow,154);
|
||
|
||
|
||
|
||
|
||
/* 以下函数只能在非ui线程调用 */
|
||
|
||
api_item(WIN_StorTouchStruct,155);
|
||
api_item(WIN_StorKeyStruct,156);
|
||
|
||
/* 以下函数只能在ui线程调用 */
|
||
|
||
api_item(WIN_ClearKeyQueue,157);
|
||
api_item(WIN_ClearTouchQueue,158);
|
||
api_item(WIN_KeyShieldOn,159);
|
||
api_item(WIN_KeyShieldOff,160);
|
||
api_item(WIN_DefaultMsgLoop,161);
|
||
api_item(WIN_SetMsgLoopCallBack,162);
|
||
api_item(WIN_RunBlock,163);
|
||
api_item(WIN_SendMsg,164);
|
||
api_item(WIN_SendMsgToPrent,165);
|
||
api_item(WIN_ClearMsgQueue,166);
|
||
api_item(WIN_CheckMsg,167);
|
||
api_item(WIN_SendTouchMsg,168);
|
||
api_item(WIN_SendTouchMove,169);
|
||
api_item(WIN_SendKeyMsg,170);
|
||
api_item(WIN_TouchMsgBroad,171);
|
||
api_item(WIN_SetInvalid,172);
|
||
api_item(WIN_SetInvalidWhenTop,173);
|
||
api_item(WIN_SetInvalidRect,174);
|
||
api_item(WIN_SetInvalidRectWhenTop,175);
|
||
api_item(WIN_Move,176);
|
||
api_item(WIN_SetPos,177);
|
||
api_item(WIN_SetSize,178);
|
||
|
||
|
||
|
||
|
||
/* 以下函数只能在ui线程调用 */
|
||
|
||
api_item(WIN_CreatTimer,179);
|
||
api_item(WIN_TimerReload,180);
|
||
api_item(WIN_SetTimerCycle,181);
|
||
api_item(WIN_DeleteTimer,182);
|
||
api_item(WIN_WinDeleteTimer,183);
|
||
// WIN_TimerWork,
|
||
|
||
|
||
|
||
|
||
/* 以下函数对同一对象只能在同一线程调用 */
|
||
|
||
api_item(WIN_CreatVirtualLcd,184);
|
||
api_item(WIN_DeleteVirtualLcd,185);
|
||
api_item(WIN_LcdSetScreenDis,186);
|
||
api_item(WIN_LcdSetWindow,187);
|
||
api_item(WIN_LcdGetWindowSizeX,188);
|
||
api_item(WIN_LcdGetWindowSizeY,189);
|
||
api_item(WIN_LcdSetLcdColor,190);
|
||
api_item(WIN_LcdSetLcdBkColor,191);
|
||
api_item(WIN_LcdSetLcdColor16,192);
|
||
api_item(WIN_LcdSetLcdBkColor16,193);
|
||
api_item(WIN_LcdGetLcdColor,194);
|
||
api_item(WIN_LcdGetLcdBkColor,195);
|
||
api_item(WIN_LcdGetLcdColor16,196);
|
||
api_item(WIN_LcdGetLcdBkColor16,197);
|
||
api_item(WIN_LcdSetLcdDrawMode,198);
|
||
api_item(WIN_LcdFillRectOff16At,199);
|
||
api_item(WIN_LcdDrawPointSafe,200);
|
||
api_item(WIN_LcdDrawPointSafeColor,201);
|
||
api_item(WIN_LcdDrawPointSafeColorAlpha,202);
|
||
api_item(WIN_LcdFillRectByColor,203);
|
||
api_item(WIN_LcdFillRectByColorAlpha,204);
|
||
api_item(WIN_LcdDrawImag,205);
|
||
api_item(WIN_LcdDrawImagButColor,206);
|
||
api_item(WIN_LcdDrawImagByColor,207);
|
||
api_item(WIN_LcdDrawImagByAlpha,208);
|
||
api_item(WIN_LcdClear,209);
|
||
api_item(WIN_LcdClearRect,210);
|
||
api_item(WIN_LcdGetColors,211);
|
||
|
||
|
||
|
||
|
||
/* 以下函数只能在ui线程调用 */
|
||
|
||
api_item(WIN_SetFontSize,212);
|
||
api_item(WIN_SetFontType,213);
|
||
api_item(WIN_GetFontHight,214);
|
||
api_item(WIN_GetFontWidth,215);
|
||
api_item(WIN_SetFontMode,216);
|
||
|
||
|
||
|
||
|
||
/* 以下函数只能在ui线程调用 */
|
||
|
||
api_item(WIN_DrawPointSafe,217);
|
||
api_item(WIN_DrawPointNormal,218);
|
||
api_item(WIN_DrawPointColorSafe,219);
|
||
api_item(WIN_DrawPointColorNormal,220);
|
||
api_item(WIN_DrawPointSafeColorAlpha,221);
|
||
api_item(WIN_SetLcdColor,222);
|
||
api_item(WIN_SetLcdBkColor,223);
|
||
api_item(WIN_GetLcdColor16,224);
|
||
api_item(WIN_DrawTxtAt,225);
|
||
api_item(WIN_DrawTxtAtRect,226);
|
||
api_item(WIN_DrawTxtCenterAtRect,227);
|
||
api_item(WIN_DrawTxtHCenterAt,228);
|
||
api_item(WIN_DrawHLine,229);
|
||
api_item(WIN_DrawHLineAlpha,230);
|
||
api_item(WIN_DrawVLine,231);
|
||
api_item(WIN_DrawLine,232);
|
||
api_item(WIN_DrawLines,233);
|
||
api_item(WIN_DrawCircle,234);
|
||
api_item(WIN_DrawRect,235);
|
||
api_item(WIN_DrawPolygon,236);
|
||
api_item(WIN_FillRectByColor,237);
|
||
api_item(WIN_FillRectByColorAlpha,238);
|
||
api_item(WIN_FillTriangle,239);
|
||
api_item(WIN_FillPolygon,240);
|
||
api_item(WIN_CreatPlaneAA,241);
|
||
api_item(WIN_DeletePlaneAA,242);
|
||
api_item(WIN_DrawPointAA,243);
|
||
api_item(WIN_DrawPlaneAA,244);
|
||
api_item(WIN_DrawLineAA,245);
|
||
api_item(WIN_FillRect,246);
|
||
api_item(WIN_FillRectAlpha,247);
|
||
api_item(WIN_DrawImag,248);
|
||
api_item(WIN_DrawImagButColor,249);
|
||
api_item(WIN_DrawImagByColor,250);
|
||
api_item(WIN_DrawImagByAlpha,251);
|
||
api_item(WIN_DrawImagByAlphaAnti,252);
|
||
api_item(WIN_Clear,253);
|
||
api_item(WIN_GetTxtRectSize,254);
|
||
api_item(WIN_GetImageSize,255);
|
||
|
||
|
||
|
||
|
||
/* 以下函数只能在ui线程调用 */
|
||
|
||
api_item(WIN_GetPic,256);
|
||
api_item(WIN_GetPicNoAlpha,257);
|
||
api_item(WIN_PicInsidePic,258);
|
||
api_item(WIN_GetPicLive,259);
|
||
api_item(WIN_DrawPic,260);
|
||
|
||
|
||
|
||
|
||
/* 以下函数只能在ui线程调用 */
|
||
|
||
api_item(MSGBOX_SetTitle,261);
|
||
api_item(MSGBOX_SetMsg,262);
|
||
api_item(MSGBOX_SetKey,263);
|
||
api_item(MSGBOX_SetKey2,264);
|
||
api_item(MSGBOX_AddItem,265);
|
||
api_item(MSGBOX_Tips,266);
|
||
api_item(MSGBOX_TipsTime,267);
|
||
api_item(MSGBOX_Inquiry,268);
|
||
api_item(MSGBOX_Select,269);
|
||
|
||
|
||
|
||
|
||
/* 以下函数只能在ui线程调用 */
|
||
|
||
api_item(WIN_CreatButton,270);
|
||
api_item(BUTTON_SetKeyString,271);
|
||
|
||
|
||
|
||
|
||
/* 以下函数只能在ui线程调用 */
|
||
|
||
api_item(WIN_CreatInput,272);
|
||
api_item(INPUT_KeyBoard,273);
|
||
|
||
|
||
|
||
|
||
/* 以下函数只能在ui线程调用 */
|
||
|
||
api_item(WIN_CreatList,274);
|
||
api_item(LIST_SetItem,275);
|
||
api_item(LIST_SetItemHeight,276);
|
||
api_item(LIST_SetYOrigin,277);
|
||
api_item(LIST_SetYMove,278);
|
||
|
||
|
||
|
||
|
||
/* 以下函数只能在ui线程调用 */
|
||
|
||
api_item(WIN_CreatPage,279);
|
||
api_item(PAGE_SetBackPic,280);
|
||
api_item(PAGE_SetItem,281);
|
||
api_item(PAGE_SetTitleHeight,282);
|
||
api_item(PAGE_SetItemHeight,283);
|
||
api_item(PAGE_SetItemIndent,284);
|
||
api_item(PAGE_IndexAdd,285);
|
||
api_item(PAGE_IndexSub,286);
|
||
|
||
|
||
|
||
|
||
/* 以下函数只能在ui线程调用 */
|
||
|
||
api_item(POPUP_SelectItem,287);
|
||
api_item(POPUP_AddItem,288);
|
||
|
||
|
||
|
||
|
||
/* 以下函数只能在ui线程调用 */
|
||
|
||
api_item(WORKING_DoWork,289);
|
||
|
||
|
||
|
||
|
||
/* 以下函数只能在ui线程调用 */
|
||
|
||
api_item(SCROLLBAR_SelectItem,290);
|
||
api_item(SCROLLBAR_SelectNum,291);
|
||
api_item(SCROLLBAR_AddItem,292);
|
||
|
||
|
||
|
||
|
||
/* 以下函数只能在ui线程调用 */
|
||
|
||
api_item(INPUTBOX_InputChars,293);
|
||
api_item(INPUTBOX_Clear,294);
|
||
api_item(INPUTBOX_SetChars,295);
|
||
|
||
|
||
|
||
|
||
/* 以下函数只能在ui线程调用 */
|
||
|
||
api_item(RECORD_DrawRecord,296);
|
||
api_item(RECORD_AddMsg,297);
|
||
|
||
|
||
|
||
|
||
/* 以下函数只能在ui线程调用 */
|
||
|
||
api_item(WIN_CreatTouch,298);
|
||
api_item(WIN_CreatTouchEx,299);
|
||
api_item(WIN_CreatTouchChild,300);
|
||
api_item(WIN_CreatTouchBase,301);
|
||
api_item(TOUCHWIN_AddChild,302);
|
||
api_item(TOUCHWIN_ClearChild,303);
|
||
api_item(TOUCHWIN_SetOutCon,304);
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// 一些补充函数
|
||
api_item(myfree,305);
|
||
api_item(mymalloc,306);
|
||
api_item(myrealloc,307);
|
||
api_item(mycalloc,308);
|
||
api_item(mymalloc_fast,309);
|
||
//api_item(mymalloc_ex,310);
|
||
//api_item(myfree_ccm,311);
|
||
//api_item(mymalloc_ccm,312);
|
||
api_item(mymemset ,310);
|
||
api_item(mymemcpy,311);
|
||
api_item(mem_perused,312);
|
||
api_item(exmem_perused,313);
|
||
//api_item(ccm_perused,314);
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// FATFS文件系统
|
||
api_item(f_open,314);
|
||
api_item(f_close,315);
|
||
api_item(f_read,316);
|
||
api_item(f_write,317);
|
||
api_item(f_lseek,318);
|
||
api_item(f_truncate,319);
|
||
api_item(f_sync,320);
|
||
api_item(f_opendir,321);
|
||
api_item(f_closedir,322);
|
||
api_item(f_readdir,323);
|
||
api_item(f_findfirst,324);
|
||
api_item(f_findnext,325);
|
||
api_item(f_mkdir,326);
|
||
api_item(f_unlink,327);
|
||
api_item(f_rename,328);
|
||
api_item(f_stat,329);
|
||
api_item(f_getfree,330);
|
||
api_item(f_mount,331);
|
||
api_item(f_mkfs,332);
|
||
//api_item(f_chmod,333);
|
||
//api_item(f_utime,334);
|
||
//api_item(f_chdir,335);
|
||
//api_item(f_chdrive,336);
|
||
//api_item(f_getcwd,337);
|
||
//api_item(f_getlabel,338);
|
||
//api_item(f_setlabel,339);
|
||
//api_item(f_forward,340);
|
||
//api_item(f_expand,341);
|
||
//api_item(f_fdisk,342);
|
||
//api_item(f_setcp,343);
|
||
//api_item(f_putc,344);
|
||
//api_item(f_puts,345);
|
||
//api_item(f_printf,346);
|
||
//api_item(f_gets,347);
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|