fix(README): 修正文档中协议字段链接路径
fix(main): 修正主循环中延时以保持程序运行
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
> 当前目录是 `GML670x4_V2`。代码内的 CMake 项目名是 `GML670_V2`,BLE 设备名是 `GML670_System`。
|
||||
>
|
||||
> 这份 README 只描述当前 `V2` 工程已经落地的实现。更细的协议字段和示例帧见 [BALANCE_BOARD_PROTOCOL.md](./BALANCE_BOARD_PROTOCOL.md)。
|
||||
> 这份 README 只描述当前 `V2` 工程已经落地的实现。更细的协议字段和示例帧见 [BALANCE_BOARD_PROTOCOL.md](./doc/BALANCE_BOARD_PROTOCOL.md)。
|
||||
|
||||
---
|
||||
|
||||
|
||||
+1
-2
@@ -26,15 +26,14 @@ LOG_MODULE_REGISTER(ads1256, LOG_LEVEL_INF);
|
||||
#define SPI_OP (SPI_OP_MODE_MASTER | SPI_MODE_CPHA | SPI_WORD_SET(8) | SPI_LINES_SINGLE)
|
||||
|
||||
/* --- 硬件资源 --- */
|
||||
static const struct device *spi_dev;
|
||||
static struct spi_config spi_cfg;
|
||||
static const struct device *spi_dev;
|
||||
static const struct gpio_dt_spec cs_spec = GPIO_DT_SPEC_GET(DT_ALIAS(ads_cs), gpios);
|
||||
static const struct gpio_dt_spec drdy_spec = GPIO_DT_SPEC_GET(DT_ALIAS(ads_drdy), gpios);
|
||||
static const struct gpio_dt_spec reset_spec = GPIO_DT_SPEC_GET(DT_ALIAS(ads_reset), gpios);
|
||||
|
||||
void ads1256_wait_drdy(uint16_t timeout_ms) {
|
||||
/* drdy_spec 配了 GPIO_ACTIVE_LOW,逻辑 1 表示 DRDY 有效(物理拉低) */
|
||||
/* 用 k_usleep 代替 k_busy_wait,让出 CPU 给其他线程 */
|
||||
int64_t deadline = k_uptime_get() + timeout_ms;
|
||||
while (gpio_pin_get_dt(&drdy_spec) == 0) {
|
||||
k_usleep(10);
|
||||
|
||||
@@ -23,6 +23,9 @@ int main(void) {
|
||||
ble_transport_adv_start();
|
||||
|
||||
if (sensor_init()) return 0;
|
||||
while (1) {
|
||||
k_sleep(K_SECONDS(1));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user