|
#include "stm32f0xx_hal.h") W ?+ I5 Q! n void SystemClock_Config(void); static void MX_GPIO_Init(void); int main(void) {) W( L3 S' b. {6 ?; }0 g uint8_t x;) V! k8 P b6 ]0 t* E HAL_Init();3 A$ V8 {0 [& o2 K+ C R r SystemClock_Config(); MX_GPIO_Init(); while (1) {0 y5 Z2 \$ l q7 X: s, [1 _ x=HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13);# A4 s w( z! e if(x==0)* J. d! `3 b! C. q& X {: d' f! e2 R [- {! y4 r8 W HAL_Delay(10); if(x==0) {3 Z5 `! I5 [& C HAL_GPIO_WritePin(GPIOA,GPIO_PIN_5,GPIO_PIN_SET); } }* j ^; w" }( w% v- _, _8 Y( V else { HAL_GPIO_WritePin(GPIOA,GPIO_PIN_5,GPIO_PIN_RESET);6 I: y6 G; m( e* p0 R+ d }/ Y6 o) |8 k0 ~1 t8 ] }: m6 Y8 Q0 ]! L' q: B }7 @7 ~4 D% r9 S: k4 }7 r# P% ~% d void SystemClock_Config(void) {' M8 q9 R4 `1 o% H# ]* r" X RCC_OscInitTypeDef RCC_OscInitStruct;$ `8 Y1 [# O- D: O6 u1 p RCC_ClkInitTypeDef RCC_ClkInitStruct; W+ |" w9 @5 \* z9 J, c& R7 G RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;7 I4 A/ c7 ^: f7 ?$ [9 t( h) u6 ? RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSICalibrationValue = 16;' p/ r1 d A7 N* _4 j RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;! ^. u5 H r9 V, L0 Q2 ^* Q RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12; RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV2; HAL_RCC_OscConfig(&RCC_OscInitStruct); RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;0 b( {6 g$ \5 ~) a RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1); __SYSCFG_CLK_ENABLE();, d& W7 h1 k* L: \' i- z }3 ]! W) V4 f: U4 ] K1 d3 O& D+ v$ P; [ void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct; __GPIOC_CLK_ENABLE();% p. \5 ^, l5 H( e' p __GPIOA_CLK_ENABLE();4 s( h; A, D# t5 b, D GPIO_InitStruct.Pin = GPIO_PIN_13;" c3 x9 q1 Q" v% D! g ] GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL;6 q5 M( Z- G2 ^, i. T HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_5; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW;8 P, @+ O, M D+ w HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);* t- a' N7 R6 B- a3 h% d. ^: L! r }. V. x( t W, B n9 L$ u% Q #ifdef USE_FULL_ASSERT void assert_failed(uint8_t* file, uint32_t line) { } #endif& q3 K) _0 {. _! {9 h " U* R! x. S1 o4 s: | |
KEY.zip
下载1.36 KB, 下载次数: 5
cubeæä»¶
DMA 原理从 0 到 1:为什么它能解放 CPU?一文讲透 DMA 的工作流程
小白也能明白的STM32的低功耗与唤醒机制
STM32系统中2种数据掉电保护的方法
分享STM32F051中文参考手册(重制书签版)
AI工具训练营-用ChatGPT解决HID Keyboard实现的问题
STM32固件库分享,超全系列整理
STM32小白入门指南:从基础到OTA实现方案
STM32超详细学习笔记
新手必看!STM32单片机应该怎么学?
如果你解决了这些问题,就可以直接学STM32
微信公众号
手机版
版主自重,小心管理员拍死你,推了这么久
下倒是下成功了,不过不会玩,都是我技术烂,技术烂~