2023-07-20 10:17:11 +08:00
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
#include "freertos/task.h"
|
|
|
|
#include "freertos/queue.h"
|
|
|
|
#include "freertos/semphr.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2024-02-19 09:58:15 +08:00
|
|
|
uint32_t TickDiff(uint32_t comptime)
|
2023-07-20 10:17:11 +08:00
|
|
|
{
|
2024-02-19 09:58:15 +08:00
|
|
|
uint32_t nowtime = xTaskGetTickCount();
|
2023-07-20 10:17:11 +08:00
|
|
|
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;
|
|
|
|
}
|
2024-03-30 18:47:02 +08:00
|
|
|
|
|
|
|
int abs_sub_uint32(uint32_t a, uint32_t b)
|
|
|
|
{
|
|
|
|
if (a >= b)
|
|
|
|
{
|
|
|
|
return a - b;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return (0xffffffff - b + a + 1);
|
|
|
|
}
|
|
|
|
}
|