小学生
最后登录1970-1-1
在线时间 小时
注册时间2024-11-11
|
#include "stm32f10x.h"
#include "FreeRTOS.h"
#include "task.h"
#include "usart.h"
#include "stdio.h"
#include "lcd_driver.h"
#include "time.h"
#include "picture.h"
#include "GUI.h"
#include "iic_dht20.h"
#define configLCD_STACK_SIZE ( ( unsigned short ) 4*1024 )
TaskHandle_t app_task1_handle = NULL;
TaskHandle_t app_task2_handle = NULL;
TaskHandle_t app_task3_handle = NULL;
void LED(void* pvParamenters);
void App_Task2(void* pvParamenters);
void App_Task3(void* pvParamenters);
void LED_Init();
int main(void)
{
usart_init(1);
SystemInit(); //System init.
delay_init(72);
LED_Init();
lcd_Init();
IIC_Init();
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
BaseType_t lcd_return;
BaseType_t led_return;
led_return = xTaskCreate((TaskFunction_t)LED, //??????
(const char *)"LED", //????
(uint16_t)configMINIMAL_STACK_SIZE, //?????
(void*)NULL, //????????
(UBaseType_t)1, //?????
(TaskHandle_t*)&app_task1_handle); //????
lcd_return = xTaskCreate((TaskFunction_t)App_Task2, //??????
(const char *)"App_Task2", //????
(uint16_t)(configMINIMAL_STACK_SIZE), //?????
(void*)NULL, //????????
(UBaseType_t)1, //?????
(TaskHandle_t*)&app_task2_handle); //????
xTaskCreate((TaskFunction_t)App_Task3, //??????
(const char *)"App_Task3", //????
(uint16_t)configMINIMAL_STACK_SIZE, //?????
(void*)NULL, //????????
(UBaseType_t)0, //?????
(TaskHandle_t*)&app_task3_handle); //????
printf("lcd return %d led return %d\n",lcd_return,led_return);
vTaskStartScheduler();
}
void LED_Init()
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);//??C????
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //????
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //??50Mhz
GPIO_Init(GPIOC,&GPIO_InitStructure); //???GPIOC
}
void LED(void *pvParameters)
{
for(;;)
{
GPIO_WriteBit(GPIOC,GPIO_Pin_13,Bit_RESET);
printf("����\n");
vTaskDelay(500);
printf("task1\n");
GPIO_WriteBit(GPIOC,GPIO_Pin_13,Bit_SET);
printf("Ϩ��\n");
vTaskDelay(500);
}
}
void App_Task2(void *pvParameters)
{
float temp =0;
float hump =0;
char lcd_buffer[15]="";
for(;;)
{
lcd_clear_limit(0,40,127,70,RED);
lcd_clear_limit(0,60,127,80,RED);
read_SHT30(&temp,&hump);
printf("�¶�: %.2f ʪ�ȣ�%.2f\n",temp,hump);
sprintf(lcd_buffer,"temp:%.2f",temp);
lcd_show_string(5,40,BLUE,RED,lcd_buffer);
memset(lcd_buffer,0,15);
sprintf(lcd_buffer,"hump:%.2f",hump);
lcd_show_string(5,60,BLUE,RED,lcd_buffer);
vTaskDelay(1000);
printf("task2\n");
}
}
void App_Task3(void *pvParameters)
{
for(;;)
{
}
}
|
|