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

59 lines
1.5 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;
extern u8 gpio_state;
// int a_value=20;
// int b_value=20;
// int c_value=20;
int main(void)
{
SysTick_Init(72);
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); // FreeRTOS推荐使用 中断优先级分组4
USART2_Init(2400);
PID_Init();
// printf("复位\r\n");
TimePwm_init(400 - 1, 360 - 1); // 72M/400/360=500HZ
// GPIO_ResetBits(GPIOB,GPIO_Pin_0);
// TIM_SetCompare3(TIM3,0);
// TODO::内含RS485_1_Init(9600) 初始化RS485_1
light_set_all();
// RS485_1_Init(9600);
HC595_Pin_Init();
RTC_Init(); // need to after HC595_Pin_Init()
TIM2_Init();
Read_Init(); // 读flash的值赋值给total数组以及阶段
// Array(&now_stage,&hour,&min,&tem,&hum,&red,&blue,&white);
PWM1_Init(500 - 1, 720 - 1);
PWM2_Init(500 - 1, 720 - 1);
PWM3_Init(500 - 1, 720 - 1);
TIM4_Init(10000 - 1, 7200 - 1); // 1s计数溢出更新中断10000*7200/72M=1s,内含喂狗程序
iwdg_my_Init(5, 16000); // 不喂狗12s复位
RX_BUF_Init();
// GPIO_ResetBits(GPIOB,GPIO_Pin_0);
// 红白蓝对应J10 J11 J12
PWM_SetCompare1(0); // J10
PWM_SetCompare2(0); // J12
PWM_SetCompare4(0); // J11
// printf("init start\r\n");
// init_Net();//网络初始化
// printf("init_Net OK");
// while(!do_dns((u8 *)"hp8oQhMZJ67.iot-as-mqtt.cn-shanghai.aliyuncs.com"));// network name
// default open back fan
gpio_state |= 0x04;
HC595_Send_Byte(gpio_state);
os_init();
while (1)
{
// printf("%d,%d,%d\r\n",a_value,b_value,c_value);
}
}