ESP32 IDF Development Driver Chapter 5 GPIO and External Interrupt Explanation

ESP32 IDF Development Driver Chapter 5 GPIO and External Interrupt Explanation 1 Introduction 2. Principle 3. Related functions 4. Software design 5. Example analysis 6. The following are the debugging results: Don’t get lost-Navigation bar Quickly navigate to find what you want (article directory) If this article is useful to you, please like and save […]

ESP32-Peripheral GPIO information

Easy to use Make IO2 output high and low levels #include “driver/gpio.h” #define LED GPIO_NUM_2 gpio_reset_pin(LED); // Clear GPIO default state gpio_set_direction(LED, GPIO_MODE_OUTPUT); // GPIO output mode while(1) {<!– –> //vTaskDelay(1000 / portTICK_PERIOD_MS); //delay gpio_set_level(LED, 0); // Output low level //vTaskDelay(1000 / portTICK_PERIOD_MS); //delay gpio_set_level(LED, 1); // Output low level } GPIO configuration structure //ESP32 […]

STM32 GPIO input – key detection

Main function code /** *************************************************** **************************** * @file main.c * @author fire * @version V1.0 * @date 2015-xx-xx * @brief Use buttons to control lanterns *************************************************** **************************** * @attention * * Experimental platform: Wildfire STM32 F429 development board * Forum: http://www.firebbs.cn * Taobao: https://fire-stm32.taobao.com * *************************************************** **************************** */ #include “stm32f4xx.h” #include “./led/bsp_led.h” #include “./key/bsp_key.h” /** […]

IMX6ULL–GPIO

Purpose of this chapter: Use GPIO to light up an LED light 1.LED principle (1) LED type: pin LED; SMD LED. (2) LED lighting circuit Method 1: Method 2: We use the second method in this chapter, using the GPIO pin of IMX6ULL to output high and low levels to control the LED to light […]

[Driver development] Register character device and use gpio device tree node to control the on and off of three LED lights

Register character device and use gpio device tree node to control the on and off of three LED lights Device tree: Header file: #ifndef __HEAD_H__ #define __HEAD_H__ typedef struct { unsigned int MODER; unsigned int OTYPER; unsigned int OSPEEDR; unsigned int PUPDR; unsigned int IDR; unsigned int ODR; } gpio_t; #define PHY_LED1_ADDR 0X50006000 #define PHY_LED2_ADDR […]

Based on the platform driver model, the LED driver is written through the (gpiod_get_from_of_node) function.

pdri.ko #include <linux/init.h> #include <linux/module.h> #include <linux/platform_device.h> #include <linux/mod_devicetable.h> #include <linux/of.h> #include <linux/of_gpio.h> struct resource *res; unsigned int irq1; struct gpio_desc *gpiono1; struct gpio_desc *gpiono2; struct gpio_desc *gpiono3; struct platform_device *pdev1; struct class *cls; struct device *dev; int major; char kbuf[128] = {0}; //Define operation method int mycdev_open(struct inode *inode, struct file *file) { printk(“%s:%s:%d\ […]

Register the character device and use the gpio device tree node to control the on and off of the three LED lights.

head.h #define LED_ON _IOW(‘l’,1,int *) #define LED_OFF _IOW(‘l’,0,int *) text.c #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <fcntl.h> #include <unistd.h> #include <string.h> #include “head.h” int main(int argc,const char * argv[]) { int a; int b; while(1) { int fd; //Get the function we want to implement from the interrupt printf(“Please select the lights […]

Three methods to control GPIO under Linux

https://blog.csdn.net/qq_41076734/article/details/124669908 1. Application space control gpio 1.1 Introduction There is an export file under /sys/class/gpio/. Write the GPIO number to be operated into the export file, so that the operation interface of the GPIO is exposed from the kernel space to the user space. The operation interface of the GPIO includes direction and value, direction, […]

Programming LED lights based on GPIO subsystem

#include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <fcntl.h> #include <unistd.h> #include <string.h> // Construct the function code to turn the lights on and off #define LED_ON _IOW(‘l’, 1,int) #define LED_OFF _IOW(‘l’, 0,int) int main(int argc, char const *argv[]) { char buf[128] = {0}; int a, b; int fd; while (1) { […]

gpio simulates spi read and write register sample code

gpio simulation spi communication sample code (Hisilicon HI3531DV200 platform) When reading, write a 32-bit address and read a 32-bit data. The highest bit of the address is 1. When writing, a 32-bit address, a 32-bit data, the highest bit of the address is 0 Transmitting and receiving order: high byte first #include <stdio.h> #include <sys/types.h> […]