最近有个项目是需要用到esp32来做spi slave从机的,主机给从机发送数据,不过相对来说这方面的介绍就比较少了,仅仅只有例程可供参考。
在esp32的SDK中有spi slave的例程,但是这里注意的是,文件里面有两个目录,一个是sender,一个是recevier,然后根据和他们的FAE沟通和代码的注释,我才知道原来这个例程需要两块esp32的开发板,然后烧录两个不同的程序,就可以了。起初我不懂的时候问他们怎么解决,他们就这么回复我,说这样就可以了,晕死。
这里的代码仅仅是slave的代码,如下:
/* SPI Slave example, receiver (uses SPI Slave driver to communicate with sender)
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "freertos/queue.h"
#include "lwip/sockets.h"
#include "lwip/dns.h"
#include "lwip/netdb.h"
#include "lwip/igmp.h"
#include "esp_

本文介绍了使用ESP32作为SPI Slave的开发过程,包括硬件连接、软件配置及注意事项。通过实例代码展示了如何设置SPI Slave接口,并实现与SPI Master的数据交换。
最低0.47元/天 解锁文章
2173

被折叠的 条评论
为什么被折叠?



