Page 113 of 346 Start Back Next End ZBasic System Library 101 ZBasic Microcontrollers DefineSPI Type Subroutine Invocation DefineSPI(clkPin, mosiPin, misoPin) Parameter Method Type Description clkPin ByVal Byte The pin to serve as the SPI clock signal (output). mosiPin ByVal Byte The pin to serve as the SPI MOSI signal (output). misoPin ByVal Byte The pin to serve as the SPI MISO signal (input). Discussion This subroutine is used to specify the clock and data pins to use for the software driven SPI implementation (sometimes known as a “bit banged” implementation). If the flags parameter to the OpenSPI subroutine requests software SPI, OpenSPI will initialize the specified pins (clkPin and mosiPin as output, misoPin as input) and set clkPin to the idle state specified by the flags parameter to OpenSPI. If software SPI is not requested, OpenSPI will initialize the hardware SPI controller according to the flags parameter to OpenSPI. It is important to be aware that the pin values set by DefineSPI are used by both the OpenSPI and SPICmd routines. This fact requires some extra attention if your application uses multiple SPI channels and two or more of them use the software-driven implementation. In such cases, you must ensure that the SPI pins have been correctly set by a prior call to DefineSPI before each call to OpenSPI and SPICmd. If your application uses just one channel with software SPI, a single call to DefineSPI will suffice and if it does not use software SPI at all then DefineSPI needn’t be called either. Compatibility This subroutine is not supported in BasicX mode nor it is supported on any VM mode ZX device. See Also CloseSPI, OpenSPI, OpenSPISlave, SPICmd, SPIGetByte, SPIPutByte, SPIGetData, SPIPutData, SPIStart, SPIStop