当前位置:网站首页>STM32 running lantern experiment - library function version
STM32 running lantern experiment - library function version
2022-07-03 09:56:00 【Yiao】
1. To write led.h file
#ifndef __LED_H
#define __LED_H
// If identifier __LED_H Not defined , Then define the identifier __LED_H,
void LED_Init(void);
#endif
3, To write led.c file
#include"led.h"
#include"stm32f4xx.h"
void LED_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOF, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOF, &GPIO_InitStructure);
GPIO_SetBits(GPIOF,GPIO_Pin_9 | GPIO_Pin_10);
}
4, Write the main function
#include "stm32f4xx.h"
#include "delay.h"
#include "led.h"
int main()
{
delay_init(168); // Delay function initialization
LED_Init(); //IO Mouth initialization
while(1)
{
GPIO_ResetBits(GPIOF,GPIO_Pin_9);
GPIO_SetBits(GPIOF,GPIO_Pin_10);
delay_ms(500);
GPIO_SetBits(GPIOF,GPIO_Pin_9);
GPIO_ResetBits(GPIOF,GPIO_Pin_10);
delay_ms(500);
}
}
边栏推荐
- Seven sorting of ten thousand words by hand (code + dynamic diagram demonstration)
- [Li Kou brush question notes (II)] special skills, module breakthroughs, classification and summary of 45 classic questions, and refinement in continuous consolidation
- 2020-08-23
- 我想各位朋友都应该知道学习的基本规律就是:从易到难
- NR PUCCH format0 sequence generation and detection mechanism
- 万字手撕七大排序(代码+动图演示)
- Blue Bridge Cup for migrant workers majoring in electronic information engineering
- A lottery like scissors, stone and cloth (C language)
- 手机都算是单片机的一种,只不过它用的硬件不是51的芯片
- [22 graduation season] I'm a graduate yo~
猜你喜欢
JMX、MBean、MXBean、MBeanServer 入门
Comment la base de données mémoire joue - t - elle l'avantage de la mémoire?
开学实验里要用到mysql,忘记基本的select语句怎么玩啦?补救来啦~
For new students, if you have no contact with single-chip microcomputer, it is recommended to get started with 51 single-chip microcomputer
When you need to use some functions of STM32, but 51 can't realize them, 32 naturally doesn't need to learn
Development of electrical fire system
Vector processor 9_ Basic multilevel interconnection network
NR PUCCH format0 sequence generation and detection mechanism
There is no specific definition of embedded system
[22 graduation season] I'm a graduate yo~
随机推荐
(1) 什么是Lambda表达式
应用最广泛的8位单片机当然也是初学者们最容易上手学习的单片机
Definition and use of enum in C language
(2)接口中新增的方法
2021-09-26
Nr-prach:prach format and time-frequency domain
Synchronization control between tasks
MYSQL数据库底层基础专栏
自動裝箱與拆箱了解嗎?原理是什麼?
Of course, the most widely used 8-bit single chip microcomputer is also the single chip microcomputer that beginners are most easy to learn
Successful graduation [2] - student health management system function development...
Matlab reads hexadecimal numbers and converts them into signed short
UCI and data multiplexing are transmitted on Pusch - placement of data and UCI positions (Part III)
Vector processor 9_ Basic multilevel interconnection network
Happy Dragon Boat Festival—— Zongzi written by canvas~~~~~
Project cost management__ Cost management technology__ Article 6 prediction
Project cost management__ Cost management technology__ Article 7 completion performance index (tcpi)
PIP references domestic sources
STM32 interrupt priority management
NR PUCCH format0 sequence generation and detection mechanism