Files
RCU_C1P_Launcher/MCU_Driver/timer.c
caocong 5e9338cee4 新增:串口通讯避障功能
​ 1、Launcher中的串口只使用串口0(调试串口)、串口2(主动RS485端口);串口1与串口3不使用,且不初始化。将串口通讯缓冲区修改为1100Byte。

​  目的:CH564由于将Launcher代码搬运到RAM中运行,因此可使用的变量大小只有32Kbyte。不使用的串口将不初始化,同时使用的通讯缓冲区将节约出来,否则RAM空间不够使用。

​ 2、串口2 - 增加RS485使能,同时通讯增加避障功能。
2026-01-19 16:39:22 +08:00

53 lines
856 B
C

/*
* timer.c
*
* Created on: May 16, 2025
* Author: cc
*/
#include "timer.h"
#include <stdio.h>
#include <string.h>
void TIMER0_Init(void)
{
TMR0_DeInit();
TMR0_TimerInit(SystemCoreClock / 10000);
TMR0_ITCfg(RB_TMR_IF_CYC_END, ENABLE);
NVIC_EnableIRQ(TIM0_IRQn);
TMR0_Enable();
}
volatile uint32_t Time0_100us = 0;
volatile uint32_t Time0_1ms = 0;
void TIM0_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
void TIM0_IRQHandler(void)
{
static uint8_t NUM_1 = 0;
TMR0_ClearITFlag(RB_TMR_IF_CYC_END);
Time0_100us++;
NUM_1++;
if(NUM_1 >= 10){
NUM_1 = 0;
Time0_1ms++;
}
}
void Timer0_Task(void)
{
static uint32_t timer0_tick = 0;
if(Time0_1ms - timer0_tick >= 1000 ){
timer0_tick = Time0_1ms;
printf("Run:%d ..",timer0_tick);
}
}