版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、 stm32 LED ( )偠偠偠 ST I/O I/O (1)(0) LED PC3 LED1PC4 LED2 PC5 LED3startup/start_stm32f10x_hd.c CMSIS/core_cm3.c CMSIS/system_stm32f10x.c FWlib/stm32f10x_gpio.cFWlib/stm32f10x_rcc.c:USER/main.cUSER/stm32f10x_it.c USER/led.c1 / 11fireE-MQQ313303034firest
2、 STM32 ST3.0.0 stm32 STM32 LED 偠 -LED 偠 GPIO RCC I/O stm32f10x_rcc.c stm32f10x_gpio.c I/O stm32f10x_xxx.c stm32f10x_xxx.h stm32f10x_conf.h stm32f10x_conf.h 2 / 111. */* Includes 2. Uncomment the line below to enable peripheral header file inclusion */
3、*3. /* #include stm32f10x_adc.h */4. /* #include stm32f10x_bkp.h */5. /* #include stm32f10x_can.h */6. /* #include stm32f10x_crc.h */7. /* #include stm32f10x_dac.h */8. /* #include stm32f10x_dbgmcu.h */9. /* #include stm32f10x_dma.h */10. /* #include stm32f10x_exti.h */11. /* #include stm32f10x_flas
4、h.h*/12. /* #include stm32f10x_fsmc.h */13. /* #include stm32f10x_gpio.h */14. /* #include stm32f10x_i2c.h */15. /* #include stm32f10x_iwdg.h */16. /* #include stm32f10x_pwr.h */ stm32 咬 偅, LED偠RCC GPIO I/O Warning Eror USER 3 / 11main.cstm32f10x_it.cxxx.c1. /* Includes */
5、2. /* Uncomment the line below to enable peripheral header file inclusion */3. /* #include stm32f10x_adc.h */4. /* #include stm32f10x_bkp.h */5. /* #include stm32f10x_can.h */6. /* #include stm32f10x_crc.h */7. /* #include stm32f10x_dac.h */8. /* #include stm32f10x_dbgmcu.h */9. /* #include stm32f10
6、x_dma.h */10. /* #include stm32f10x_exti.h */11. /* #include stm32f10x_flash.h*/12. /* #include stm32f10x_fsmc.h */13. #include stm32f10x_gpio.h14. /* #include stm32f10x_i2c.h */15. /* #include stm32f10x_iwdg.h */16. /* #include stm32f10x_pwr.h */17. #include stm32f10x_rcc.h18. /* #include stm32f10x
7、_rtc.h */19. /* #include stm32f10x_sdio.h */20. /* #include stm32f10x_spi.h */21. /* #include stm32f10x_tim.h */22. /* #include stm32f10x_usart.h */23. /* #include stm32f10x_wwdg.h */24. /*#include misc.h*/ /* High level functions for NVIC and SysTick (add- on to CMSIS functions) */17. /* #include s
8、tm32f10x_rcc.h */18. /* #include stm32f10x_rtc.h */19. /* #include stm32f10x_sdio.h */20. /* #include stm32f10x_spi.h */21. /* #include stm32f10x_tim.h */22. /* #include stm32f10x_usart.h */23. /* #include stm32f10x_wwdg.h */24. /*#include misc.h*/ /* High level functions for NVIC and SysTick (add-
9、on to CMSIS functions) */ stm32 main main.c c mainxx.cxxx stm32f10x_it.c M3 咬 stm32f10x_it.c USER LED main main佪 SystemInit(); 72M CPU SystemInit() system_stm32f10x.c 4 / 111. void SystemInit (void) 2. 3. /*! RCC system reset(for debug purpose) */4. /*!CR |= (uint32_t)0x00
10、000001;6./*!CFGR &= (uint32_t)0xF8FF0000;8. /*!CR &= (uint32_t)0xFEF6FFFF;1. /*2.* main 3.* 4.* 5.* 6.*/7. int main(void) 8. 9. /* 72M */10. SystemInit();11./* LED */12. LED_GPIO_Config();13. while (1)14.15.LED1( ON );/ 16.Delay(0x6FFFEF);17.LED1( OFF );/ 18.19. LED2( ON );20. Delay(0x6FFFEF);21. LE
11、D2( OFF ); 22.23. LED3( ON );24. Delay(0x6FFFEF);25. LED3( OFF );26.27. stm32 SystemInit() SetSysClock()SetSysClock()SetSysClock() system_stm32f10x.c SYSCLK_FREQ_72MHz SetSysClockTo72(); 72M 乍 偠 72M.5 / 111. /*! Uncomment the line corresponding to the desired System clock (
12、SYSCLK)2. frequency (after reset the HSI is used as SYSCLK source) */1. static void SetSysClock(void) 2. 3. #ifdef SYSCLK_FREQ_HSE4. SetSysClockToHSE();5. #elif defined SYSCLK_FREQ_20MHz6. SetSysClockTo20();7. #elif defined SYSCLK_FREQ_36MHz8. SetSysClockTo36();9. #elif defined SYSCLK_FREQ_48MHz10.
13、SetSysClockTo48();11. #elif defined SYSCLK_FREQ_56MHz12. SetSysClockTo56();13. #elif defined SYSCLK_FREQ_72MHz14. SetSysClockTo72();15. #endif 16.17. /*! If none of the define above is enabled, the HSI is used as System clock18. source (default after reset) */19. 10. /*!CR &= (uint32_t)0xFFFBFFFF;12
14、. /*!CFGR &= (uint32_t)0xFF80FFFF;14. /*!CIR = 0x00000000;16.17. /*! Configure the System clock frequency, HCLK, PCLK2 and PCLK1 prescalers */18. /*! Configure the Flash Latency cycles and enable prefetch buffer */19. SetSysClock();20. stm32 SetSysClockTo72() 72M ST催SetSys
15、ClockTo72)( 8M PLL 72M6 / 111. #elif defined SYSCLK_FREQ_72MHz 2. /*3. * brief Sets System clock frequency to 72MHz and configure HCLK, PCLK24. *and PCLK1 prescalers.5. * param None.6. * arg None.7. * note : This function should be used only after reset.8. * retval value: None. 9.*/10. static void S
16、etSysClockTo72(void)11. 12.IO uint32_t StartUpCounter = 0, HSEStatus = 0; 13.14./*! SYSCLK, HCLK, PCLK2 and PCLK1 configuration -*/15. /*!CR |= (uint32_t)RCC_CR_HSEON); 17.18. /*!CR & RCC_CR_HSERDY;22. StartUpCounter+;23. while(HSEStatus = 0) & (StartUpCounter != HSEStartUp_TimeOut); 24.25.if (RCC-C
17、R & RCC_CR_HSERDY) != RESET)26.27.HSEStatus = (uint32_t)0x01;28.29.else30.31.HSEStatus = (uint32_t)0x00;32. 33.34.if (HSEStatus = (uint32_t)0x01)35.36. /*!ACR |= FLASH_ACR_PRFTBE; 38.39. /*!ACR &= (uint32_t)(uint32_t)FLASH_ACR_LATENCY);41. FLASH-ACR |= (uint32_t)FLASH_ACR_LATENCY_2; 42.43. /*!CFGR |
18、= (uint32_t)RCC_CFGR_HPRE_DIV1; 45.3. /#define SYSCLK_FREQ_HSEHSE_Value4. /#define SYSCLK_FREQ_20MHz 200000005. /#define SYSCLK_FREQ_36MHz 360000006. /#define SYSCLK_FREQ_48MHz 480000007. /#define SYSCLK_FREQ_56MHz 560000008. #define SYSCLK_FREQ_72MHz 72000000 stm32 System
19、Init() LED I/O mian LED_GPIO_Config() LED_GPIO_Config() /*led.c 7 / 111. * LED_GPIO_Config2. * LED I/O 3.* 4.* 5.*/6. void LED_GPIO_Config(void) 7. 8. GPIO_InitTypeDef GPIO_InitStructure;9. RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOC, ENABLE); 10.11. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_
20、Pin_4 | GPIO_Pin_5;12. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;46. /*!CFGR |= (uint32_t)RCC_CFGR_PPRE2_DIV1; 48.49. /*!CFGR |= (uint32_t)RCC_CFGR_PPRE1_DIV2; 51.52./*!CFGR &= (uint32_t)(uint32_t)(RCC_CFGR_PLLSRC | RCC_CFGR_PLLXTPRE | RCC_CFGR_ PLLMULL);54. RCC-CFGR |= (uint32_t)(RCC_CFGR_PLL
21、SRC | RCC_CFGR_PLLMULL9);55. /*!CR |= RCC_CR_PLLON; 57.58. /*!CR & RCC_CR_PLLRDY) = 0)60.61.62. /*!CFGR &= (uint32_t)(uint32_t)(RCC_CFGR_SW);64. RCC-CFGR |= (uint32_t)RCC_CFGR_SW_PLL;65. /*!CFGR & (uint32_t)RCC_CFGR_SWS) != (uint32_t)0x08)0. else71. /*! If HSE fails to start-up, the applic
22、ation will have wrong clock72. configuration. User can add here some code to deal with this error */73. /*! GPIO_InitTypeDef GPIO_InitStructure 2- I/O 3- I/O 4- I/O I/O I/O I/O I/O5- 6- void GPIO_Init(GPIO_TypeDef* GPIOx,GPIO_InitTypeDef* GPIO_InitStruct) I/O 9 / 111. typedef enum 2. 3. GPIO_Speed_1
23、0MHz = 1,4. GPIO_Speed_2MHz,5. GPIO_Speed_50MHz6. GPIOSpeed_TypeDef;3. GPIO_Mode_IN_FLOATING = 0x04,/ 4. GPIO_Mode_IPD = 0x28,/ 5. GPIO_Mode_IPU = 0x48,/ 6. GPIO_Mode_Out_OD = 0x14,/ 7. GPIO_Mode_Out_PP =0x10,/ 8. GPIO_Mode_AF_OD = 0x1C,/ 9. GPIO_Mode_AF_PP = 0x18/ stm32 I
24、/O (1)(0) stm32f10x_gpio.c I/O LED_GPIO_Config() GPIO_SetBits(GPIOC, GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5); LED LED VCCI/OI/O 催()LED I/O stm32f10x_gpio.h 10 / 111. void GPIO_DeInit(GPIO_TypeDef* GPIOx);2. void GPIO_AFIODeInit(void);3. void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitSt
25、ruct);4. void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct);5. uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);6. uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx);7. uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);8. uint16_t GPIO_ReadOutputData(GPIO
26、_TypeDef* GPIOx);9. void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);10. void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);11. void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal);12. void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal);13. void GPIO_PinL
27、ockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);14. void GPIO_EventOutputConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource);15. void GPIO_EventOutputCmd(FunctionalState NewState);16. void GPIO_PinRemapConfig(uint32_t GPIO_Remap, FunctionalState NewState);17. void GPIO_EXTILineConfig(uint8_t GPIO_PortSour
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 文物保护工程从业资格考试模拟试卷(完整版)
- 妇产科病区的安全管理
- 牙齿健康笑容绽放
- 完整版2025年中级注安《化工安全》考试真题及答案解析
- 景观照明安装专项施工方案
- 冶金企业驾驶员日常检查安全操作规程
- 消防电梯安装专项施工方案
- 精细化工企业安全技术措施制度
- 危险化学品使用单位主要负责人检修维修安全操作规程
- 高层中心施工组织设计方案
- 2026年芯片设计DFT工程师高频面试题包含详细解答
- 供排水安全工作方案
- 娄底市辅警招聘公安基础知识考试题库及答案
- 2025年湖南事业单位招聘考试(计算机)细选练习试题及答案
- 危重患者的容量管理
- 2025版《煤矿安全规程》解读
- 2025年下学期初中数学与纳米技术试卷
- 2025年度内江市专业技术继续教育公需科目考试及答案
- 华为管理体系讲解
- 医疗器械公司工作程序 (一)
- 失智老年人照护课件
评论
0/150
提交评论