首页
随机
最近更改
特殊页面
社群首页
参数设置
关于WHY42
免责声明
WHY42
搜索
用户菜单
登录
欢迎来到Riguz的小站!这是一个私人wiki,用来记录一些我的笔记。
查看“︁Stm32 led blink”︁的源代码
←
Stm32 led blink
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
= STM32 development settings on Mac = == ST-Link connection == * VCC 3.3v * GND * SWDCLK * SWDIO == Install Stm32CubeIde== * install [https://www.st.com/en/development-tools/stm32cubeclt.html stm32cubeclt] * install [https://www.st.com/en/development-tools/stm32cubeide.html stm32cubeide] <syntaxhighlight lang="bash"> $ arm-none-eabi-gcc --version arm-none-eabi-gcc (GNU Tools for STM32 13.3.rel1.20240926-1715) 13.3.1 20240614 Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ STM32_Programmer_CLI --version ------------------------------------------------------------------- STM32CubeProgrammer v2.19.0 ------------------------------------------------------------------- STM32CubeProgrammer version: 2.19.0 $ ST-LINK_gdbserver --version ST-LINK_gdbserver version: 7.10.0 $ cmake --version cmake version 3.28.1 CMake suite maintained and supported by Kitware (kitware.com/cmake). $ ninja --version 1.11.1 </syntaxhighlight> <ref>https://github.com/MaJerle/stm32-cube-cmake-vscode?tab=readme-ov-file</ref> == Install ST Link Driver == <syntaxhighlight lang="bash"> brew install stlink </syntaxhighlight> <syntaxhighlight lang="bash"> $ st-info --probe Found 1 stlink programmers version: V2J17S4 serial: 56FF74066580515144522467 flash: 524288 (pagesize: 2048) sram: 65536 chipid: 0x414 dev-type: F1xx_HD </syntaxhighlight> == Install PlatformIo == Install platformio extension in vscode, and then install stm32 platform: [[Image:platformio.png|600px]] = Led blink = main.h <syntaxhighlight lang="cpp"> #ifndef __MAIN_H_ #define __MAIN_H_ #include "stm32f1xx_hal.h" void Error_Handler(void); #endif </syntaxhighlight> main.cpp: <syntaxhighlight lang="cpp"> #include "main.h" #define LED_PIN GPIO_PIN_4 #define LED_GPIO_PORT GPIOD #define LED_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE() void SystemClock_Config(void); void LED_Init(); int main(void) { HAL_Init(); SystemClock_Config(); LED_Init(); while (1) { HAL_GPIO_TogglePin(LED_GPIO_PORT, LED_PIN); HAL_Delay(200); } } void LED_Init() { LED_GPIO_CLK_ENABLE(); GPIO_InitTypeDef gpioConfig = {0}; gpioConfig.Pin = LED_PIN; gpioConfig.Mode = GPIO_MODE_OUTPUT_PP; gpioConfig.Pull = GPIO_NOPULL; gpioConfig.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(LED_GPIO_PORT, &gpioConfig); } void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB buses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) { Error_Handler(); } } void Error_Handler(void) { __disable_irq(); while (1) { } } </syntaxhighlight> = Issues = * If "st-info" shows no device, then check if the usb wine is good * Stm32CubeIde does not work with none-original ST-Link device, error: [[Image:stm32cubeide-error.png|600px]] * If install old version of stm32cubeide, "“STM32CubeIDE is damaged and can’t be opened" <ref>https://community.st.com/t5/stm32cubeide-mcus/stm32cubeide-is-damaged-and-can-t-be-opened/td-p/256814</ref> [[Category:Stm32]] [[Category:ARM]] [[Category:ARM]]
返回
Stm32 led blink
。