当前位置:网站首页>2.2 STM32 GPIO operation
2.2 STM32 GPIO operation
2022-07-06 03:24:00 【rou252051452】
1、 summary
By program PIN Device input , Output , Interruption, etc .
2、 Input
3、 Output

4、 interrupt

4、 Test functions
/**
1、 Output :
1) Use the button of Polaris on the punctual atomic development board LED0(PB1) and LED1(PB0) As the output IO test .
2) After the button is pressed ,LED0 bright
3) After the button is released ,LED0 destroy
2、 Input :
1) Use the button of Polaris on the punctual atomic development board KEY0(PH3) Test as input
2) After the button is pressed ,LED0 bright
3) After the button is released ,LED0 destroy
3、 interrupt :
1) Use the button of Polaris on the punctual atomic development board KEY1(PH2) As interrupt input
2) After the button is pressed ,LED1 bright
3) After the button is released ,LED1 destroy
**/
#include "rtthread.h"
#include "board.h"
// The macro definition obtains the pin number .
#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()
{
// adopt API Get pin number
KEY0 = rt_pin_get("PH.3");
KEY2 = rt_pin_get("PC.13");
// Set pin mode
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);
// test LED Lamp output
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);
}
// Interrupt callback function binding
rt_pin_attach_irq(KEY2, PIN_IRQ_MODE_RISING_FALLING, exti_callback, RT_NULL);
// Interrupt enable
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)
Complete the project
边栏推荐
- 【概念】Web 基础概念认知
- Cross origin cross domain request
- Image super-resolution using deep convolutional networks(SRCNN)解读与实现
- Pelosi: Congress will soon have legislation against members' stock speculation
- Brush questions in summer -day3
- 银行核心业务系统性能测试方法
- 深入刨析的指针(题解)
- MPLS experiment
- Audio-AudioRecord Binder通信机制
- pytorch加载数据
猜你喜欢

Getting started with applet cloud development - getting user search content
![[slam] orb-slam3 parsing - track () (3)](/img/87/b580837778c2c9f6bac5ba49403d6b.png)
[slam] orb-slam3 parsing - track () (3)

Research on cooperative control of industrial robots

Tomb. Weekly update of Finance (February 7 - February 13)

IPv6 comprehensive experiment
![[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

The real machine cannot access the shooting range of the virtual machine, and the real machine cannot Ping the virtual machine

遥感图像超分辨重建综述

svg拖动点裁剪图片js特效

ESBuild & SWC浅谈: 新一代构建工具
随机推荐
Résumé des méthodes de reconnaissance des caractères ocr
[concept] Web basic concept cognition
C language judgment, ternary operation and switch statement usage
Data and Introspection__ dict__ Attributes and__ slots__ attribute
遥感图像超分辨率论文推荐
Map sorts according to the key value (ascending plus descending)
Redis cache breakdown, cache penetration, cache avalanche
three.js网页背景动画液态js特效
Overview of OCR character recognition methods
Linear regression and logistic regression
Advanced learning of MySQL -- Fundamentals -- isolation level of transactions
SD卡报错“error -110 whilst initialising SD card
【Rust 笔记】18-宏
Leetcode problem solving -- 99 Restore binary search tree
银行核心业务系统性能测试方法
Yyds dry inventory what is test driven development
Audio-AudioRecord Binder通信机制
Redo file corruption repair
BUUCTF刷题笔记——[极客大挑战 2019]EasySQL 1
Some problem records of AGP gradle