当前位置:网站首页>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
边栏推荐
- Four logs of MySQL server layer
- MADDPG的pythorch实现——(1)OpenAI MADDPG环境配置
- [padding] an error is reported in the prediction after loading the model weight attributeerror: 'model' object has no attribute '_ place‘
- 1、工程新建
- Getting started with applet cloud development - getting user search content
- js凡客banner轮播图js特效
- Derivation of anti Park transform and anti Clarke transform formulas for motor control
- 【RISC-V】外部中断
- How to do function test well
- Differences and application scenarios between resulttype and resultmap
猜你喜欢

Game theory matlab
![[concept] Web basic concept cognition](/img/27/14bcd73ca70d136436a4382a1b4bd1.jpg)
[concept] Web basic concept cognition

11. Container with the most water

Tomb. Weekly update of Finance (February 7 - February 13)
How to do function test well

JS regular filtering and adding image prefixes in rich text

2、GPIO相关操作

Overview of OCR character recognition methods

ASU & OSU | model based regularized off-line meta reinforcement learning
![[slam] lidar camera external parameter calibration (Hong Kong University marslab) does not need a QR code calibration board](/img/07/973722bf484b374f752177dfc48ef5.png)
[slam] lidar camera external parameter calibration (Hong Kong University marslab) does not need a QR code calibration board
随机推荐
Data and Introspection__ dict__ Attributes and__ slots__ attribute
Restful style
Game theory matlab
[risc-v] external interrupt
记录一下逆向任务管理器的过程
JS音乐在线播放插件vsPlayAudio.js
指针笔试题~走近大厂
Pytorch基础——(2)张量(tensor)的数学运算
Codeworks 5 questions per day (1700 average) - day 6
Pytorch load data
ArabellaCPC 2019(补题)
svg拖动点裁剪图片js特效
Distributed service framework dobbo
NR modulation 1
Deno介绍
银行核心业务系统性能测试方法
Esbuild & SWC: a new generation of construction tools
JS regular filtering and adding image prefixes in rich text
Four logs of MySQL server layer
施努卡:3d视觉检测应用行业 机器视觉3d检测