Mikroelektronika MIKROE-350 Fiche De Données

Page de 526
Soft_SPI_Read
Soft_SPI_Write
348
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6
Prototype
sub function Soft_SPI_Read(dim sdata as byteas word
Returns
Byte received via the SPI bus.
Description
This routine performs 3 operations simultaneously. It provides clock for the Soft-
ware SPI bus, reads a byte and sends a byte.
Parameters : 
sdata:
data to be sent. 
Requires
Soft SPI must be initialized before using this function. See Soft_SPI_Init routine.
Example
dim data_read as byte
data_send 
as byte
...
' Read a byte and assign it to data_read variable
' (data_send byte will be sent via SPI during the Read operation)
data_read = Soft_SPI_Read(data_send)
Prototype
sub procedure Soft_SPI_Write(dim sdata as byte)
Returns
Nothing.
Description
This routine sends one byte via the Software SPI bus.
Parameters : 
sdata:
data to be sent. 
Requires
Soft SPI must be initialized before using this function. See Soft_SPI_Init routine.
Example
' Write a byte to the Soft SPI bus
Soft_SPI_Write(0xAA)