
#include "stm32f0xx_hal.h" void SystemClock_Config(void);% U1 J( }- `, P' e) s' k- h9 p static void MX_GPIO_Init(void);6 c2 i1 H- r3 B0 q5 E int main(void) {5 m* d# S* z, T7 ]7 W uint8_t x; HAL_Init();9 Q! M5 C; V" [3 Q SystemClock_Config(); MX_GPIO_Init();1 I; G+ D7 c; b0 b while (1) { x=HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13); if(x==0)" o z/ x3 a$ j9 a9 ~: V# P { HAL_Delay(10);5 ]6 n6 [7 o9 E' D7 @; N3 A if(x==0)2 K. I& t/ R! g1 A- e& ?0 i { HAL_GPIO_WritePin(GPIOA,GPIO_PIN_5,GPIO_PIN_SET);1 P$ J( H: ~: d } } else N! }5 g9 f' W9 M. e, t6 i1 ~9 ] { HAL_GPIO_WritePin(GPIOA,GPIO_PIN_5,GPIO_PIN_RESET);* S5 q" n: H/ y2 u k& e }8 m2 s# M" e9 s } } void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct;7 y* r2 }5 B, {! q RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; RCC_OscInitStruct.HSIState = RCC_HSI_ON; l6 m7 v7 J+ {/ d; w9 s& a RCC_OscInitStruct.HSICalibrationValue = 16;/ l' Y U' _. g9 h RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;2 V3 R7 I3 [: |1 N RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; f7 A8 j1 f; Q9 q# _9 W. }9 b RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12;, d) s$ \5 B: _3 j Y7 B( A RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV2;) j9 A& U; Y" @$ |8 z. x HAL_RCC_OscConfig(&RCC_OscInitStruct); RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;: L) O2 G1 R3 k2 v: a3 f$ O; K RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;) y& g; t0 K3 ? RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;1 ^9 B% K5 ?9 k( q2 {) f1 [ HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1); __SYSCFG_CLK_ENABLE(); } void MX_GPIO_Init(void) { GPIO_InitTypeDef GPIO_InitStruct;. l4 k- K7 K( A$ W) F3 O, L __GPIOC_CLK_ENABLE();' F$ \2 I, g. J' Z, v __GPIOA_CLK_ENABLE(); GPIO_InitStruct.Pin = GPIO_PIN_13;5 }1 Y. k' U2 [" w, P* I" ? GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL;4 [" j" j* x9 E8 Q- Y HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);. U+ P% m+ C0 n( }: { GPIO_InitStruct.Pin = GPIO_PIN_5;# U- N2 @- g1 z GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;, X) A% j$ p% U% Q4 s& f GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_LOW;, x. M( W& `( u/ a# R* j8 Y HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); } #ifdef USE_FULL_ASSERT void assert_failed(uint8_t* file, uint32_t line)! d6 `, v* x" w7 z, R& a8 r/ J { } #endif" v5 N7 z; G, H! F. u+ \ C 8 a+ |8 e% W/ f1 F- n |
KEY.zip
下载1.36 KB, 下载次数: 5
cubeæä»¶
版主自重,小心管理员拍死你,推了这么久
下倒是下成功了,不过不会玩,都是我技术烂,技术烂~