当前位置:网站首页>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
边栏推荐
- Esbuild & SWC: a new generation of construction tools
- Shell 传递参数
- js凡客banner轮播图js特效
- resulttype和resultmap的区别和应用场景
- pytorch加载数据
- Jenkins basic knowledge ----- detailed explanation of 03pipeline code
- canvas切积木小游戏代码
- Remote Sensing Image Super-resolution and Object Detection: Benchmark and State of the Art
- 多态day02
- 暑期刷题-Day3
猜你喜欢

2022工作中遇到的问题四

3.1 rtthread 串口设备(V1)详解

Python implementation of maddpg - (1) openai maddpg environment configuration

StrError & PERROR use yyds dry inventory

IPv6 jobs

mysqldump数据备份

three.js网页背景动画液态js特效

Princeton University, Peking University & UIUC | offline reinforcement learning with realizability and single strategy concentration

OCR文字识别方法综述

Modeling specifications: naming conventions
随机推荐
3.1 rtthread 串口设备(V1)详解
StrError & PERROR use yyds dry inventory
Data and Introspection__ dict__ Attributes and__ slots__ attribute
电机控制反Park变换和反Clarke变换公式推导
Buuctf question brushing notes - [geek challenge 2019] easysql 1
Linear regression and logistic regression
Redis cache breakdown, cache penetration, cache avalanche
MADDPG的pythorch实现——(1)OpenAI MADDPG环境配置
MPLS experiment
pytorch加载数据
Modeling specifications: naming conventions
three.js网页背景动画液态js特效
How to choose PLC and MCU?
Getting started with applet cloud development - getting user search content
SD card reports an error "error -110 whilst initializing SD card
Analyze 菜单分析
The next industry outlet: NFT digital collection, is it an opportunity or a foam?
出现Permission denied的解决办法(750权限谨慎使用)
What are the principles of software design (OCP)
ASU & OSU | model based regularized off-line meta reinforcement learning