Files
FilmForge/Src/main.c
T

76 lines
1.9 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*!
\file main.c
\brief FilmForge 热压模具温控固件入口
自制热压模具(塑型 PC 膜):加热驱动 + 测温(NTC)+ RS485 数据口。
基于 GD32F4xx 工程模板,目标芯片 GD32F405RET6(Cortex-M4 @168MHz)。
*/
#include "gd32f4xx.h"
#include "systick.h"
#include "uart.h"
#include "uart_ring_buffer.h"
#include "rs485.h"
#include "command.h"
#include "ntc.h"
#include "led.h"
#include <stdio.h>
#include "board_config.h"
/*!
\brief main function
\param[in] none
\param[out] none
\retval none
*/
int main(void)
{
led_init();
systick_config();
uart_ring_buffer_init();
uart_init();
rs485_init();
ntc_init();
#if DEBUG_MODE == CFG_ENABLE
printf("FilmForge FW %s, built %s\r\n", PROJECT_VERSION, BUILD_DATE);
printf("RS485 data link ready, NTC ready\r\n");
#endif
#if SEGGER_RTT_DETECTION == CFG_ENABLE
RTT_printf(0, "FilmForge FW\r\n");
#endif
while(1){
/* RS485 数据口命令处理(D5 帧协议,具体业务命令在 command.c 扩展) */
command_process();
/* NTC 后台采样(100ms 一次)+ M2 连续上报任务 */
ntc_sample_task();
command_report_task();
/* debug 串口周期打印 NTC 温度(约 1s 一次,读后台采样全局值) */
#if DEBUG_MODE == CFG_ENABLE
{
static uint16_t temp_report_counter = 0;
if (++temp_report_counter >= 100U) { /* 主循环 10ms 一圈 → 1s */
temp_report_counter = 0;
float temp = ntc_get_temperature();
if (temp <= -274.0f) {
printf("NTC SHORT (PC5 pulled low)\r\n");
} else if (temp <= -273.0f) {
printf("NTC OPEN (PC5 at VREF, check NTC wiring/solder)\r\n");
} else {
printf("NTC temp: %.1f C\r\n", temp);
}
}
}
#endif
delay_ms(10);
}
}