diff --git a/source/4-HAL/STM32.md b/source/4-HAL/STM32.md deleted file mode 100644 index 07eda4c..0000000 --- a/source/4-HAL/STM32.md +++ /dev/null @@ -1,21 +0,0 @@ -# Embassy STM32 HAL - -The [Embassy STM32 HAL](https://github.com/embassy-rs/embassy/tree/master/embassy-stm32) is based on the `stm32-metapac` project. - -## The infinite variant problem - -STM32 microcontrollers come in many families, and flavors and supporting all of them is a big undertaking. Embassy has taken advantage of the fact that the STM32 peripheral versions are shared across chip families. Instead of re-implementing the SPI peripheral for every STM32 chip family, embassy has a single SPI implementation that depends on code-generated register types that are identical for STM32 families with the same version of a given peripheral. - -### The metapac - -The `stm32-metapac` module uses pre-generated chip and register definitions for STM32 chip families to generate register types. This is done at compile time based on Cargo feature flags. - -The chip and register definitions are located in a separate module, `stm32-data`, which is modified whenever a bug is found in the definitions, or when adding support for new chip families. - -### he HAL - -The `embassy-stm32` module contains the HAL implementation for all STM32 families. The implementation uses automatically derived feature flags to support the correct version of a given peripheral for a given chip family. - -## Timer driver - -The STM32 timer driver operates at 32768 Hz by default. diff --git a/source/4-HAL/STM32.rst b/source/4-HAL/STM32.rst new file mode 100644 index 0000000..4bac8e3 --- /dev/null +++ b/source/4-HAL/STM32.rst @@ -0,0 +1,28 @@ + +Embassy STM32 硬件抽象层 +========================== + +.. seealso:: https://embassy.dev/book/dev/stm32.html + +`Embassy_STM32_硬件抽象层 `_ 建立于 ``stm32-metapac`` 基础之上。 + +芯片系列与版本繁多的问题 +--------------------- + +STM32 微控制器有很多系列,支持所有系列是一项艰巨的任务。STM32 不同芯片系列的外设版本是相同的,Embassy 充分利用了的这个特征。Embassy 没有为每个 STM32 芯片系列都去实现一个外设接口,对于外设版本相同的 STM32 系列,会被代码生成相同的寄存器类型,Embassy 只针对不同寄存器类型,有一个单独的 SPI 实现。 + +外设的元信息 +--------------------- + +``stm32-metapac`` 模块生成寄存器类型时,使用了 STM32 芯片系列预先生成的芯片和寄存器定义。这是在编译时根据 Cargo 功能标志完成的。 + +芯片和寄存器定义位于单独的 ``stm32-data`` 模块中,每当定义中发现错误,或添加对新芯片系列的支持时,就会对其进行修改。 + +硬件抽象层(HAL) +--------------------- +``embassy-stm32`` 模块包含了 STM32 全系列的硬件层抽象实现。对于给定芯片系列和外设版本,该实现使用自动派生出的特性标记,来支持相对应的版本。 + +定时器的驱动程序 +--------------------- + +STM32 定时器驱动程序默认工作频率为 32768 Hz。