Jump to content

Component: SPI Slave (Comms: Interface): Difference between revisions

From Flowcode Help
No edit summary
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder""
 
(21 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{| style="width:50%"
 
{| 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.0 (Release)
| 1.0
|-
|-
| width="20%" style="color: gray;" | Category
| width="20%" style="color:gray;" | Category
| Comms: Interface
| Comms: Interface
|}
|}




==SPI Slave 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.


==[[File:Component Icon e2955f6c_d724_4ab0_afca_d62093a77248.png|Image]] SPI Slave component==
==Component Source Code==
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.


==Examples==
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_SPI_Slave.fcfx FC_Comp_Source_SPI_Slave.fcfx]


Simple Master program that sends an incrementing test value to the SPI bus as well as outputting the value onto LEDs.
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_SPI_Slave.fcfx FC_Comp_Source_SPI_Slave.fcfx]


{{Fcfile|SPI_Master.fcfx|SPI_Master}}
==Detailed description==




Simple Slave program that collects the value sent by the master and outputs the value onto LEDs. Allows the master slave comms to be compared to check that everything is working correctly.


{{Fcfile|SPI_Slave.fcfx|SPI_Slave}}




Another simple example to buffer incoming SPI bytes sent by the master and output these to the LCD.


{{Fcfile|SPI_Slave2.fcfx|SPI_Slave2}}




==Downloadable macro reference==


===<span style="font-weight: normal;"><u><tt>SendChar</tt></u></span>===
General purpose SPI send byte macro


'''Parameters'''


:[[Variable Types|BYTE]] ''Char''
::Data byte to send




'''Return value'''


:''This call does not return a value''




===<span style="font-weight: normal;"><u><tt>GetChar</tt></u></span>===
General purpose SPI get byte macro


'''Parameters'''


:''This macro has no parameters''




'''Return value'''


:[[Variable Types|BYTE]]




===<span style="font-weight: normal;"><u><tt>UnInitialise</tt></u></span>===
''No detailed description exists yet for this component''
Deactivates the SPI peripheral leaving the I/O pins in a state where they can be used for general purpose I/O.


'''Parameters'''
==Examples==


:''This macro has no parameters''




'''Return value'''


:''This call does not return a value''




===<span style="font-weight: normal;"><u><tt>Initialise</tt></u></span>===
Activates the SPI peripheral and claims control over the I/O pins.


'''Parameters'''


:''This macro has no parameters''




'''Return value'''


:''This call does not return a value''






==Simulation macro reference==


''This component does not contain any simulation macros''




==Property reference==
<span style="font-weight: normal;"><u>Channel</u></span>


This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi::CHANNEL''.


SPI Channel selector


<span style="font-weight: normal;"><u>MOSI</u></span>


This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi::MOSI''.


SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode.


<span style="font-weight: normal;"><u>MISO</u></span>


This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi::MISO''.


SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode.
Simple Master program that sends an incrementing test value to the SPI bus as well as outputting the value onto LEDs.


<span style="font-weight: normal;"><u>CLK</u></span>
{{Fcfile|SPI_Master.fcfx|SPI_Master}}


This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi::CLK''.


SPI Clock Pin CLK - The Clock signal is driven by the SPI master.
Simple Slave program that collects the value sent by the master and outputs the value onto LEDs. Allows the master slave comms to be compared to check that everything is working correctly.


<span style="font-weight: normal;"><u>Use Slave Select</u></span>
{{Fcfile|SPI_Slave.fcfx|SPI_Slave}}


This property is of type ''True or false'' and can be referenced with the variable name ''cal_spi::UseCS''.


''<span style="color:red;">No additional information</span>''
Another simple example to buffer incoming SPI bytes sent by the master and output these to the LCD.


{{Fcfile|SPI_Slave2.fcfx|SPI_Slave2}}




<span style="font-weight: normal;"><u>CS / SS</u></span>


This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_spi::SS''.


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.


<span style="font-weight: normal;"><u>Clock Phase</u></span>


This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi::CKE''.


Clock Phase (data change edge) selection


<span style="font-weight: normal;"><u>Clock Polarity</u></span>


This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi::CKP''.


Clock Polarity setting, inactive (idle) state
==Macro reference==


<span style="font-weight: normal;"><u>Sample Point</u></span>
===GetChar===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''GetChar'''
|-
| colspan="2" | General purpose SPI get byte macro&nbsp;
|-
|-
| 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''
|}


This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi::SMP''.


Data bit read sample point
===Initialise===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''Initialise'''
|-
| colspan="2" | Activates the SPI peripheral and claims control over the I/O pins.&nbsp;
|-
|-
| 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''
|}


