-
大小: 1.95MB文件类型: .zip金币: 2下载: 1 次发布日期: 2023-10-03
- 语言: 其他
- 标签: esp8266 MQTT UART Smartconfig
资源简介
1、本例程所用的SDK版本:ESP8266_RTOS_SDK-1.4.x
2、创建MQTT任务,连接MQTT服务器,订阅(接收)和发布(发送)信息
3、具有UART发送和接收功能
4、具有Smartconfig功能,可通过按键和UART命令触发一键配置连接WIFI
代码片段和文件信息
/*
* ESPRSSIF MIT License
*
* Copyright (c) 2015
*
* Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only in which case
* it is free of charge to any person obtaining a copy of this software and associated
* documentation files (the “Software“) to deal in the Software without restriction including
* without limitation the rights to use copy modify merge publish distribute sublicense
* and/or sell copies of the Software and to permit persons to whom the Software is furnished
* to do so subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED “AS IS“ WITHOUT WARRANTY OF ANY KIND EXPRESS OR
* IMPLIED INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER LIABILITY WHETHER
* IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING FROM OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include “espressif/esp_common.h“
#include “freertos/portmacro.h“
#include “driver/gpio.h“
void gpio_config(GPIO_ConfigTypeDef *pGPIOConfig)
{
uint16 gpio_pin_mask = pGPIOConfig->GPIO_Pin;
uint32 io_reg;
uint8 io_num = 0;
uint32 pin_reg;
if (pGPIOConfig->GPIO_Mode == GPIO_Mode_Input) {
GPIO_AS_INPUT(gpio_pin_mask);
} else if (pGPIOConfig->GPIO_Mode == GPIO_Mode_Output) {
GPIO_AS_OUTPUT(gpio_pin_mask);
}
do {
if ((gpio_pin_mask >> io_num) & 0x1) {
io_reg = GPIO_PIN_REG(io_num);
if ((0x1 << io_num) & (GPIO_Pin_0 | GPIO_Pin_2 | GPIO_Pin_4 | GPIO_Pin_5)) {
PIN_FUNC_SELECT(io_reg 0);
} else {
PIN_FUNC_SELECT(io_reg 3);
}
if (pGPIOConfig->GPIO_Pullup) {
PIN_PULLUP_EN(io_reg);
} else {
PIN_PULLUP_DIS(io_reg);
}
if (pGPIOConfig->GPIO_Mode == GPIO_Mode_Out_OD) {
portENTER_CRITICAL();
pin_reg = GPIO_REG_READ(GPIO_PIN_ADDR(io_num));
pin_reg &= (~GPIO_PIN_DRIVER_MASK);
pin_reg |= (GPIO_PAD_DRIVER_ENABLE << GPIO_PIN_DRIVER_LSB);
GPIO_REG_WRITE(GPIO_PIN_ADDR(io_num) pin_reg);
portEXIT_CRITICAL();
} else if (pGPIOConfig->GPIO_Mode == GPIO_Mode_Sigma_Delta) {
portENTER_CRITICAL();
pin_reg = GPIO_REG_READ(GPIO_PIN_ADDR(io_num));
pin_reg &= (~GPIO_PIN_SOURCE_MASK);
pin_reg |= (0x1 << GPIO_PIN_SOURCE_LSB);
GPIO_REG_WRITE(GPIO_PIN_ADDR(io_num) pin_reg);
GPIO_REG_WRITE(GPIO_SIGMA_DELTA_ADDRESS SIGMA_DELTA_ENABLE);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-12-15 10:26 esp8266_mqtt_demo\
文件 3713 2016-12-14 16:04 esp8266_mqtt_demo\.cproject
目录 0 2016-12-14 18:10 esp8266_mqtt_demo\.output\
目录 0 2016-12-15 10:36 esp8266_mqtt_demo\.output\eagle\
文件 795 2016-12-14 15:36 esp8266_mqtt_demo\.project
目录 0 2016-12-15 10:36 esp8266_mqtt_demo\.settings\
文件 2990 2016-12-05 10:49 esp8266_mqtt_demo\Makefile
文件 358 2016-07-04 01:59 esp8266_mqtt_demo\airkiss.txt
目录 0 2016-12-14 18:10 esp8266_mqtt_demo\bin\
目录 0 2016-12-14 18:10 esp8266_mqtt_demo\bin\_temp_by_dltool\
目录 0 2016-12-14 18:10 esp8266_mqtt_demo\bin\_temp_by_dltool\downloadPanel1\
文件 28800 2016-07-19 10:49 esp8266_mqtt_demo\bin\_temp_by_dltool\downloadPanel1\eagle.flash.bin_rep
文件 5411488 2016-12-05 11:01 esp8266_mqtt_demo\bin\eagle.S
文件 1802448 2016-12-05 11:01 esp8266_mqtt_demo\bin\eagle.dump
文件 29152 2016-12-05 11:01 esp8266_mqtt_demo\bin\eagle.flash.bin
文件 290045 2016-12-05 11:01 esp8266_mqtt_demo\bin\eagle.irom0text.bin
目录 0 2016-12-14 18:10 esp8266_mqtt_demo\driver\
目录 0 2016-12-14 18:10 esp8266_mqtt_demo\driver\.output\
目录 0 2016-12-15 10:36 esp8266_mqtt_demo\driver\.output\eagle\
文件 1471 2016-07-04 01:59 esp8266_mqtt_demo\driver\Makefile
文件 7335 2016-07-18 11:43 esp8266_mqtt_demo\driver\gpio.c
文件 6868 2016-03-01 01:40 esp8266_mqtt_demo\driver\key.c
文件 15110 2016-12-05 10:59 esp8266_mqtt_demo\driver\uart.c
文件 3744 2016-07-04 01:59 esp8266_mqtt_demo\gen_misc.bat
文件 1122 2016-12-15 09:50 esp8266_mqtt_demo\gen_misc.sh
文件 3776 2016-07-14 08:41 esp8266_mqtt_demo\gen_misc_bak.sh
目录 0 2016-12-14 18:10 esp8266_mqtt_demo\include\
文件 1378 2015-11-15 01:18 esp8266_mqtt_demo\include\dmsg.h
目录 0 2016-12-14 18:10 esp8266_mqtt_demo\include\driver\
文件 9922 2016-09-28 09:14 esp8266_mqtt_demo\include\driver\gpio.h
文件 688 2016-03-01 01:40 esp8266_mqtt_demo\include\driver\key.h
............此处省略65个文件信息
- 上一篇:易用API伴侣EAPI
- 下一篇:EN2T的ModbusTCP例程+说明文档
相关资源
- Quartus II 15.0中仿真DDR2 IP核
- STM32F042F6P6 Uart12DMA;发送中断接收
- uart_tx.zip
- STM32F407 串口配置 串口1~6 六串口同时
- STM32F407_6个串口同时使用的代码
- MQTT_3.1protocol_Specific中文版
- s7epasrvx.exe CP2102_USB_to_UART_Bridge_Contro
- CP210x UsbToUART win7 64 bit
- esp8266 win10驱动 cp2102
- quartus 11.0 破解包 全
- CSDN文件---ESP8266.rar
- Quartusii十字交叉路口三色交通灯设计
- stm32103c8t6ESP8266串口转WIFI模块TCP服务器
- ESP8266ESP8266安卓控制端源代码
- 中值滤波算法Quartus实现
- springmvc+Mybatis+axis2+webservice+quartz作业整
- VHDL简易交通灯设计 quartus 2
- quartus14.1破解包
- 基于quartus II的VHDL数字钟设计
- MQTTv3.1中文版
- mt7628 mqtt功能 放到packet下面就可以使
- nudemcu相关工具和固件测试稳定
- MQTT-1.zip
- 单片机通过ESP8266上传温湿度数据
- STM32F407ZG_ESP8266例程
- ESP8266最新稳定版固件
- ESP8266AP模式控制51单片机亮灯.docx
- STM32F103C8T6与MQTT通信的源码
- ESP8266使用MQTT协议连接阿里云
- 贝壳物联arduino esp8266 demo版本
评论
共有 条评论