# 32位单片机驱动库 **Repository Path**: licgg/32-microcontroller-driver_lib ## Basic Information - **Project Name**: 32位单片机驱动库 - **Description**: 自用的单片机驱动库,随机更新,目前只编写了GD32F103系列和HK32F103系列的程序,后续代码将继续丰富,有想法的可以联系我,一起探讨代码。 - **Primary Language**: C - **License**: MulanPSL-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2023-10-13 - **Last Updated**: 2026-09-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # MCU driver library (architecture v2) - Architecture: [`docs/架构方案说明.md`](docs/架构方案说明.md) - **配置与应用编写:** [`docs/配置与应用编写指南.md`](docs/配置与应用编写指南.md) - Plan: [`docs/实现计划.md`](docs/实现计划.md) - Contributing: [`docs/CONTRIBUTING.md`](docs/CONTRIBUTING.md) - **Adapt / feature skill:** [`docs/skills/mcu-adapt-feature-dev/SKILL.md`](docs/skills/mcu-adapt-feature-dev/SKILL.md) ## Layout ``` apps/ USER zone: app_main.c + apps.mk (no Kconfig; no main) kernel/ KERNEL: boot/app main + app_api.h + kernel.mk configs/ SoC defconfig presets console/ multi-backend interactive console + console/Kconfig devices/ off-chip drivers (dev_*) + per-class Kconfig protocol/ host framing + net protocols + protocol/Kconfig osal/ OS abstraction + ports + osal/Kconfig runtime/coop/ cooperative scheduler platform/ SoC HAL + project.Kconfig (name/version/LED) third_party/ vendored libs + third_party/Kconfig docs/ architecture docs + chip PDFs in ref/ tools/ toolchain and scripts ``` **User edits only `apps/`** (sources + `apps.mk`). No apps Kconfig — enable devices under **Devices**. `main()` lives in `kernel/`. ## Flash partitions (boot / app) | Region | Origin | Size | |--------|--------|------| | Boot | `0x08000000` | 16 KiB | | App | `0x08004000` | remainder of Flash | ```bash make defconfig DEFCONFIG=gd32f10x make IMAGE=boot # → build/boot/ (kernel/boot/main.c) make IMAGE=app # → build/app/ (kernel/app/main.c + apps/) make images ``` Flash **boot** at `0x08000000`, then **app** at `0x08004000`. Boot validates the App vector table and jumps; no IAP yet. ## Build ```bash make defconfig DEFCONFIG=gd32f10x make menuconfig # System → Project: name / version / LED make -j1 # defaults to IMAGE=app # also: hk32f10x / gd32f4xx / stm32f10x / stm32g4 # OS: gd32f10x_freertos / gd32f10x_ucos3 (need Kernel drop-in) make check-arch make smoke-build make smoke-devices make ci ``` See [`configs/README.md`](configs/README.md) and [`devices/README.md`](devices/README.md). ## Rules 1. `apps` / `devices` use only `hal_*`, `osal_*`, `board` API, `autoconf.h`, `app_api.h` 2. On-chip peripherals use vendor register libs / SPL — not Cube HAL / IDF drivers 3. Config source of truth: Kconfig -> `.config` -> `autoconf.h` 4. USART/I2C/SPI wiring: MCU pinmux **groups** in Kconfig; GPIO controls via `*_PORT`/`*_PIN` 5. Console: multi-backend mux (`console/`) — USART/TCP/UDP/HTTP/ITM/RTT/semihosting; `log` shell cmd 6. Project identity: `CONFIG_PROJECT_NAME` / `CONFIG_PROJECT_VERSION` (menuconfig)