<span style="font-weight: normal;"><u>Label</u></span>


This property is of type ''Line of text'' and can be referenced with the variable name ''label''.
===SendChar===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''SendChar'''
|-
| colspan="2" | General purpose SPI send byte macro&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Char
|-
| colspan="2" | Data byte to send&nbsp;
|-
| 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''
|}


Label used to identify the component on the panel.


<span style="font-weight: normal;"><u>Scope Traces</u></span>
===UnInitialise===
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''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.&nbsp;
|-
|-
| 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''
|}


This property is of type ''True or false'' and can be referenced with the variable name ''cal_spi::ScopeTraces''.


Selects if the scope traces are automatically generated or not
==Property reference==


<span style="font-weight: normal;"><u>Console Data</u></span>
{| class="mtx-class-macrotable wikitable"
 
|-
This property is of type ''True or false'' and can be referenced with the variable name ''cal_spi::ConsoleData''.
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]]
 
| width="90%" class="mtx-class-macrohead" | '''Properties'''
Selects if the console data is automatically generated or not
|-
 
|-
<span style="font-weight: normal;"><u>Injector</u></span>
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
 
| width="90%" class="mtx-class-propfolder" | Connections
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi::Injector''.
|-
 
|-
''<span style="color:red;">No additional information</span>''
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| width="90%" | Channel
|-
| colspan="2" | SPI Channel selector&nbsp;
|-
| 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.&nbsp;
|-
| 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.&nbsp;
|-
| 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.&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-type-7-icon.png]]
| width="90%" | Use Slave Select
|-
| colspan="2" | &nbsp;
|-
| 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. &nbsp;
|-
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" class="mtx-class-propfolder" | Bus Settings
|-
|-
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| width="90%" | Clock Phase
|-
| colspan="2" | Clock Phase (data change edge) selection&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| width="90%" | Clock Polarity
|-
| colspan="2" | Clock Polarity setting, inactive (idle) state&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| width="90%" | Sample Point
|-
| colspan="2" | Data bit read sample point&nbsp;
|-
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" class="mtx-class-propfolder" | 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.&nbsp;
|-
| 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&nbsp;
|-
| 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&nbsp;
|-
| width="10%" align="center" | [[File:Fc9-type-16-icon.png]]
| width="90%" | API
|-
| colspan="2" | &nbsp;
|}

Latest revision as of 14:37, 13 July 2026

Author Matrix Ltd
Version 1.0
Category Comms: Interface


SPI Slave 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.

Component Source Code

Please click here to download the component source project: FC_Comp_Source_SPI_Slave.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_SPI_Slave.fcfx

Detailed description

No detailed description exists yet for this component

Examples

Simple Master program that sends an incrementing test value to the SPI bus as well as outputting the value onto LEDs.

SPI_Master


Simple Slave program that collects the value sent by the master and outputs the value onto LEDs. Allows the master slave comms to be compared to check that everything is working correctly.

SPI_Slave


Another simple example to buffer incoming SPI bytes sent by the master and output these to the LCD.

SPI_Slave2







Macro reference

GetChar

GetChar
General purpose SPI get byte macro 
- BYTE Return


Initialise

Initialise
Activates the SPI peripheral and claims control over the I/O pins. 
- VOID Return


SendChar

SendChar
General purpose SPI send byte macro 
- BYTE Char
Data byte to send 
- VOID Return


UnInitialise

UnInitialise
Deactivates the SPI peripheral leaving the I/O pins in a state where they can be used for general purpose I/O. 
- VOID Return


Property reference

Properties
Connections
Channel
SPI Channel selector 
MOSI
SPI Data Out Pin SDO - Also Known as Master Out Slave In (MOSI) when used in Master mode. 
MISO
SPI Data In Pin SDI - Also Known as Master In Slave Out (MISO) when used in Master mode. 
CLK
SPI Clock Pin CLK - The Clock signal is driven by the SPI master. 
Use Slave Select
 
CS / SS
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.  
Bus Settings
Clock Phase
Clock Phase (data change edge) selection 
Clock Polarity
Clock Polarity setting, inactive (idle) state 
Sample Point
Data bit read sample point 
Simulation
Label
Label used to identify the component on the panel. 
Scope Traces
Selects if the scope traces are automatically generated or not 
Console Data
Selects if the console data is automatically generated or not 
API