spislave - SPI From machine#
Adapted Air601 Air101/Air103
Note
This page document is automatically generated by this file. If there is any error, please submit issue or help modify pr, thank you!
Tip
This library has its own demo,click this link to view spislave demo examples
Example
-- Please consult demo
-- Currently only supported by the XT804 series, such Air101/Air103/Air601
spislave.setup(id, opts)#
Initialize SPI Slave
Parameters
Incoming Value Type |
Explanation |
---|---|
int |
Slave SPI number, note the difference with SPI host number, this is related to specific equipment |
table |
opts Extended configuration parameters, currently no parameters |
Return Value
return value type |
explanation |
---|---|
boolean |
true Indicates success, other failures |
Examples
-- Currently only supported by the XT804 series, such Air101/Air103/Air601/Air690
-- Air101 For example, initialize SPI slave, number 2, SPI mode
spislave.setup(2)
-- Air101 For example, initialize SPI slave, number 3, SDIO mode
spislavve.setup(3)
spislave.ready(id)#
Whether writable
Parameters
Incoming Value Type |
Explanation |
---|---|
int |
Number of Slave SPI |
Return Value
return value type |
explanation |
---|---|
boolean |
true Indicates writable, others not writable |
Examples
None
spislave.on(id, cb)#
Register event callback function
Parameters
Incoming Value Type |
Explanation |
---|---|
int |
Number of Slave SPI |
function |
callback function |
Return Value
None
Examples
None
spislave.read(id, ptr, buff, len)#
Read data
Parameters
Incoming Value Type |
Explanation |
---|---|
int |
Number of Slave SPI |
userdata |
User data pointer, obtained from the callback function |
int |
zbuff buffer object |
int |
Read length, obtained from the callback function |
Return Value
return value type |
explanation |
---|---|
int |
The number of bytes read, usually the same length as the expected read |
int |
Error code, returned only when an error occurs |
Examples
None
spislave.write(id, ptr, buff, len)#
Write Data
Parameters
Incoming Value Type |
Explanation |
---|---|
int |
Number of Slave SPI |
userdata |
User data pointer, currently passing nil |
int |
zbuff buffer object |
int |
Write length, note that the hardware limit cannot be exceeded, usually 1500 bytes |
Return Value
return value type |
explanation |
---|---|
boolean |
true Indicates success, other failures |
int |
Error code, returned only when an error occurs |
Examples
None