Library_spi
// #include "http://www.byvac.com//mBlib/flb/Library/2016/lib_spi.bas"
SPI
Serial Peripheral Interface.
BV500 Hardware
// Data out SDO1 is RB13
// Data in SDI1 is RB8
// Clock SCK1 is RB14
BV513,BV514,BV523 Hardware (MX3) Channel 2 implemented
On this hardware SPI channel 2 is already initialised and so spi_init() will simply set the speed, the default initialised speed is 10 MHz.
// Data out SDO2 is RG8 (MOSI)
// Data in SDI2 is RG7 (MISO)
// Clock SCK2 is RG6
// Initialises the SPI bus, speed is in HZ, for 10MHz the speed value will be 10000000
spi_init(speed) // for 8 bits serial
spi_init16(speed) // for 16 bits serial
spi_init32(speed) // for 32 bits serial
Transfers data, with the SPI interface data is transferred in and out at the same time, by convention id just receiving is required the output byte is normally set to 0xff
spi_data(value)
Example: x = spi_data(0xff) // gets a byte from the SPI bus
spi_data(0x33) // send 0x33 to the SPI bus