当前位置:网站首页>2.2 fonctionnement stm32 GPIO
2.2 fonctionnement stm32 GPIO
2022-07-06 03:24:00 【Rou252051452】
1、Généralités
Par procédurePINEntrée de l'appareil,Produits,Travaux de vérification interrompus, etc..
2、Entrée
3、Produits
4、Interruption
4、Fonction d'essai
/**
1、Produits:
1)Utilisez le bouton Polaris pour développer le tableauLED0(PB1)EtLED1(PB0)Comme sortieIOTests.
2)Après avoir appuyé sur le bouton,LED0Lumière.
3)Après le relâchement du bouton,LED0éteint.
2、Entrée:
1)Utilisez le bouton Polaris pour développer le tableauKEY0(PH3)Détecter comme entrée
2)Après avoir appuyé sur le bouton,LED0Lumière.
3)Après le relâchement du bouton,LED0éteint.
3、Interruption:
1)Utilisez le bouton Polaris pour développer le tableauKEY1(PH2)Comme entrée d'interruption
2)Après avoir appuyé sur le bouton,LED1Lumière.
3)Après le relâchement du bouton,LED1éteint.
**/
#include "rtthread.h"
#include "board.h"
// Macro - définition pour obtenir le numéro pin .
#define LED0 GET_PIN(B,1)
#define LED1 GET_PIN(B,0)
static rt_uint32_t KEY0 = 0;
static rt_uint32_t KEY2 = 0;
void exti_callback()
{
if(rt_pin_read(KEY2) == PIN_LOW)
{
rt_pin_write(LED1, PIN_LOW);
}
else
{
rt_pin_write(LED1, PIN_HIGH);
}
}
void example_gpio()
{
//AdoptionAPI Obtenir le numéro pin
KEY0 = rt_pin_get("PH.3");
KEY2 = rt_pin_get("PC.13");
// Régler le mode pin
rt_pin_mode(LED0, PIN_MODE_OUTPUT);
rt_pin_mode(LED1, PIN_MODE_OUTPUT);
rt_pin_mode(KEY0, PIN_MODE_INPUT_PULLUP);
rt_pin_mode(KEY2, PIN_MODE_INPUT_PULLUP);
//TestsLEDSortie de la lampe
for(rt_int8_t i = 0; i<5 ; i++)
{
rt_pin_write(LED0, PIN_LOW);
rt_pin_write(LED1, PIN_LOW);
rt_thread_delay(500);
rt_pin_write(LED0, PIN_HIGH);
rt_pin_write(LED1, PIN_HIGH);
rt_thread_delay(500);
}
// Interrompre la liaison de la fonction de rappel
rt_pin_attach_irq(KEY2, PIN_IRQ_MODE_RISING_FALLING, exti_callback, RT_NULL);
//Activer l'interruption
rt_pin_irq_enable(KEY2, PIN_IRQ_ENABLE);
while(1)
{
if(rt_pin_read(KEY0) == PIN_LOW)
{
rt_pin_write(LED0, PIN_LOW);
}
else
{
rt_pin_write(LED0, PIN_HIGH);
}
rt_thread_delay(200);
}
}
MSH_CMD_EXPORT(example_gpio, example_gpio)
Travaux complets
边栏推荐
- Leetcode problem solving -- 108 Convert an ordered array into a binary search tree
- XSS challenges bypass the protection strategy for XSS injection
- SD卡报错“error -110 whilst initialising SD card
- February 14, 2022 Daily: Google long article summarizes the experience of building four generations of TPU
- OCR文字识别方法综述
- Pytorch load data
- 八道超经典指针面试题(三千字详解)
- Research on cooperative control of industrial robots
- 电机控制反Park变换和反Clarke变换公式推导
- [pointer training - eight questions]
猜你喜欢
随机推荐
Item 10: Prefer scoped enums to unscoped enums.
Linear regression and logistic regression
February 14, 2022 Daily: Google long article summarizes the experience of building four generations of TPU
MPLS experiment
SD卡報錯“error -110 whilst initialising SD card
银行核心业务系统性能测试方法
Buuctf question brushing notes - [geek challenge 2019] easysql 1
My C language learning record (blue bridge) -- under the pointer
Modeling specifications: naming conventions
Audio audiorecord binder communication mechanism
resulttype和resultmap的区别和应用场景
Exness foreign exchange: the governor of the Bank of Canada said that the interest rate hike would be more moderate, and the United States and Canada fell slightly to maintain range volatility
Getting started with applet cloud development - getting user search content
Record the process of reverse task manager
Distributed service framework dobbo
2.1 rtthread pin设备详解
Leetcode problem solving -- 98 Validate binary search tree
. Net 6 and Net core learning notes: Important issues of net core
【概念】Web 基础概念认知
Leetcode problem solving -- 99 Restore binary search tree