#include "includes.h" void appimg_exit(void){ OSI_LOGI(0,"application image exit"); } static void mainTask(void *param); ////////////////////////test start/////////////////////////// void logDataCb2(const char *data,uint32 length){MSG_INFO(1, "USB get:%d");} bool logPortInit1(void){ bool ret=nwy_usb_serial_reg_recv_cb(logDataCb2); if(false==ret) OSI_LOGI(0,"nwy_usb_serial_reg_recv_cb failed"); else{ usb_log_status=true; MSG_INFO(1,"logPortInit ok"); } return ret; } static void gpioIsqActiveCb(int param){MSG_INFO(1, "GPIO_ISR:GPIO=%d,LEVEL=%d", param,nwy_gpio_get_value(param));}//打印中断管脚号及其当前电平值 void testInit(void){ //配置IO,运行即自行锁住电源 nwy_gpio_set_direction(G_POWER_HOLD,nwy_output);//设置为输出 nwy_gpio_pullup_or_pulldown(G_POWER_HOLD,1);//up nwy_gpio_set_value(G_POWER_HOLD,nwy_high);//HIGH //配置PIN79为ISR,上下延 gpioInputInit(G_KEY_MIC_PTT,1,2); nwy_close_gpio(G_KEY_MIC_PTT);nwy_sleep(10000); if(nwy_open_gpio_irq_config(G_KEY_MIC_PTT,2,gpioIsqActiveCb)){//ISR 上下延 nwy_gpio_open_irq_enable(G_KEY_MIC_PTT);MSG_INFO(1, "IRQ CONFIG OK"); }else MSG_INFO(1, "IRQ CONFIG FAILED"); nwy_gpio_pullup_or_pulldown(G_KEY_MIC_PTT,2);//no pull } void testInfo(void){MSG_INFO(1, "QueryLevel:GPIO=%d,Level:%d",G_KEY_MIC_PTT,nwy_gpio_get_value(G_KEY_MIC_PTT));}//定时读取管脚电平 static void testTask(void *param){ logPortInit1();testInit(); for(;;){ nwy_sleep(1000); testInfo(); } } //////////////////////////test end//////////////////////////////// /*appimg_enter cat one入口函数*/ int appimg_enter(void *param){ #ifdef DEBUG_ON nwy_sleep(10000); #endif nwy_set_sim_detect_mode(false); mainThreadPtr=nwy_create_thread("main", mainTask, NULL, NWY_OSI_PRIORITY_NORMAL, MAIN_TASK_THREAD_STACK, 5); if(NULL==mainThreadPtr){ for(;;){ OSI_LOGI(0,"main task failed"); nwy_sleep(1000); } } if(NULL==nwy_create_thread("sub", subTask, NULL, NWY_OSI_PRIORITY_NORMAL, SUB_TASK_THREAD_STACK, 10)){ for(;;){ OSI_LOGI(0,"sub task failed"); nwy_sleep(1000); } } return 0; } /////////////////////////////////////////////////////////// void ohpocRecvGet(unsigned char *msg, int len){ pocCmdHandler(msg,len); } static void ohpocStart(void){ if(false==ohpocInit(ohpocRecvGet, OHPOC_VERSION, OHPOC_MODLE, OHPOC_CUST)) OSI_LOGI(0,"ohpocInit failed"); MSG_INFO(1,"ohpocInit Ok"); } #include "nwy_audio_api.h" static int player_cb(nwy_player_status state){ OSI_LOGI(0,"player_cb state:%d", state); if(0==state){//播放完毕了 OSI_LOGI(0,"pcm play finished"); } } void TestPlayer(void){ int i; unsigned char buffer[320]; OSI_LOGI(0, "[XXX]TestPlayer start"); nwy_audio_recorder_close(); OSI_LOGI(0, "[XXX]try rec close done"); if(0!=nwy_audio_player_open(player_cb)){ OSI_LOGI(0, "[xxx]plp open failed"); return; } OSI_LOGI(0, "[XXX]ply open ok"); for(i=0;i<10;i++){ OSI_LOGI(0, "[XXX]ply frame start:%d", i); if(NWY_SUCESS!=nwy_audio_player_play(buffer,320)){ OSI_LOGI(0,"[XXX]ply frame failed:%d",i); break; }else OSI_LOGI(0, "[XXX]ply frame ok:%d",i); } if(0==nwy_audio_player_stop()) OSI_LOGI(0, "[XXX]ply stop ok"); else OSI_LOGI(0, "[XXX]ply stop failed"); OSI_LOGI(0, "[XXX]try player close"); nwy_audio_player_close(); OSI_LOGI(0, "[XXX]player close done"); } static void test_flash_now(void); static void mainTask(void *param){ #if 0 #include "spiFlash.h" #define FLASH_SIZE_BYTES (4*1024*1024) unsigned int i; bool ret; int flag=0; char info[50]; SPIFLASH_INFO spiFlashInfo; boardInit(); nwy_sleep(2000); MSG_INFO(1, "Test Flash start\r\n"); for(i=0;i>%d/%d err=%d ",i+1,FLASH_SIZE_BYTES/SECTOR_SIZE_BYTE,spiFlashInfo.errno); guiShowStr(2, 50,info, FONT_MODE_12X12, REVERSED_NO,guiGetBackColor(),COLOR_STATUS_BAR); break; } snprintf(info, sizeof(info), ">>%d/%d ok",i+1,FLASH_SIZE_BYTES/SECTOR_SIZE_BYTE); guiShowStr(2, 50,info, FONT_MODE_12X12, REVERSED_NO,guiGetBackColor(),COLOR_STATUS_BAR); } MSG_INFO(1, "Test Flash end\r\n"); #endif #if 0 dataInit(); boardInit(); ohpocStart(); uioStatusInit(); #endif #if 1 dataInit(); boardInit(); #ifndef ENABLE_ANT_MODE ohpocStart(); #endif uioStatusInit(); appRun(); #endif nwy_exit_thread(); } #include "nwy_file.h" #include "mymd5.h" #define flash_size (4 * 1024) #define flash_addr 0x60320000 #define TEST_SIZE 18912 //#include //const char mytext[] __at (0x60321000)= "ddddd"; void test_flash_now() { #if 0 unsigned char databuf[10]={'0','1','2','3','4','5','6','7','8','9'}; MD5_CTX mdContext; unsigned char *md5; MD5Init(&mdContext); MD5Update(&mdContext,databuf,10); MD5Final(&mdContext); md5=mdContext.digest; OSI_LOGI(0,"md5:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", md5[0],md5[1],md5[2],md5[3], md5[4],md5[5],md5[6],md5[7], md5[8],md5[9],md5[10],md5[11], md5[12],md5[13],md5[14],md5[15]); #else MD5_CTX mdContext; unsigned char *md5; int ret = -1; unsigned char data_str[flash_size] = {0}; nwyspiflash_t *fp = NULL; fp = nwy_flash_open(NAME_FLASH_1); if(fp == NULL) { OSI_LOGI(0,"flash open filed"); return; } OSI_LOGI(0,"flash open ok"); memset(data_str,0,sizeof(data_str)); MD5Init(&mdContext); int fs=TEST_SIZE; int flen; unsigned int offset=flash_addr; while(fs>0){ if(fs>flash_size) flen=flash_size; else flen=fs; ret = nwy_flash_read(fp, offset, data_str, flen); if (ret == false) { OSI_LOGI(0,"nwy_flash_read filed"); return; } OSI_LOGI(0,"nwy_flash_read ok:%d",flen); MD5Update(&mdContext,data_str,flen); offset += flen; fs -= flen; } MD5Final(&mdContext); md5=mdContext.digest; OSI_LOGI(0,"md5:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", md5[0],md5[1],md5[2],md5[3], md5[4],md5[5],md5[6],md5[7], md5[8],md5[9],md5[10],md5[11], md5[12],md5[13],md5[14],md5[15]); #endif return; }