Mikroelektronika MIKROE-724 データシート

ページ / 726
472
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
SPIx_Read
SPIx_Write
Prototype
sub function SPIx_Read(dim data_out as word) as word
Description Reads one word or byte (depending on mode set by init routines) from the SPI bus.
Parameters 
data_out
: dummy data for clock generation (see device Datasheet for SPI modules implementation 
details) 
Returns
Received data.
Requires
Routine requires at least one SPI module.
Used  SPI  module  must  be  initialized  before  using  this  function.  See  the  SPIx_Init  and  SPIx_Init_
Advanced routines.
Example
‘ read a byte from the SPI bus 
dim take, buffer as byte
...
take = SPI1_Read(buffer)
Notes
SPI library routines require you to specify the module you want to use. To select the desired SPI 
module, simply change the letter 
x in the routine prototype for a number from 1 to 3.
Number of SPI modules per MCU differs from chip to chip. Please, read the appropriate datasheet 
before utilizing this library.
Prototype
sub procedure SPIx_Write(dim data_out as word)
Description Writes one word or byte (depending on mode set by init routines) via the SPI bus.
Parameters 
data_out
: data to be sent 
Returns
Received data.
Requires
Routine requires at least one SPI module.
Used  SPI  module  must  be  initialized  before  using  this  function.  See  the  SPIx_Init  and  SPIx_Init_
Advanced routines.
Example
‘ write a byte to the SPI bus
dim buffer as byte
...
SPI1_Write(buffer)
Notes
SPI library routines require you to specify the module you want to use. To select the desired SPI 
module, simply change the letter 
x in the routine prototype for a number from 1 to 3.
Number of SPI modules per MCU differs from chip to chip. Please, read the appropriate datasheet 
before utilizing this library.