feat: 换用更简单的通信帧格式

This commit is contained in:
bmy
2024-03-04 15:05:40 +08:00
parent f1c0b63d21
commit 7e7b22c992
20 changed files with 149 additions and 620 deletions

View File

@@ -2,11 +2,11 @@
* CH32V307VCT6 Opensourec Library 即CH32V307VCT6 开源库)是一个基于官方 SDK 接口的第三方开源库
* Copyright (c) 2022 SEEKFREE 逐飞科技
*
* 本文件是CH32V307VCT6 开源库的一部分
* 本文件是 CH32V307VCT6 开源库的一部分
*
* CH32V307VCT6 开源库 是免费软件
* 您可以根据自由软件基金会发布的 GPLGNU General Public License即 GNU通用公共许可证的条款
* 即 GPL 的第3版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
* 您可以根据自由软件基金会发布的 GPLGNU General Public License即 GNU 通用公共许可证)的条款
* 即 GPL 的第 3 版(即 GPL3.0)或(您选择的)任何后来的版本,重新发布和/或修改它
*
* 本开源库的发布是希望它能发挥作用,但并未对其作任何的保证
* 甚至没有隐含的适销性或适合特定用途的保证
@@ -30,7 +30,7 @@
*
* 修改记录
* 日期 作者 备注
* 2022-09-15 大W first version
* 2022-09-15 大 W first version
********************************************************************************************************************/
@@ -95,9 +95,9 @@ void pit_disable (pit_index_enum pit_n)
//-------------------------------------------------------------------------------------------------------------------
// 函数简介 定时器周期中断
// 参数说明 timer_ch 定时器通道
// 参数说明 us 定时周期(1-65535)
// 参数说明 us 定时周期 (1-65535)
// 返回参数 void
// 备注信息 pit_init(TIMER_1, 5); 使用定时器1作为5ms一次的周期中断
// 备注信息 pit_init(TIMER_1, 5); 使用定时器 1 作为 5ms 一次的周期中断
//-------------------------------------------------------------------------------------------------------------------
void pit_init (pit_index_enum pit_n, uint32 period)
{
@@ -136,10 +136,10 @@ void pit_init (pit_index_enum pit_n, uint32 period)
TIM_TimeBaseStructure.TIM_Period = period_temp;
TIM_TimeBaseStructure.TIM_Prescaler = freq_div; // 分频值
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; // 设置时钟分割:TDTS = Tck_tim
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; // TIM向上计数模式
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0; // 重复计数器设置为0
TIM_TimeBaseInit(tim_index, &TIM_TimeBaseStructure); // 根据指定的参数初始化TIMx的时间基数单位
TIM_ITConfig(tim_index,TIM_IT_Update,ENABLE ); // 使能指定的TIM中断,允许更新中断
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; // TIM 向上计数模式
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0; // 重复计数器设置为 0
TIM_TimeBaseInit(tim_index, &TIM_TimeBaseStructure); // 根据指定的参数初始化 TIMx 的时间基数单位
TIM_ITConfig(tim_index,TIM_IT_Update,ENABLE ); // 使能指定的 TIM 中断允许更新中断
TIM_ClearITPendingBit(tim_index, TIM_IT_Update);
const uint32 irq_index[10] =
@@ -156,7 +156,7 @@ void pit_init (pit_index_enum pit_n, uint32 period)
TIM10_UP_IRQn
};
interrupt_set_priority((IRQn_Type)irq_index[(uint8)pit_n], 0x03); // 设置中断优先级
interrupt_set_priority((IRQn_Type)irq_index[(uint8)pit_n], (1<<5) | 3); // 设置中断优先级
interrupt_enable((IRQn_Type)irq_index[pit_n]); // 使能中断
TIM_Cmd(tim_index, ENABLE); // 使能定时器