Jump to content

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

From Flowcode Help
No edit summary
No edit summary
Line 16: Line 16:


==Detailed description==
==Detailed description==


''No detailed description exists yet for this component''
''No detailed description exists yet for this component''


==Examples==
==Examples==




Line 787: Line 791:
|-
|-
| colspan="2" | Initialise the comms to the Arduino board ready for commands to be sent. 
| colspan="2" | Initialise the comms to the Arduino board ready for commands to be sent. 
|-
|-
| 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''
|}
{| 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;" | '''PWMEnable'''
|-
| colspan="2" | Allows pulse width modulated transistor outputs to be switched on or off. Bit 0 = Enable AB Bit 1 = A / Bit 2 = B Bit 3 = C / Bit 4 = D Bit 5 = Enable CD 
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | EnableMask
|-
| colspan="2" | Range 0-63 or 0b00000 to 0b111111 
|-
| 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''
|}
{| 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" |  
|-
|-
|-
|-

Revision as of 10:38, 17 November 2021

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.

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


Downloadable macro reference

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


GetChar
General purpose SPI get byte macro 
- BYTE Return


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


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


Disable_CS
Outputs a high signal to the chip select pin to deselect the remote slave device. 
- VOID Return


GetByteArray
Attempts to read an array of bytes from the SPI bus. Similar to the GetString component macro but allows the value 0. 
- BYTE NumBytes
Number of bytes to read 
- BYTE Data
Byte Array to Assign Data to. 
- VOID Return


GetChar
General purpose SPI get byte macro 
- BYTE Return


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


Enable_CS
Outputs a low signal to the chip select pin to select the remote slave device. 
- VOID Return


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


I2CStop
Put the I2C Module into Stop mode 
- BYTE Channel
 
- VOID Return


SPIPrescaler
Modify the speed of the SPI bus 
- BYTE Channel
Channel Index: Range 0 - SPI Bus Count - 1 
- BYTE Prescaler
Range: 0-2 
- VOID Return


PWMSetDuty
Sets the duty for the PWM output 
- BYTE Channel
Range: 0-5 
- BYTE Duty
 
- VOID Return


ADCSample10
Reads the voltage present on an Alanog pin as an 10-bit value range 0-1023 
- BYTE ADCChannel
Range: 0-12 
- UINT Return


I2CTransSend
Sends an I2C Transaction on the selected I2C channel. Returns the number of bytes sent. 
- BYTE Channel
Channel Index: Range 0 - I2C Bus Count - 1 
- BYTE Data
Data to send 
- UINT Count
Number of bytes to send out, MS bit 0x8000 signifies no Stop if set 
- UINT Return


I2CTransInit
Initialises the I2C Transaction mode with the 7-bit device address 
- BYTE Channel
Channel Index: Range 0 - I2C Bus Count - 1 
- BYTE DeviceAddress
7-bit Device Address 
- BYTE Baud
0=100KHz, 1=400KHz, 2=1MHz 
- VOID Return


IOSetOutputPin
Sets the selected digital pin to an output and assigns the output state. 
- BYTE Pin
Range: 0-29 
[[File:]] - State
Range: 0-1 
- VOID Return


UARTReceive
Receives a data byte from the UART. Recommend calling the UARTCheckRx function first to ensure data is available. 
- BYTE Channel
Channel Index: Range 0 - UART Bus Count - 1 
- BYTE Return


SPIInitialise
Initialsie the SPI module ready for communications 
- BYTE Channel
Channel Index: Range 0 - SPI Bus Count - 1 
- VOID Return


I2CSend
Transmit a byte using the I2C bus 
- BYTE Channel
Channel Index: Range 0 - I2C Bus Count - 1 
- BYTE DataOut
 
[[File:]] - Return


UARTSend
Send a byte via the UART module 
- BYTE Channel
Channel Index: Range 0 - UART Bus Count - 1 
- BYTE Data
Data Byte to send. Range: 0-255 
- VOID Return


PWMSetPrescaler
Sets the prescaler for the PWM output 
- BYTE Channel
 
- BYTE Prescaler
 
- BYTE Period
 
- VOID Return


PWMEnable
Enable a PWM output 
- BYTE Channel
Range: 0-1 
- VOID Return


Initialise
Initialise the comms to the Arduino board ready for commands to be sent. 
- VOID Return


IOSetOutputPin
Sets the selected digital pin to an output and assigns the output state. 
- BYTE Pin
Range: 0-29 
[[File:]] - State
Range: 0-1 
- VOID Return


UARTReceive
Receives a data byte from the UART. Recommend calling the UARTCheckRx function first to ensure data is available. 
- BYTE Channel
Channel Index: Range 0 - UART Bus Count - 1 
- BYTE Return


ADCSampleAverage10
Reads the voltage present on an Analog pin as an 10-bit value range 0-1023. Performs the selected number of samples with the selected time in microseconds in between samples 
- BYTE ADCChannel
Range: 0, 3-7 
- BYTE SampleCount
Range: 1- 100 
- BYTE SampleDelay
Delay in us between each sample 
- UINT Return


OneWireScanBus
Scans the one wire bus to detect all connected devices. Returns the number of one wire devices found. 
- BYTE Channel
Channel Index: Range 0 - I2C Bus Count - 1 
- BYTE Return


SPIInitialise
Initialsie the SPI module ready for communications 
- BYTE Channel
Channel Index: Range 0 - SPI Bus Count - 1 
- VOID Return


OneWireReceiveByte
Receives a byte from the one wire bus a bit at a time 
- BYTE Channel
Channel Index: Range 0 - I2C Bus Count - 1 
- BYTE Return


I2CSend
Transmit a byte using the I2C bus 
- BYTE Channel
Channel Index: Range 0 - I2C Bus Count - 1 
- BYTE DataOut
 
[[File:]] - Return


UARTSend
Send a byte via the UART module 
- BYTE Channel
Channel Index: Range 0 - UART Bus Count - 1 
- BYTE Data
Data Byte to send. Range: 0-255 
- VOID Return


OneWireGetDeviceCount
Returns the number of devices found by the last ScanBus operation. 
- BYTE Channel
Channel Index: Range 0 - I2C Bus Count - 1 
- BYTE Return


PWMSetPrescaler
Sets the prescaler for the PWM output 
- BYTE Channel
Range: 0 - 11 
- BYTE Prescaler
 
- BYTE Period
 
- VOID Return


PWMEnable
Enable a PWM output 
- BYTE Channel
Range: 0-11 
- VOID Return


ADCSampleArray10
Reads the voltage present on an Analog pin as an 10-bit value range 0-1023 Performs the selected number of samples with the selected time in microseconds in between samples and returns each sample in a single packet 
- BYTE ADCChannel
Range: 0, 3-7 
- BYTE SampleCount
Range: 1- 32 
- UINT SampleDelay
Delay in us between each sample 
- UINT Samples
10-bit samples returned from the function 
- VOID Return


ADCSampleAverage8
Reads the voltage present on an Analog pin as an 8-bit value range 0-255 Performs the selected number of samples with the selected time in microseconds in between samples 
- BYTE ADCChannel
Range: 0, 3-7 
- BYTE SampleCount
Range: 1- 100 
- BYTE SampleDelay
Delay in us between each sample 
- BYTE Return


Initialise
Initialise the comms to the Arduino board ready for commands to be sent. 
- VOID Return


PWMEnable
Allows pulse width modulated transistor outputs to be switched on or off. Bit 0 = Enable AB Bit 1 = A / Bit 2 = B Bit 3 = C / Bit 4 = D Bit 5 = Enable CD 
- BYTE EnableMask
Range 0-63 or 0b00000 to 0b111111 
- VOID Return


Initialise
 
- VOID Return



Property reference

Properties
Clock Phase
Clock Phase (data change edge) selection 
Clock Polarity
Clock Polarity setting, inactive (idle) state 
Sample Point
Data bit read sample point 
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.  
Simulations
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