generated from hulk/gd32f4xx_template_cmake_vscode
64 lines
1.4 KiB
C
64 lines
1.4 KiB
C
/*!
|
||
\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 "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 数据口处理(拉通阶段:回显) */
|
||
rs485_process();
|
||
|
||
/* 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;
|
||
printf("NTC temp: %.1f C\r\n", ntc_read_temperature());
|
||
}
|
||
}
|
||
#endif
|
||
|
||
delay_ms(10);
|
||
}
|
||
}
|