65 lines
2.1 KiB
C
65 lines
2.1 KiB
C
/******************************************************************************
|
||
* @file usr_usb_jb.h
|
||
* @brief USB CDC 见宝帧解析:设置 ProdtCode / productCode 并落盘重广播
|
||
* @author cyWu <1917507415@qq.com>
|
||
* @date 2026.07.24
|
||
* @version V1.0.0
|
||
* @history
|
||
* - V1.0.0, 2026.07.24, cyWu, 首次发布
|
||
******************************************************************************/
|
||
|
||
#ifndef __USR_USB_JB_H__
|
||
#define __USR_USB_JB_H__
|
||
|
||
#include <stdint.h>
|
||
|
||
/*============================================================================*/
|
||
/* 宏定义 */
|
||
/*============================================================================*/
|
||
|
||
#define USR_PRODCODE_LEN (4)
|
||
#define USR_PCODE_LEN (6)
|
||
#define USR_JB_CMD_SET_PRODCODE (0x64) /**< USB 下发产品码命令 */
|
||
|
||
/*============================================================================*/
|
||
/* 外部接口 */
|
||
/*============================================================================*/
|
||
|
||
/**
|
||
* @brief 上电加载产品码(flash 优先,否则默认值)
|
||
* @return void
|
||
*/
|
||
void usr_prodcode_init(void);
|
||
|
||
/**
|
||
* @brief 获取当前产品码缓存
|
||
* @param prodcode 输出 ProdtCode,长度 USR_PRODCODE_LEN,可为 NULL
|
||
* @param pcode 输出 productCode,长度 USR_PCODE_LEN,可为 NULL
|
||
* @return void
|
||
*/
|
||
void usr_prodcode_get(uint8_t *prodcode, uint8_t *pcode);
|
||
|
||
/**
|
||
* @brief 记录最近一次 BLE 收到的 msgid(供 USB 回包复用)
|
||
* @param msgid BLE 包头 msgid(4bit)
|
||
* @return void
|
||
*/
|
||
void usr_ble_rx_msgid_save(uint8_t msgid);
|
||
|
||
/**
|
||
* @brief 获取最近一次 BLE 收到的 msgid
|
||
* @return msgid
|
||
*/
|
||
uint8_t usr_ble_rx_msgid_get(void);
|
||
|
||
/**
|
||
* @brief USB CDC 喂数:仅入环并挂定时器(可在中断调用)
|
||
* @note 帧解析 / syscfg_write / ACK / 重广播在定时器任务中执行
|
||
* @param buf 接收缓冲
|
||
* @param len 长度
|
||
* @return void
|
||
*/
|
||
void usr_usb_jb_feed(uint8_t *buf, uint32_t len);
|
||
|
||
#endif /* __USR_USB_JB_H__ */
|