库 | 芯片支持 | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
WB | F0 | G0 | F1 | F2 | F3 | G4 | F4 | F7 | H7 | L0 | L1 | L4/L4+ | L5 | ||
F30x | F37x | ||||||||||||||
STM32Snippets | N | Y | N | Y | N | ||||||||||
Standard peripheral library(SPL) | N | Y | N | Y | N | Y | N | Y | N | ||||||
Hardware Abstraction Layer(HAL) | Y | ||||||||||||||
Low-Layer(LL) | Y |
库 | 可移植性 | 优化(内存和指令) | 易用性 | 可读性 | 硬件覆盖率 |
---|---|---|---|---|---|
Snippets | +++ | + | |||
SPL | ++ | ++ | + | ++ | +++ |
HAL | +++ | + | ++ | +++ | +++ |
LL | + | +++ | + | ++ | ++ |
库 | 最新版本 | 最后更新日期 |
---|---|---|
STM32SnippetsF0 | 1.2.0 | 2015.06.19 |
STM32SnippetsL0 | 1.2.0 | 2016.02.05 |
库 | 最新版本 | 最后更新日期 |
---|---|---|
STM32F0xx标准外设库 | 1.5.0 | 2014.12.05 |
STM32F10x标准外设库 | 3.5.0 | 2011.04.08 |
STM32F20x标准外设库 | 1.1.0 | 2012.04.13 |
STM32F4 DSP和标准外设库 | 1.8.0 | 2016.11.09 |
STM32L1xx标准外设库 | 1.3.1 | 2015.05.20 |
STM32F301x/302x/303x/334x DSP和标准外设库 | 1.2.3 | 2015.08.14 |
STM32F37x/38x DSP和标准外设库 | 1.0.0 | 2012.09.20 |
库 | 最新版本 | 最后更新日期 |
---|---|---|
STM32CubeF0 | 1.11.0 | 2019.09.12 |
STM32CubeF1 | 1.8.0 | 2019.06.26 |
STM32CubeF2 | 1.9.0 | 2020.01.07 |
STM32CubeF3 | 1.11.0 | 2019.09.12 |
STM32CubeF4 | 1.25.0 | 2020.02.12 |
STM32CubeF7 | 1.16.0 | 2020.02.14 |
STM32CubeG0 | 1.3.0 | 2019.06.25 |
STM32CubeG4 | 1.3.0 | 2020.06.26 |
STM32CubeH7 | 1.8.0 | 2020.05.29 |
STM32CubeL0 | 1.11.2 | 2019.02.22 |
STM32CubeL1 | 1.10.0 | 2020.06.24 |
STM32CubeL4 | 1.16.0 | 2020.06.26 |
STM32CubeL5 | 1.3.0 | 2020.06.26 |
STM32CubeMP1 | 1.2.0 | 2020.02.03 |
STM32CubeWB | 1.8.0 | 2020.06.23 |
STM32F103RC
Device->Startup
和Device->StdPeriph Drivers->GPIO
,点击Resolve会自动选择其他必须的选择
main.c
,把main.c
添加到工程main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "stm32f10x.h"
#include "my_gpio.h"
#define SOFT_DELAY Delay(0x0FFFFF);
void Delay(__IO u32 nCount);
int main(void){
/* LED 端口初始化 */
LED_GPIO_Config();
while(1)
{
LED1(ON); // 亮
SOFT_DELAY;
LED1(OFF); // 灭
LED2(ON); // 亮
SOFT_DELAY;
LED2(OFF); // 灭
}
}
void Delay(__IO uint32_t nCount) //简单的延时函数
{
for(; nCount != 0; nCount--);
}
my_gpio.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
******************************************************************************
* @file my_gpio.c
* @author author
* @version V1.0
* @date 2020.07.28
* @brief led应用函数接口
******************************************************************************
* @attention
*
*
******************************************************************************
*/
#include "my_gpio.h"
/**
* @brief 初始化控制LED的IO
* @param 无
* @retval 无
*/
void LED_GPIO_Config(void)
{
/*定义一个GPIO_InitTypeDef类型的结构体*/
GPIO_InitTypeDef GPIO_InitStructure;
/*开启LED相关的GPIO外设时钟*/
RCC_APB2PeriphClockCmd( LED1_GPIO_CLK | LED2_GPIO_CLK , ENABLE);
/*选择要控制的GPIO引脚*/
GPIO_InitStructure.GPIO_Pin = LED1_GPIO_PIN;
/*设置引脚模式为通用推挽输出*/
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
/*设置引脚速率为50MHz */
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
/*调用库函数,初始化GPIO*/
GPIO_Init(LED1_GPIO_PORT, &GPIO_InitStructure);
/*选择要控制的GPIO引脚*/
GPIO_InitStructure.GPIO_Pin = LED2_GPIO_PIN;
/*调用库函数,初始化GPIO*/
GPIO_Init(LED2_GPIO_PORT, &GPIO_InitStructure);
/* 关闭所有led灯 */
GPIO_SetBits(LED1_GPIO_PORT, LED1_GPIO_PIN);
/* 关闭所有led灯 */
GPIO_SetBits(LED2_GPIO_PORT, LED2_GPIO_PIN);
}
/*********************************************END OF FILE**********************/
my_gpio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef __LED_H
#define __LED_H
#include "stm32f10x.h"
/* 定义LED连接的GPIO端口, 用户只需要修改下面的代码即可改变控制的LED引脚 */
#define LED1_GPIO_PORT GPIOC /* GPIO端口 */
#define LED1_GPIO_CLK RCC_APB2Periph_GPIOC /* GPIO端口时钟 */
#define LED1_GPIO_PIN GPIO_Pin_2
#define LED2_GPIO_PORT GPIOC /* GPIO端口 */
#define LED2_GPIO_CLK RCC_APB2Periph_GPIOC /* GPIO端口时钟 */
#define LED2_GPIO_PIN GPIO_Pin_3
/** the macro definition to trigger the led on or off
* 1 - off
*0 - on
*/
#define ON 0
#define OFF 1
/* 使用标准的固件库控制IO*/
#define LED1(a) if (a) \
GPIO_SetBits(LED1_GPIO_PORT,LED1_GPIO_PIN);\
else \
GPIO_ResetBits(LED1_GPIO_PORT,LED1_GPIO_PIN)
#define LED2(a) if (a) \
GPIO_SetBits(LED2_GPIO_PORT,LED2_GPIO_PIN);\
else \
GPIO_ResetBits(LED2_GPIO_PORT,LED2_GPIO_PIN)
void LED_GPIO_Config(void);
#endif /* __LED_H */