feat: 添加杰理 JL7016 SOC 代码生成模板
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/* ================================================================
|
||||
* jb_common.h — 工具函数(校验和、大端序转换)
|
||||
*
|
||||
* 说明: 见宝协议采用大端序(Big-Endian)。
|
||||
* 多字节值(uint16/uint32)按高位在前传输。
|
||||
* ================================================================
|
||||
*/
|
||||
#ifndef _JB_COMMON_H
|
||||
#define _JB_COMMON_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/* ════════════════════════════════════════════════════════════════
|
||||
* 校验和
|
||||
* sum(LEN_H, LEN_L, CMD, SN, ...payload_last) & 0xFF
|
||||
* buf[0]=55, buf[1]=AA,累加范围从 buf[2] 到 buf[totalLen-2]
|
||||
* ════════════════════════════════════════════════════════════════ */
|
||||
uint8_t jbChecksum(const uint8_t *frame, uint16_t totalLen);
|
||||
|
||||
/* ════════════════════════════════════════════════════════════════
|
||||
* 大端序转换
|
||||
* ════════════════════════════════════════════════════════════════ */
|
||||
|
||||
/* 从字节数组读取 uint16(大端序)*/
|
||||
uint16_t jbReadU16BE(const uint8_t *buf);
|
||||
|
||||
/* 从字节数组读取 uint32(大端序)*/
|
||||
uint32_t jbReadU32BE(const uint8_t *buf);
|
||||
|
||||
/* 将 uint16 写入字节数组(大端序)*/
|
||||
void jbWriteU16BE(uint8_t *buf, uint16_t val);
|
||||
|
||||
/* 将 uint32 写入字节数组(大端序)*/
|
||||
void jbWriteU32BE(uint8_t *buf, uint32_t val);
|
||||
|
||||
#endif /* _JB_COMMON_H */
|
||||
Reference in New Issue
Block a user