1、驱动库简介

本文详细介绍了STM32G0xx系列微控制器的驱动层目录结构及其内部组织方式,包括CMSIS目录下的启动文件、寄存器定义等关键文件说明,以及STM32G0xx_LL_Driver目录下的GPIO等外设驱动文件和头文件的具体内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

驱动层目录结构(本例程以stm32g070xx GCC为例)

├── driver_os
   └── fm33lc0xx
     ├── stm32f0xx
     └── stm32g0xx
         ├── CMSIS
         ├── Makefile
         ├── stm32g0xx_hal_conf.h
         └── STM32G0xx_LL_Driver

1.driver_os目录

driver_os:为驱动层主目录,此目录下包括了不同型号芯片的官方驱动
        fm33lc0xx:复旦微fm33lc0xx官方驱动
        stm32f0xx:意法半导体stm32f0xx官方驱动
        stm32g0xx:意法半导体stm32g0xx官方驱动(以此驱动为例)

2.stm32g0xx目录

        此目录主要包括了:stm32g0xx系列芯片的驱动文件和Makefile文件。

(1).CMSIS目录

        此目录包括了stm32g0xx启动文件和寄存器定义。

 └────── CMSIS
          ├── Device
          │   └── ST
          │       └── STM32G0xx
          │           ├── Include
          │           │   ├── stm32g070xx.h
          │           │   ├── stm32g0xx.h
          │           │   └── system_stm32g0xx.h
          │           └── Source
          │               └── Templates
          │                   ├── arm
          │                   ├── gcc
          │                   │   └── startup_stm32g070xx.s
          │                   ├── iar
          │                   └── system_stm32g0xx.c
          ├── Include
          │   ├── cmsis_armcc.h
          │   ├── cmsis_armclang.h
          │   ├── cmsis_armclang_ltm.h
          │   ├── cmsis_compiler.h
          │   ├── cmsis_gcc.h
          │   ├── cmsis_iccarm.h
          │   ├── cmsis_version.h
          │   └── tz_context.h
          ├── LICENSE.txt
          └── README.md

启动文件:
./CMSIS/Device/ST/STM32G0xx/Source/Templates/gcc/startup_stm32g070xx.s

设备外设访问层系统源文件:
./CMSIS/Device/ST/STM32G0xx/Source/Templates/system_stm32g0xx.c

寄存器定义以及其他宏定义头文件:
./CMSIS/Include
./CMSIS/Device/ST/STM32G0xx/Include

(2). STM32G0xx_LL_Driver目录

        此目录包括了STM32G070xx的驱动文件和头文件。

└── STM32G0xx_LL_Driver
    ├── Inc
    │   ├── stm32g0xx_ll_adc.h
    │   ├── stm32g0xx_ll_bus.h
    │   ├── stm32g0xx_ll_comp.h
    │   ├── stm32g0xx_ll_cortex.h
    │   ├── stm32g0xx_ll_crc.h
    │   ├── stm32g0xx_ll_crs.h
    │   ├── stm32g0xx_ll_dac.h
    │   ├── stm32g0xx_ll_dma.h
    │   ├── stm32g0xx_ll_dmamux.h
    │   ├── stm32g0xx_ll_exti.h
    │   ├── stm32g0xx_ll_gpio.h
    │   ├── stm32g0xx_ll_i2c.h
    │   ├── stm32g0xx_ll_iwdg.h
    │   ├── stm32g0xx_ll_lptim.h
    │   ├── stm32g0xx_ll_lpuart.h
    │   ├── stm32g0xx_ll_pwr.h
    │   ├── stm32g0xx_ll_rcc.h
    │   ├── stm32g0xx_ll_rng.h
    │   ├── stm32g0xx_ll_rtc.h
    │   ├── stm32g0xx_ll_spi.h
    │   ├── stm32g0xx_ll_system.h
    │   ├── stm32g0xx_ll_tim.h
    │   ├── stm32g0xx_ll_ucpd.h
    │   ├── stm32g0xx_ll_usart.h
    │   ├── stm32g0xx_ll_usb.h
    │   ├── stm32g0xx_ll_utils.h
    │   └── stm32g0xx_ll_wwdg.h
    └── Src
        ├── stm32g0xx_ll_adc.c
        ├── stm32g0xx_ll_comp.c
        ├── stm32g0xx_ll_crc.c
        ├── stm32g0xx_ll_crs.c
        ├── stm32g0xx_ll_dac.c
        ├── stm32g0xx_ll_dma.c
        ├── stm32g0xx_ll_exti.c
        ├── stm32g0xx_ll_gpio.c
        ├── stm32g0xx_ll_i2c.c
        ├── stm32g0xx_ll_lptim.c
        ├── stm32g0xx_ll_lpuart.c
        ├── stm32g0xx_ll_pwr.c
        ├── stm32g0xx_ll_rcc.c
        ├── stm32g0xx_ll_rng.c
        ├── stm32g0xx_ll_rtc.c
        ├── stm32g0xx_ll_spi.c
        ├── stm32g0xx_ll_tim.c
        ├── stm32g0xx_ll_ucpd.c
        ├── stm32g0xx_ll_usart.c
        ├── stm32g0xx_ll_usb.c
        └── stm32g0xx_ll_utils.c

       驱动文件路径:
                ./STM32G0xx_LL_Driver/Src
        驱动文件主要是对STM32寄存器的初始化,对此类接口的调用可以实现(GPIO为例):
                GPIO:通用输入/输出模式

                       外部中断

                       Pwm波形输出

                       ……

       驱动头文件路径:
                . /STM32G0xx_LL_Driver/Inc

头文件中主要包括了一些驱动接口初始化的结构体,通过对结构体初始化成不同的值来实现不同功能:
GPIO端口引脚号选Pin):引脚号可选择0~15(LL_GPIO_PIN_0/LL_GPIO_PIN_1…)
GPIO模式(Mode):输入、输出、复用、模拟
GPIO工作速率(Speed):低速、中速、高速、超高速
GPIO输出电平(OutputType):选择输出模式时,此值有效
GPIO上拉下拉(Pull):内接上拉、内接下拉、无上下拉
GPIO引脚外设(Alternate):复用功能时使用

/**
  * @brief LL GPIO Init Structure definition
  */
typedef struct
{
  uint32_t Pin;          /*!< Specifies the GPIO pins to be configured.
                              This parameter can be any value of @ref GPIO_LL_EC_PIN */

  uint32_t Mode;         /*!< Specifies the operating mode for the selected pins.
                              This parameter can be a value of @ref GPIO_LL_EC_MODE.

                              GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinMode().*/

  uint32_t Speed;        /*!< Specifies the speed for the selected pins.
                              This parameter can be a value of @ref GPIO_LL_EC_SPEED.

                              GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinSpeed().*/

  uint32_t OutputType;   /*!< Specifies the operating output type for the selected pins.
                              This parameter can be a value of @ref GPIO_LL_EC_OUTPUT.

                              GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinOutputType().*/

  uint32_t Pull;         /*!< Specifies the operating Pull-up/Pull down for the selected pins.
                              This parameter can be a value of @ref GPIO_LL_EC_PULL.

                              GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinPull().*/

  uint32_t Alternate;    /*!< Specifies the Peripheral to be connected to the selected pins.
                              This parameter can be a value of @ref GPIO_LL_EC_AF.

                              GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetAFPin_0_7() and LL_GPIO_SetAFPin_8_15().*/
} LL_GPIO_InitTypeDef;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值