Date FreeRTOS获取当前时间
我有运行FreeRTOS的代码,我想编辑它, 这是一个测量压力和温度的代码,我想知道这些测量的时间 有人能告诉我如何获取我机器中的当前时间或日期吗 多谢各位 这是我现在正在使用的代码Date FreeRTOS获取当前时间,date,freertos,Date,Freertos,我有运行FreeRTOS的代码,我想编辑它, 这是一个测量压力和温度的代码,我想知道这些测量的时间 有人能告诉我如何获取我机器中的当前时间或日期吗 多谢各位 这是我现在正在使用的代码 //#include <stdio.h> //#include <stdlib.h> #include <stdint.h> #include <math.h> #include "platform.h" #include "printf.h" #include "l
//#include <stdio.h>
//#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#include "platform.h"
#include "printf.h"
#include "lps331ap.h"
static void app_task(void *);
int main(int argc, char *argv[])
{
// Initialize the platform
platform_init();
// Create a task for the application
xTaskCreate(app_task, (const signed char * const) "lps331", configMINIMAL_STACK_SIZE, NULL, 1, NULL);
// Run
platform_run();
return 0;
}
static void app_task(void *param)
{
uint32_t pres;
int16_t temp;
int count=0;
// FILE* fichier = NULL;
printf("# Testing LPS331AP\n");
printf("# Initializing LPS331AP...\n");
lps331ap_powerdown();
printf("# Setting LPS331AP pressure sensor\n");
lps331ap_set_datarate(LPS331AP_P_12_5HZ_T_12_5HZ);
while (1)
{
lps331ap_read_pres(&pres);
lps331ap_read_temp(&temp);
//fichier = fopen("test.txt", "w");
//fprintf(fichier,"%f", pres / 4096.0);
//fprintf(fichier,"%f", 42.5 + temp / 480.0 );
printf("%d\t",count);
printf("%f\t", 42.5 + temp / 480.0);
printf("%f\n", pres / 4096.0);
count=count+1;
//fclose(fichier);
//vTaskDelay(configTICK_RATE_HZ / 10);
vTaskDelay(2000);
//vTaskDelay(600000);
}
}
/#包括
//#包括
#包括
#包括
#包括“platform.h”
#包括“printf.h”
#包括“lps331ap.h”
静态void应用程序任务(void*);
int main(int argc,char*argv[])
{
//初始化平台
平台初始化();
//为应用程序创建任务
xTaskCreate(app_任务,(const signed char*const)“lps331”,配置最小_堆栈大小,NULL,1,NULL);
//跑
平台运行();
返回0;
}
静态void应用程序任务(void*param)
{
uint32_t pres;
内部温度;
整数计数=0;
//FILE*fichier=NULL;
printf(“测试LPS331AP\n”);
printf(“初始化LPS331AP…\n”);
lps331ap_断电();
printf(“设置LPS331AP压力传感器\n”);
lps331ap_设置_数据速率(lps331ap_P_12_5HZ_T_12_5HZ);
而(1)
{
lps331ap\u读取压力(&pres);
lps331ap_读取_温度(&temp);
//fichier=fopen(“test.txt”,“w”);
//fprintf(fichier,“%f”,pres/4096.0);
//fprintf(菲希尔,“%f”,42.5+温度/480.0);
printf(“%d\t”,计数);
printf(“%f\t”,42.5+温度/480.0);
printf(“%f\n”,pres/4096.0);
计数=计数+1;
//fclose(fichier);
//vTaskDelay(配置滴答频率为HZ/10);
vTaskDelay(2000年);
//vTaskDelay(600000);
}
}
对于测量时间,有两种方法,但这仅限于您的滴答声频率的分辨率
或者,您可以创建另一个频率为1 Hz的任务以增加计数器,并将其用作系统时间
然而,为了得到一个实际的日期,你需要咨询你的开发委员会,看看它是否有RTC。否则,您需要以某种方式手动获取时间,并使用开发板的硬件计时器维护此计数
在你的开发板上肯定有一些硬件时钟,你也可以用来测量时间