0979866a7c
- 删除 protocol.h,帧定义和标定命令码统一迁入 comm_protocol.h - 新增 comm_protocol.c:上行组包(CoP/标定响应)、下行解析+msgq 分发 - ble_transport 剥离所有协议解析和参数 getter,仅保留字节收发+rx 回调注册 - main.c 初始化顺序:ble_transport → comm_protocol → adv_start → cal_init - 更新 README 架构图和项目结构表,补充标定流程章节 - 更新 BALANCE_BOARD_PROTOCOL.md 增加标定命令/响应帧格式文档
54 lines
1.2 KiB
C
54 lines
1.2 KiB
C
/*
|
|
* GML670 Balance Board — CoP Binary Protocol
|
|
* Features:
|
|
* - 4-channel ADS1256 with averaging filter.
|
|
* - Board-side CoP (Center of Pressure) computation.
|
|
* - Binary protocol over BLE NUS (17-byte CoP frame, 50 Hz).
|
|
* - Downlink: resistance params, spotter mode, heartbeat.
|
|
*/
|
|
|
|
#include "ble_transport.h"
|
|
#include "button.h"
|
|
#include "calibration.h"
|
|
#include "comm_protocol.h"
|
|
#include "sensor.h"
|
|
|
|
#include <zephyr/kernel.h>
|
|
#include <zephyr/logging/log.h>
|
|
|
|
LOG_MODULE_REGISTER(main, LOG_LEVEL_INF);
|
|
|
|
/**
|
|
* @brief 初始化系统各模块并进入主线程驻留状态。
|
|
*
|
|
* @retval 0 理论上的正常返回值;当前实现进入永久休眠后不会主动返回。
|
|
* @retval -1 按键模块或传感器模块初始化失败。
|
|
*/
|
|
int main(void) {
|
|
k_msleep(2000);
|
|
LOG_INF("--- GML670 System (CoP Binary Protocol) ---");
|
|
|
|
ble_transport_init();
|
|
comm_protocol_init();
|
|
ble_transport_adv_start();
|
|
|
|
if (cal_init()) {
|
|
LOG_ERR("Failed to initialize calibration");
|
|
return -1;
|
|
}
|
|
|
|
if (button_init()) {
|
|
LOG_ERR("Failed to initialize buttons");
|
|
return -1;
|
|
}
|
|
|
|
if (sensor_init()) {
|
|
LOG_ERR("Failed to initialize sensor");
|
|
return -1;
|
|
}
|
|
|
|
k_sleep(K_FOREVER);
|
|
|
|
return 0;
|
|
}
|