#include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/queue.h" #include "freertos/semphr.h" #include "utils.h" #include #include int GetCompileDateTime(uint16_t *DateTime) { const int MONTH_PER_YEAR=13; static char szEnglishMonth[][4] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"}; char szTmpDate[40]= {0}; char szTmpTime[20]= {0}; char szMonth[4]= {0}; int iYear,iMonth,iDay,iHour,iMin,iSec;//,, int i; //获取编译日期、时间 sprintf(szTmpDate,"%s",__DATE__); //"Sep 18 2010" sprintf(szTmpTime,"%s",__TIME__); //"10:59:19" sscanf(szTmpDate,"%s %d %d",szMonth,&iDay,&iYear); sscanf(szTmpTime,"%d:%d:%d",&iHour,&iMin,&iSec); for(i=0; MONTH_PER_YEAR; i++) { if(strncmp(szMonth,szEnglishMonth[i],3)==0) { iMonth=i+1; break; } } //printf("%d,%d,%d,%d,%d,%d\n",iYear,iMonth,iDay,iHour,iMin,iSec); //sprintf(szDateTime,"%04d-%02d-%02d %02d:%02d:%02d",iYear,iMonth,iDay,iHour,iMin,iSec); DateTime[0] = iYear; DateTime[1] = iMonth*100; DateTime[1] += iDay; DateTime[2] = iHour*100; DateTime[2] += iMin; return 0; } unsigned int TickDiff(unsigned int comptime) { unsigned int nowtime = xTaskGetTickCount(); if(nowtime >= comptime) return (nowtime - comptime); else return (0 - (comptime - nowtime)); } int scale(int raw, int raw_min, int raw_max,int eng_min, int eng_max) { int result = 0; if(raw_max != raw_min) { result = (raw - raw_min) * (eng_max - eng_min) / (raw_max - raw_min) + eng_min; } return result; }