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

From Flowcode Help
Jump to navigationJump to search
(XML import)
 
 
(16 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]
''<span style="color:red;">No additional examples</span>''
 
  
 +
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]
  
==Downloadable macro reference==
+
==Detailed description==
  
===<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>===
 
Deactivates the SPI peripheral leaving the I/O pins in a state where they can be used for general purpose I/O.
 
  
'''Parameters'''
 
  
:''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'''
+
''No detailed description exists yet for this component''
  
:''This macro has no parameters''
+
==Examples==
  
  
'''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.
 
  
<span style="font-weight: normal;"><u>CLK</u></span>
 
  
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.
 
  
<span style="font-weight: normal;"><u>Use Slave Select</u></span>
 
  
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>''
 
  
  
 +
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>CS / SS</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::SS''.
 
  
Chip Select / Slave Select Pin
+
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.
  
Master Mode: General purpose output pin used to select the remote SPI device.
+
{{Fcfile|SPI_Slave.fcfx|SPI_Slave}}
  
Slave Mode: Hardware chip select pin input used to select the SPI device.
 
  
<span style="font-weight: normal;"><u>Clock Phase</u></span>
+
Another simple example to buffer incoming SPI bytes sent by the master and output these to the LCD.
  
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi::CKE''.
+
{{Fcfile|SPI_Slave2.fcfx|SPI_Slave2}}
  
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
 
  
<span style="font-weight: normal;"><u>Sample Point</u></span>
 
  
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
 
  
<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''.
 
  
Label used to identify the component on the panel.
 
  
<span style="font-weight: normal;"><u>Scope Traces</u></span>
 
  
This property is of type ''True or false'' and can be referenced with the variable name ''cal_spi::ScopeTraces''.
+
==Macro reference==
  
Selects if the scope traces are automatically generated or not
+
===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&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''
 +
|}
  
<span style="font-weight: normal;"><u>Console Data</u></span>
 
  
This property is of type ''True or false'' and can be referenced with the variable name ''cal_spi::ConsoleData''.
+
===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.&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''
 +
|}
  
Selects if the console data is automatically generated or not
 
  
<span style="font-weight: normal;"><u>Injector</u></span>
+
===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&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''
 +
|}
 +
 
 +
 
 +
===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.&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 ''Fixed list of ints'' and can be referenced with the variable name ''cal_spi::Injector''.
+
==Property reference==
  
''<span style="color:red;">No additional information</span>''
+
{| 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&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" 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%" | 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" 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.&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 13:12, 7 February 2023

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.

FC6 Icon.png 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.

FC6 Icon.png SPI_Slave


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

FC6 Icon.png SPI_Slave2







Macro reference

GetChar

Fc9-comp-macro.png GetChar
General purpose SPI get byte macro 
Fc9-u8-icon.png - BYTE Return


Initialise

Fc9-comp-macro.png Initialise
Activates the SPI peripheral and claims control over the I/O pins. 
Fc9-void-icon.png - VOID Return


SendChar

Fc9-comp-macro.png SendChar
General purpose SPI send byte macro 
Fc9-u8-icon.png - BYTE Char
Data byte to send 
Fc9-void-icon.png - VOID Return


UnInitialise

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


Property reference

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