Draft
Conversation
Agent-Logs-Url: https://github.com/zlun10/example_code/sessions/d3f6a716-5edd-4904-8457-f29ab546a1d4 Co-authored-by: zlun10 <165892790+zlun10@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor code to decouple AT commands from hardware
重构:AT与模组层与底层硬件解耦,建立硬件抽象层(HAL)
Mar 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AT 命令层和模组业务层直接依赖芯片专用驱动(
drv_uart、CW32L011 GPIO/NVIC),导致移植困难。HAL 层存在反向依赖(hal-at.c调用dev层的module_notify_init())。架构变更
分层现在严格单向:
新增文件
hal/inc/hal_module.h— 模组硬件抽象接口:hal_module_rst()、hal_module_notify_init/deInit/resume()、hal_module_notify_callback()(回调由 dev 层实现,HAL ISR 调用)hal/src/hal_module.c— CW32L011 实现:将原module.c中的GPIOB_IRQHandler、GPIO 配置、NVIC 操作全部移入此处解耦变更
dev/src/at.c— 删除drv_uart.h引用;getAtUart()->line_ready/drv_atUart_getLine()/drv_atUart_init()统一替换为hal_at_is_line_ready()/hal_at_get_line()/hal_at_reinit_baudrate()hal/inc/hal-at.h— 新增上述三个接口 +HAL_AT_LINE_BUF_LENhal/src/hal-at.c— 实现新接口;移除对module_notify_init/deInit的调用(消除反向依赖)dev/src/module.c— 所有芯片专用代码替换为hal_module_*调用;实现hal_module_notify_callback();移除GPIOB_IRQHandlerdev/inc/module.h— 删除#include "cw32l011_gpio.h"及POWER_KEY_PORT/PIN等 GPIO 宏(移至app_lowpower.c本地定义)移植方法
移植到新平台只需实现两个文件:
dev/层及以上代码无需任何修改。文档
README.md新增完整的架构说明、各层接口参考表及移植检查清单。Original prompt
This pull request was created from Copilot chat.