User manual

mikroPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
456
Soft_SPI_Init
Prototype
procedure Soft_SPI_Init();
Description Routine initializes the software SPI module.
Parameters None.
Returns Nothing.
Requires Global variables:
- SoftSpi_SDI: Data in line
- SoftSpi_SDO: Data out line
- SoftSpi_CLK: Data clock line
- SoftSpi_SDI_Direction: Direction of the Data in pin
- SoftSpi_SDO_Direction: Direction of the Data out pin
- SoftSpi_CLK_Direction: Direction of the Data clock pin
must be dened before using this function.
Example
// Software SPI module connections
var SoftSpi_SDI : sbit at RF2_bit;
var SoftSpi_SDO : sbit at LATF3_bit;
var SoftSpi_CLK : sbit at LATF6_bit;
var SoftSpi_SDI_Direction : sbit at TRISF2_bit;
var SoftSpi_SDO_Direction : sbit at TRISF3_bit;
var SoftSpi_CLK_Direction : sbit at TRISF6_bit;
// End Software SPI module connections
...
Soft_SPI_Init(); // Init Soft_SPI
Notes None.
Soft_SPI_Read
Prototype
function Soft_SPI_Read(data_ : byte) : byte;
Description This routine performs 3 operations simultaneously. It provides clock for the Software SPI bus, reads
a byte and sends a byte.
Parameters - sdata: data to be sent.
Returns Byte received via the SPI bus.
Requires Soft SPI must be initialized before using this function. See Soft_SPI_Init routine.
Example
var data_read, data_send : 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);
Notes None