You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
incubator_embeded/USER/main.c

53 lines
1.3 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "myfreertos.h"
extern u16 tem,hum,red,blue,white;
extern u8 now_stage;
extern u8 hour,min;
int main(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); //FreeRTOS推荐使用 中断优先级分组4
SysTick_Init(72);
USART2_Init(2400);
PID_Init();
printf("复位\r\n");
TimePwm_init(400-1,360-1);// 72M/400/360=500HZ
RS485_1_Init(4800);
HC595_Pin_Init();
RTC_Init(); //需要放在HC595_Pin_Init()后面
TIM3_Init();
delay_ms(20000);
//Write_Init(); //把数据写入W25Q128
Read_Init();
Array(&now_stage,&hour,&min,&tem,&hum,&red,&blue,&white);
Write_Init(); //把数据写入W25Q128
PWM1_Init(500-1,720-1);
PWM2_Init(500-1,720-1);
PWM3_Init(500-1,720-1);
TIM4_Init(10000-1,7200-1);//100ms计数溢出更新中断200*7200/72M=0.02s=20ms
//iwdg_my_Init(5,16000); //不喂狗12s复位
//RX_BUF_Init();
HC595_Send_Byte(0x02);//默认打开压缩机
TIM_SetCompare4(TIM4,200);
delay_xms(10000);//压缩机启动时10秒内以一半的功率工作
//红白蓝对应J10 J11 J12
PWM_SetCompare1(0);//J10
PWM_SetCompare2(0);//J12
PWM_SetCompare4(0);//J11
delay_ms(500);
PWM_SetCompare1(30);//J10
PWM_SetCompare2(30);//J12
PWM_SetCompare4(30);//J11
//init_Net();//网络初始化
//printf("init_Net OK");
//while(!do_dns((u8 *)"hp8oQhMZJ67.iot-as-mqtt.cn-shanghai.aliyuncs.com"));//网域名称
os_init();
while(1)
{
// printf("enter while\r\n");
// delay_ms(1000);
}
}