stop:boolean. true will send a stop message, releasing the bus after transmission. false will send a restart, keeping the IIC connection
active.
onReceive() Description: 8. onReceive()
Function: Registers an event to be triggered when a slave device receives a transmission from a master.
Grammar: Wire.onReceive(handler)
Parameter:
handler:the event to be triggered when the slave receives data; this should take a single int parameter (the number of bytes read
from the master) and return nothing, e.g.: void myHandler(int numBytes)
onRequest(handler)
Description: Register an event to be triggered when a master requests data from this slave device. Grammar: Wire.onRequest(handler)
Parameter:
handler:the event to be triggered, takes no parameters and returns nothing, e.g.: void myHandler()
8.6 SPI
SPI Pin
ESP32 has four SPI peripherals: SPI0,SPI1, HSPI and VSPI.
1. SPI0 is used for flash cache, and ESP32 maps the attached SPI flash device to memory.
2. SPI1 and SPI0 share one hardware line, SPI1 is used to write flash chip.
3. HSPI and VSPI can be used arbitrarily.
4. SPI1, HSPI and VSPI have three chip selection lines, so as SPI host, ESP32 is allowed to drive up to three SPI devices.
begin()
Description: initialize SPI communication. after calling this function, SCK.MOSI, and SS pins will be set to the output mode, and the SCK and