2.在“板管理器的附加链接”中 添加2行或中间加逗号
https://dl.espressif.com/dl/package_esp32_index.json
http://arduino.esp8266.com/stable/package_esp8266com_index.json
添加更多板型可看这个网址 https://github.com/arduino/Arduino/wiki/Unofficial-list-of-3rd-party-boards-support-urls
3.添加Arduino控制板,通过 工具>开发板>开发板管理器... 就可以打开 开发板管理器
4.在搜索栏输入型号 如esp32 点击安装
就可以选择相应的板子工作了
1、首先安装好esp32的开发板插件后,打开该插件。2、其次依次打开“工具”、“开发板”、“ESP32Arduino”。
3、最后在该列表中即可选择esp32的相关型号。
ESP32 芯片包含两个硬件定时器组。每组有两个通用硬件定时器。它们都是基于 16 位预分频器和 64 位自动重载功能的向上/向下计数器的 64 位通用定时器。
hw_timer_t * timerBegin(uint8_t num, uint16_t divider, bool countUp){}
参数:
返回值:
返回一个计时器结构体指针 hw_timer_t * ,我们预定义一个指针接收他
void timerEnd(hw_timer_t *timer)
参数:
void timerAttachInterrupt(hw_timer_t timer, void ( fn)(void), bool edge){}
参数:
void timerDetachInterrupt(hw_timer_t *timer)
void timerAlarmWrite(hw_timer_t *timer, uint64_t alarm_value, bool autoreload){}
参数:
void timerAlarmEnable(hw_timer_t *timer){}
参数:
void timerAlarmDisable(hw_timer_t *timer)
bool timerAlarmEnabled(hw_timer_t *timer)
ESP32有两个I2C控制器(也称为端口),负责处理两条I2C总线上的通信。每个I2C控制器都可以作为主机或从机运行。引脚21 默认的SDA, 引脚22是默认的SCL
IIC需要引入自带库 Wire.h Wire继承steam类 steam类有的他都有
void requestFrom(uint16_t address, uint8_t size, bool sendStop)
请求完成后 主机可以用 Wire.available() 和 Wire.read()() 等函数等待并获取从机的回答
参数:
void beginTransmission(int address)
随后, 主机可以使用 Wire.write()写数据并使用 Wire.endTransmission()结束传输
参数:
结束传输, 并释放IIC
返回值: uint8_t 类型
当作为主机时: 主机将要发送的数据加入发送队列
当作为从机时: 从机发送的数据给主机
参数:
返回值: byte类型
输入的字节数
返回接收到的字节数
返回值: byte类型
当作为主机时: 主机使用requestFrom()后 要使用此函数获取数据
当作为从机时: 从机读取主机给的数据
返回值: 读到的字节数据 byte
size_t readBytes(char *buffer, size_t length)
参数:
返回值: 数据长度
size_t readBytesUntil(char terminator, char *buffer, size_t length)
参数:
返回值: 数据长度
Wire.busy()
返回布尔值
继承自steam类, 个人感觉iic不会用到的
parseFloat
parseInt
find
findUntil
setTimeout
这些都是steam继承来的 大家灵活应用
从机有些函数和主机是一样的, 请看上一章节,本章节只有不一样的部分
Wire.begin(adress)//adress取值0~127
void onRequest(void (*)())
参数:
void onReceive(void (*)(int))
参数:
ESP32有四个SPI外设,分别为SPI0、SPI1、HSPI和VSPI。
SPI通讯流程如下:
SPI接口默认VSPI. 接口频率1 000 000, 数据默认采用MSBFIRST(低有效位优先), 时钟模式:SPI_MODE0(SCLK闲置为0, SCLK上升沿采样)
参数:
参数:
参数:
采用该函数,可以代替上面三个函数了.
参数:
结束SPI通信
参数:
返回值: 接收到的数据
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)