当前位置:网站首页>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
边栏推荐
- XSS challenges bypass the protection strategy for XSS injection
- The solution of permission denied (750 permissions should be used with caution)
- 适合程序员学习的国外网站推荐
- 深入刨析的指针(题解)
- Eight super classic pointer interview questions (3000 words in detail)
- Redis cache breakdown, cache penetration, cache avalanche
- Inherit day01
- IPv6 jobs
- Daily question brushing plan-2-13 fingertip life
- Pelosi: Congress will soon have legislation against members' stock speculation
猜你喜欢
Linear programming matlab
svg拖动点裁剪图片js特效
XSS challenges bypass the protection strategy for XSS injection
pytorch加载数据
3.1 rtthread 串口设备(V1)详解
canvas切积木小游戏代码
Force buckle 1189 Maximum number of "balloons"
Pytorch基础——(1)张量(tensor)的初始化
Teach you to build your own simple BP neural network with pytoch (take iris data set as an example)
Selenium share
随机推荐
Lua uses require to load the shared library successfully, but the return is Boolean (always true)
Precautions for single chip microcomputer anti reverse connection circuit
多态day02
Audio audiorecord binder communication mechanism
jsscript
OCR文字識別方法綜述
Distributed service framework dobbo
Daily question brushing plan-2-13 fingertip life
SAP ALV单元格级别设置颜色
MPLS experiment
The solution of permission denied (750 permissions should be used with caution)
three.js网页背景动画液态js特效
适合程序员学习的国外网站推荐
OCR文字识别方法综述
SWC介绍
Tidb ecological tools (backup, migration, import / export) collation
Advanced learning of MySQL -- Fundamentals -- isolation level of transactions
How to do function test well
手写数据库客户端
教你用Pytorch搭建一个自己的简单的BP神经网络( 以iris数据集为例 )