在網上搜了很久STM32F2的工程模板,發現資料真的好少,ST提供的模板又亂七八糟,所以花了一上午的時間,學習了一下模板制作,gpio和rcc頭文件添加了中文注釋,以供大家參考。
51hei圖片20200426104844.jpg (362.63 KB, 下載次數: 50)
下載附件
2020-4-26 10:49 上傳
單片機源程序如下:
- #include "stm32f2xx.h"
- #define LED1_ON GPIO_ResetBits(GPIOA, GPIO_Pin_12) //PB1控制LED1,共陽極,拉低PB1電平,點亮LED1
- #define LED1_OFF GPIO_SetBits(GPIOA, GPIO_Pin_12)
- #define LED2_ON GPIO_ResetBits(GPIOA, GPIO_Pin_11) //PB1控制LED1,共陽極,拉低PB1電平,點亮LED1
- #define LED2_OFF GPIO_SetBits(GPIOA, GPIO_Pin_11)
- int main(void)
- {
- LCD0802IO_Init();
- while(1)
- {
- LED1_ON;
- LED2_ON ;
- }
-
- }
- //void SystemInit(void)
- //{
- //}
- #define LED1_GPIO_CLK RCC_AHB1Periph_GPIOA
- #define LED1_GPIO_PORT GPIOA
- #define LED1_GPIO_PIN GPIO_Pin_12
- #define LED2_GPIO_CLK RCC_AHB1Periph_GPIOA
- #define LED2_GPIO_PORT GPIOA
- #define LED2_GPIO_PIN GPIO_Pin_11
- void LCD0802IO_Init ( void )
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA,ENABLE);
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //指定管腳的輸出類型
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
-
- GPIO_InitStructure.GPIO_Pin = LED1_GPIO_PIN;
- GPIO_Init ( LED1_GPIO_PORT, & GPIO_InitStructure );
-
- GPIO_InitStructure.GPIO_Pin = LED2_GPIO_PIN;
- GPIO_Init ( LED2_GPIO_PORT, & GPIO_InitStructure );
-
- }
復制代碼
51hei.png (4.69 KB, 下載次數: 37)
下載附件
2020-4-26 14:25 上傳
所有資料51hei提供下載:
STM32F205模板.7z
(224.23 KB, 下載次數: 37)
2020-4-26 14:26 上傳
點擊文件名下載附件
|