Difference between revisions of "Component: SPI Master (Comms: Interface)"
(19 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {| style="width:50%" | |
− | |||
− | {| | ||
|- | |- | ||
− | | width="20%" style="color: gray;" | Author | + | | width="20%" style="color:gray;" | Author |
| Matrix Ltd | | Matrix Ltd | ||
|- | |- | ||
− | | width="20%" style="color: gray;" | Version | + | | width="20%" style="color:gray;" | Version |
− | | 1 | + | | 2.1 |
|- | |- | ||
− | | width="20%" style="color: gray;" | Category | + | | width="20%" style="color:gray;" | Category |
| Comms: Interface | | Comms: Interface | ||
|} | |} | ||
+ | ==SPI Master component== | ||
+ | Low level routines for controlling or interacting with an SPI interface. SPI or Serial Peripheral Interface is a bus used for board level communications between devices. A target microcontroller will usually have at least one hardware SPI peripheral built in. If the hardware SPI pins are in use or more SPI channels are required then there is also a software mode available. | ||
− | == | + | ==Component Source Code== |
− | |||
− | |||
− | |||
− | |||
+ | Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_SPI_Master.fcfx FC_Comp_Source_SPI_Master.fcfx] | ||
+ | |||
+ | Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_SPI_Master.fcfx FC_Comp_Source_SPI_Master.fcfx] | ||
==Detailed description== | ==Detailed description== | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | ===Overview=== | |
− | + | The SPI bus is a high speed communications bus which is usually best suited for talking between devices situated on the same circuit board. Due to the high frequency digital nature of the bus care should be taken to keep tracks as short as possible and as far away as possible from other sources of noise. A typical SPI bus consists of four signals, chip select, data out, data in and clock. The SPI bus usually consists of a single master device and then one or more slave devices. | |
+ | As the data out and data in signals are subjective in terms of who is sending and receiving the data there are alternate names to help clarify the connection. | ||
− | + | Data out (SDO) is also known as MOSI which stands for Master Out Slave In. | |
− | |||
− | + | Data in (SDI) is also known as MISO which stands for Master In Slave Out. | |
− | + | Each SPI transaction consists of a byte made up of 8 clock cycles allowing the 8-bits of the byte to be transferred. | |
− | + | [[File:SPI_Bytes.jpg]] | |
− | + | ===Chip Select CS / Slave Select SS=== | |
− | : | + | Each device connected to the SPI bus connects in parallel to the main three SPI pins: data out, data in and clock. The fourth pin the CS pin must be unique for every SPI device present on the bus allowing only one device to be addressed at any one time. As every slave device on the SPI bus requires a individual CS signal from the SPI Master a good way of adding more devices without consuming more of the pins of the SPI master is to use things like 3 to 8 pin multiplexer ICs. The CS signal activates the slave device when pulled low and disables the slave device when pulled high. |
+ | Adding a pull up resistor of around 10K - 100K between the CS signal and VCC allows the SPI slave device to be disabled whenever the Microcontroller is not ready to perform the functionality of the SPI master e.g. during reprogramming or when the device is held in reset. | ||
− | |||
− | |||
− | + | ===Three Wire SPI=== | |
− | + | Three wire SPI is a version of SPI where the master can send data to the slave device but cannot read any data back for example a DAC or graphical LCD. | |
− | + | ===Four Wire SPI=== | |
− | + | Four wire SPI is the complete version of SPI where the master can sent data to the device and receive data back from the device. A single SPI operation simultaneously transfers a byte from the master to the slave via the MOSI signal and also a byte from the slave to the master via the MISO signal. Normally only one of these bytes is meaningful so it's down to the protocol of the slave device as to how to perform writes and reads. | |
+ | ==Examples== | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | More information on SPI can be found here, | |
− | |||
− | + | [http://www.matrixtsl.com/blog/simplified-communications-i%c2%b2c-and-spi/ Matrix Flowcode Blog: Simplified communications I2C and SPI] | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | ==Macro reference== | |
− | + | ===Disable_CS=== | |
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Disable_CS''' | ||
+ | |- | ||
+ | | colspan="2" | Outputs a high signal to the chip select pin to deselect the remote slave device. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
− | |||
− | + | ===Enable_CS=== | |
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Enable_CS''' | ||
+ | |- | ||
+ | | colspan="2" | Outputs a low signal to the chip select pin to select the remote slave device. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
− | |||
− | + | ===GetByteArray=== | |
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetByteArray''' | ||
+ | |- | ||
+ | | colspan="2" | Attempts to read an array of bytes from the SPI bus. Similar to the GetString component macro but allows the value 0. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | NumBytes | ||
+ | |- | ||
+ | | colspan="2" | Number of bytes to read | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Data | ||
+ | |- | ||
+ | | colspan="2" | Byte Array to Assign Data to. | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
− | |||
− | + | ===GetChar=== | |
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetChar''' | ||
+ | |- | ||
+ | | colspan="2" | General purpose SPI get byte macro | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
− | |||
− | + | ===GetString=== | |
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetString''' | ||
+ | |- | ||
+ | | colspan="2" | Attempts to read a string of bytes from the SPI bus. Not compatible with NULL values. String variable needs to be at least (NumBytes + 1) in length to store NULL terminator. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | NumBytes | ||
+ | |- | ||
+ | | colspan="2" | Number of bytes to read into the string, string array length must be at least +1 | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
− | |||
− | + | ===Initialise=== | |
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise''' | ||
+ | |- | ||
+ | | colspan="2" | Activates the SPI peripheral and claims control over the I/O pins. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
− | |||
− | + | ===SendByteArray=== | |
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendByteArray''' | ||
+ | |- | ||
+ | | colspan="2" | Sends a an array of bytes to the SPI bus. Similar to the SendString component macro but allows the value 0. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u16-icon.png]] - UINT | ||
+ | | width="90%" | NumBytes | ||
+ | |- | ||
+ | | colspan="2" | Number of bytes to write | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Data | ||
+ | |- | ||
+ | | colspan="2" | Byte Array to Send Data from. | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
− | |||
− | Data | + | ===SendChar=== |
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendChar''' | ||
+ | |- | ||
+ | | colspan="2" | General purpose SPI send byte macro | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | Char | ||
+ | |- | ||
+ | | colspan="2" | Data byte to send | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
− | |||
− | + | ===SendString=== | |
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendString''' | ||
+ | |- | ||
+ | | colspan="2" | Sends a string of bytes to the SPI bus. Not compatible with NULL values. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING | ||
+ | | width="90%" | Str | ||
+ | |- | ||
+ | | colspan="2" | Data string to send out. | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
− | |||
− | + | ===Transaction=== | |
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Transaction''' | ||
+ | |- | ||
+ | | colspan="2" | Allows simultaneous two way communications, send and receive, | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | DataOut | ||
+ | |- | ||
+ | | colspan="2" | Data Byte to send out | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
− | |||
− | + | ===TransactionArray=== | |
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''TransactionArray''' | ||
+ | |- | ||
+ | | colspan="2" | Allows simultaneous two way communications, send and receive multiple times. DataOut is used to store data to be transmitted. DataIn is used to store received data. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | DataOut | ||
+ | |- | ||
+ | | colspan="2" | Data Bytes to send out | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | DataIn | ||
+ | |- | ||
+ | | colspan="2" | Data Bytes received | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE | ||
+ | | width="90%" | NumBytes | ||
+ | |- | ||
+ | | colspan="2" | Number of bytes to send and receive | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
− | |||
− | + | ===UnInitialise=== | |
+ | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]] | ||
+ | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''UnInitialise''' | ||
+ | |- | ||
+ | | colspan="2" | Deactivates the SPI peripheral leaving the I/O pins in a state where they can be used for general purpose I/O. | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID | ||
+ | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
+ | |} | ||
− | |||
− | + | ==Property reference== | |
− | + | {| class="wikitable" style="width:60%; background-color:#FFFFFF;" | |
− | + | |- | |
− | + | | width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]] | |
− | + | | width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties''' | |
− | + | |- | |
− | + | |- | |
− | + | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]] | |
− | + | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Connections | |
− | + | |- | |
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]] | ||
+ | | width="90%" | Channel | ||
+ | |- | ||
+ | | colspan="2" | SPI Channel selector | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]] | ||
+ | | width="90%" | MOSI | ||
+ | |- | ||
+ | | colspan="2" | SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode. | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]] | ||
+ | | width="90%" | MISO | ||
+ | |- | ||
+ | | colspan="2" | SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode. | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]] | ||
+ | | width="90%" | CLK | ||
+ | |- | ||
+ | | colspan="2" | SPI Clock Pin CLK - The Clock signal is driven by the SPI master. | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-7-icon.png]] | ||
+ | | width="90%" | Use Auto CS | ||
+ | |- | ||
+ | | colspan="2" | Allow the SPI component to manage the CS pin for us in Master mode. On initialise the CS pin is automatically set high to disable the remote SPI device. | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-5-icon.png]] | ||
+ | | width="90%" | CS / SS | ||
+ | |- | ||
+ | | colspan="2" | Chip Select / Slave Select Pin Master Mode: General purpose output pin used to select the remote SPI device. Slave Mode: Hardware chip select pin input used to select the SPI device. | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]] | ||
+ | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Bus Settings | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]] | ||
+ | | width="90%" | Prescale | ||
+ | |- | ||
+ | | colspan="2" | Prescale option selector | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]] | ||
+ | | width="90%" | Clock Phase | ||
+ | |- | ||
+ | | colspan="2" | Clock Phase (data change edge) selection | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]] | ||
+ | | width="90%" | Clock Polarity | ||
+ | |- | ||
+ | | colspan="2" | Clock Polarity setting, inactive (idle) state | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]] | ||
+ | | width="90%" | Sample Point | ||
+ | |- | ||
+ | | colspan="2" | Data bit read sample point | ||
+ | |- | ||
+ | | width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]] | ||
+ | | width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation | ||
+ | |- | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-10-icon.png]] | ||
+ | | width="90%" | Label | ||
+ | |- | ||
+ | | colspan="2" | Label used to identify the component on the panel. | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-7-icon.png]] | ||
+ | | width="90%" | Scope Traces | ||
+ | |- | ||
+ | | colspan="2" | Selects if the scope traces are automatically generated or not | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-7-icon.png]] | ||
+ | | width="90%" | Console Data | ||
+ | |- | ||
+ | | colspan="2" | Selects if the console data is automatically generated or not | ||
+ | |- | ||
+ | | width="10%" align="center" | [[File:Fc9-type-16-icon.png]] | ||
+ | | width="90%" | API | ||
+ | |- | ||
+ | | colspan="2" | | ||
+ | |} |
Latest revision as of 13:32, 17 May 2023
Author | Matrix Ltd |
Version | 2.1 |
Category | Comms: Interface |
Contents
SPI Master component
Low level routines for controlling or interacting with an SPI interface. SPI or Serial Peripheral Interface is a bus used for board level communications between devices. A target microcontroller will usually have at least one hardware SPI peripheral built in. If the hardware SPI pins are in use or more SPI channels are required then there is also a software mode available.
Component Source Code
Please click here to download the component source project: FC_Comp_Source_SPI_Master.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_SPI_Master.fcfx
Detailed description
Overview
The SPI bus is a high speed communications bus which is usually best suited for talking between devices situated on the same circuit board. Due to the high frequency digital nature of the bus care should be taken to keep tracks as short as possible and as far away as possible from other sources of noise. A typical SPI bus consists of four signals, chip select, data out, data in and clock. The SPI bus usually consists of a single master device and then one or more slave devices.
As the data out and data in signals are subjective in terms of who is sending and receiving the data there are alternate names to help clarify the connection.
Data out (SDO) is also known as MOSI which stands for Master Out Slave In.
Data in (SDI) is also known as MISO which stands for Master In Slave Out.
Each SPI transaction consists of a byte made up of 8 clock cycles allowing the 8-bits of the byte to be transferred.
Chip Select CS / Slave Select SS
Each device connected to the SPI bus connects in parallel to the main three SPI pins: data out, data in and clock. The fourth pin the CS pin must be unique for every SPI device present on the bus allowing only one device to be addressed at any one time. As every slave device on the SPI bus requires a individual CS signal from the SPI Master a good way of adding more devices without consuming more of the pins of the SPI master is to use things like 3 to 8 pin multiplexer ICs. The CS signal activates the slave device when pulled low and disables the slave device when pulled high.
Adding a pull up resistor of around 10K - 100K between the CS signal and VCC allows the SPI slave device to be disabled whenever the Microcontroller is not ready to perform the functionality of the SPI master e.g. during reprogramming or when the device is held in reset.
Three Wire SPI
Three wire SPI is a version of SPI where the master can send data to the slave device but cannot read any data back for example a DAC or graphical LCD.
Four Wire SPI
Four wire SPI is the complete version of SPI where the master can sent data to the device and receive data back from the device. A single SPI operation simultaneously transfers a byte from the master to the slave via the MOSI signal and also a byte from the slave to the master via the MISO signal. Normally only one of these bytes is meaningful so it's down to the protocol of the slave device as to how to perform writes and reads.
Examples
More information on SPI can be found here,
Matrix Flowcode Blog: Simplified communications I2C and SPI
Macro reference
Disable_CS
![]() |
Disable_CS |
Outputs a high signal to the chip select pin to deselect the remote slave device. | |
![]() |
Return |
Enable_CS
![]() |
Enable_CS |
Outputs a low signal to the chip select pin to select the remote slave device. | |
![]() |
Return |
GetByteArray
GetChar
![]() |
GetChar |
General purpose SPI get byte macro | |
![]() |
Return |
GetString
Initialise
![]() |
Initialise |
Activates the SPI peripheral and claims control over the I/O pins. | |
![]() |
Return |
SendByteArray
SendChar
![]() |
SendChar |
General purpose SPI send byte macro | |
![]() |
Char |
Data byte to send | |
![]() |
Return |
SendString
![]() |
SendString |
Sends a string of bytes to the SPI bus. Not compatible with NULL values. | |
![]() |
Str |
Data string to send out. | |
![]() |
Return |
Transaction
![]() |
Transaction |
Allows simultaneous two way communications, send and receive, | |
![]() |
DataOut |
Data Byte to send out | |
![]() |
Return |
TransactionArray
UnInitialise
![]() |
UnInitialise |
Deactivates the SPI peripheral leaving the I/O pins in a state where they can be used for general purpose I/O. | |
![]() |
Return |