一、GPIO介绍
-
IO数量及功能 关于esp8266的板子上的引脚,是这样子的,ESP芯片一共33个个引脚,其中包括电源,使能引脚、深度睡眠唤醒引脚、SPI引脚以及连接晶振和作为烧写Flash的引脚。所谓的GPIO(General-purpose input/output)引脚一共有17个,esp8266的SDK把其放进了一个枚举类型里。源码如下:
typedef enum { GPIO_NUM_0 = 0, /*!< GPIO0, input and output */ GPIO_NUM_1 = 1, /*!< GPIO1, input and output */ GPIO_NUM_2 = 2, /*!< GPIO2, input and output */ GPIO_NUM_3 = 3, /*!< GPIO3, input and output */ GPIO_NUM_4 = 4, /*!< GPIO4, input and output */ GPIO_NUM_5 = 5, /*!< GPIO5, input and output */ GPIO_NUM_6 = 6, /*!< GPIO6, input and output */ GPIO_NUM_7 = 7, /*!< GPIO7, input and output */ GPIO_NUM_8 = 8, /*!< GPIO8, input and output */ GPIO_NUM_9 = 9, /*!< GPIO9, input and output */ GPIO_NUM_10 = 10, /*!< GPIO10, input and output */ GPIO_NUM_11 = 11, /*!< GPIO11, input and output */ GPIO_NUM_12 = 12, /*!< GPIO12, input and output */ GPIO_NUM_13 = 13, /*!< GPIO13, input and output */ GPIO_NUM_14 = 14, /*!< GPIO14, input and output */ GPIO_NUM_15 = 15, /*!< GPIO15, input and output */ GPIO_NUM_16 = 16, /*!< GPIO16, input and output */ GPIO_NUM_MAX = 17, /** @endcond */ } gpio_num_t;
-
初始化函数及结构体 众所周知,想使用一个东西之前,一定要先把其初始化,如果是使用C语言,又要初始化一个比较多参数的东东,那估计就要用结构体了,ESP82666 GPIO的初始化函数是
esp_err_t gpio_config(const gpio_config_t * pGPIOConfig ) //参数是gpio_config_t 类型的指针
这个函数的返回值是esp_err_t,其值如果是ESP_OK就代表成功,如果是ESP_ERR_INVALID_ARG意思是参数错误,这个时候我们就要去检查一次参数了,参数是什么呢?参数是gpio_config_t 类型的指针
那我们再看一下gpio_config_t 的定义:
/** * @brief gpio_config函数的配置参数 */ typedef struct { uint32_t pin_bit_mask; /*!< 引脚: 32位的参数,每一位对应着一个GPIO*/ gpio_mode_t mode; /*!
关注打赏
最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?