修改了驱动部分注释 提升了代码的易读性

This commit is contained in:
ipason 2026-01-06 18:03:24 +08:00
parent 8a32570868
commit d5a4f2a778
3 changed files with 82 additions and 25 deletions

View File

@ -5,7 +5,7 @@
* @brief Voice Recognition Module Initialization Section,
including peripheral initialization and message node insertion, etc.
* @version 1.0
* @changelog version 1.0 2025.12.31
* @changelog version 1.0 2026.1.6
******************************************************************************
* @attention
*
@ -54,9 +54,17 @@
EleC_V_data elec_v_data;
// 向对应寄存器写入数据 低位在低位 高位在高位
// 共24bit不足处用0补齐低位先行
// 发送数据大小限定为3个字节
#if COULOMBMETER_SET_FUNC_ENABLE
/**
* @brief BL0942指定寄存器写入24位数据
* @param addr: (8)
* @param reg_data: 3
* @retval
* @note 1. 24bit0
* 2. UART发送帧格式为[(BL0942_ADDR_W)++3+]
* 3. (++3)8
* 4. 3
*/
static void coulombmeter_write_reg(uint8_t addr, uint8_t* reg_data)
{
uint8_t check_sum = 0;
@ -77,12 +85,19 @@ static void coulombmeter_write_reg(uint8_t addr, uint8_t* reg_data)
check_sum = ~(check_sum & 0xFF);
COULOMBMETER_UART_TRANS_BYTE(check_sum);
}
#endif
// 从特定寄存器读取数据 芯片将通过串口接收中断返回
// 芯片收到消息后将在150us内返回数据
// 1s执行一次 数据在接收中断中处理
/**
* @brief BL0942指定寄存器读取数据
* @param addr: (8)
* @retval
* @note 1. UART发送帧格式为[(BL0942_ADDR_R)+]
* 2. 150us内通过UART返回4字节数据(3+1)
* 3. 1s执行一次该函数UART接收中断中处理
*/
static void coulombmeter_read_reg(uint8_t addr)
{
// 1. Ï·¢ÃüÁî×Ö½Ú BL0942_ADDR_R
@ -94,6 +109,17 @@ static void coulombmeter_read_reg(uint8_t addr)
/**
* @brief (UART5)
* @param
* @retval
* @note 1. UART TX/RX引脚UART通信参数
* 2. UART参数960081
* 3. UART5接收缓冲区满中断2
* 4. elec_v_data
*/
void User_PowerMeter_Init(void)
{
@ -137,7 +163,16 @@ void User_PowerMeter_Init(void)
// 推荐1s刷新一次 最终数据将存储在全局变量elec_v_data中
/**
* @brief /
* @param
* @retval
* @note 1. 1s调用一次该函数
* 2. (Addr_I_RMS)(Addr_V_RMS)
* 3. UART中断中完成
* 4. /elec_v_data中
*/
void User_Coulombmeter_Data_refresh(void)
{
static Bus_Mod mod = MOD_CURRENT_METER;
@ -165,6 +200,16 @@ void User_Coulombmeter_Data_refresh(void)
/**
* @brief UART5中断服务函数
* @param
* @retval
* @note 1. (RXBuffFull)
* 2. (BUS_COM_STATE)/
* 3. 3()+1
* 4. (V)/(mA)
* 5. RXBuff寄存器自动清除RXBuffFull标志
*/
void UART5_IRQHandler(void)
{
@ -237,20 +282,12 @@ void UART5_IRQHandler(void)
}
}
FL_UART_ClearFlag_RXBuffFull(COULOMBMETER_USED_UART_NUM);
}
}
/************************ (C) COPYRIGHT YUWELL *****END OF FILE****/

View File

@ -52,6 +52,8 @@ extern "C" {
#define COULOMBMETER_UART_TRANS_BYTE(x) FL_UART_WriteTXBuff(COULOMBMETER_USED_UART_NUM, x);CHECK_TRANS_DONE;
#define COULOMBMETER_SET_FUNC_ENABLE (0)
/************************** 芯片内部寄存器地址定义 **************************/
// 电参数寄存器(只读)

File diff suppressed because one or more lines are too long