fix(README): 修正文档中协议字段链接路径

fix(main): 修正主循环中延时以保持程序运行
This commit is contained in:
2026-05-07 09:03:45 +08:00
parent 2ab146b49c
commit 0d2fd30b3a
3 changed files with 5 additions and 3 deletions
+1 -2
View File
@@ -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);
+3
View File
@@ -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;
}