一、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; /*!
关注打赏
热门博文
- 一键安装失败
- ROS1/ROS2版本代号
- ROS节点间话题通讯问题
- ROS机械臂启动碰撞检测和启动捡拾算法时出现的两个错误,有大佬能帮忙解决吗
- 树莓派4B(Pi buster)一键安装apt存在问题,WARNING: apt does not have a stable CLI interface
- 如何去掉Gazebo的不对某个关节进行碰撞属性
- Ubuntu18.04 realsenseD435i深度摄像头外参标定的问题
- 运行sudo apt-get install ros-foxy-rmf-demos-gz时出现软件包不能安装的问题
- 运行ros2 control指令提示 [RTPS_TRANSPORT_SHM Error] Failed init_port fastrtps_port
- setuptools-scm was unable to detect version for‘…/…/某git包‘