Jump to content

Component: USB Slave (Comms: USB): Difference between revisions

From Flowcode Help
No edit summary
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder""
 
(8 intermediate revisions by 2 users not shown)
Line 48: Line 48:


''<span style="color:red;">No additional examples</span>''
''<span style="color:red;">No additional examples</span>''




Line 55: Line 61:
==Macro reference==
==Macro reference==


===SendString===
===CheckRx===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''CheckRx'''
|-
| colspan="2" | Called to check if there is any incoming data waiting to be received. Returns the number of incoming data bytes. Only needed when not running the slave service.&nbsp;
|-
|-
| 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" | Adds a string of bytes onto the end of the outgoing data buffer.&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''
|}
 
 
===GetByte===
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" class="mtx-class-macrohead" | '''GetByte'''
|-
|-
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| colspan="2" | Retreives the byte at location Idx from the incoming data buffer.&nbsp;
| width="90%" | Data
|-
|-
| colspan="2" | Data String To Send&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Length
| width="90%" | Idx
|-
|-
| colspan="2" | Max number of bytes to try and add to the outgoing buffer.&nbsp;
| colspan="2" | Specifies the location in the incoming buffer&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
Line 80: Line 95:


===GetString===
===GetString===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetString'''
| width="90%" class="mtx-class-macrohead" | '''GetString'''
|-
|-
| colspan="2" | Retreives a string of data from the incoming data buffer starting from location 0 and incrementing up to the NumBytes parameter.&nbsp;
| colspan="2" | Retreives a string of data from the incoming data buffer starting from location 0 and incrementing up to the NumBytes parameter.&nbsp;
Line 94: Line 109:
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
| 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="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" | Starts up the USB communications and attempts to enumerate. Returns 0 for a successful startup or 255 for a enumeration timeout.&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''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}
Line 99: Line 128:


===RunSlaveService===
===RunSlaveService===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''RunSlaveService'''
| width="90%" class="mtx-class-macrohead" | '''RunSlaveService'''
|-
|-
| colspan="2" | Stalls the microcontroller and waits for an incoming message from the USB, when a message is received the macro defined in the USB Slave properties is automatically run. While the macro is running you can choose to send data back to the PC if you wish.&nbsp;
| colspan="2" | Stalls the microcontroller and waits for an incoming message from the USB, when a message is received the macro defined in the USB Slave properties is automatically run. While the macro is running you can choose to send data back to the PC if you wish.&nbsp;
Line 113: Line 142:


===SendByte===
===SendByte===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendByte'''
| width="90%" class="mtx-class-macrohead" | '''SendByte'''
|-
|-
| colspan="2" | Adds the byte onto the end of the outgoing data buffer.&nbsp;
| colspan="2" | Adds the byte onto the end of the outgoing data buffer.&nbsp;
Line 132: Line 161:


===SendByteArray===
===SendByteArray===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SendByteArray'''
| width="90%" class="mtx-class-macrohead" | '''SendByteArray'''
|-
|-
| colspan="2" | Adds an array of bytes onto the end of the outgoing data buffer.&nbsp;
| colspan="2" | Adds an array of bytes onto the end of the outgoing data buffer.&nbsp;
Line 155: Line 184:




===CheckRx===
===SendString===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''CheckRx'''
| width="90%" class="mtx-class-macrohead" | '''SendString'''
|-
|-
| colspan="2" | Called to check if there is any incoming data waiting to be received. Returns the number of incoming data bytes. Only needed when not running the slave service.&nbsp;
| colspan="2" | Adds a string of bytes onto the end of the outgoing data buffer.&nbsp;
|-
|-
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" | Data
|}
 
 
===GetByte===
{| 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;" | '''GetByte'''
|-
| colspan="2" | Retreives the byte at location Idx from the incoming data buffer.&nbsp;
|-
|-
| colspan="2" | Data String To Send&nbsp;
|-
|-
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | Idx
| width="90%" | Length
|-
|-
| colspan="2" | Specifies the location in the incoming buffer&nbsp;
| colspan="2" | Max number of bytes to try and add to the outgoing buffer.&nbsp;
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
Line 189: Line 209:


===StopSlaveService===
===StopSlaveService===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''StopSlaveService'''
| width="90%" class="mtx-class-macrohead" | '''StopSlaveService'''
|-
|-
| colspan="2" | Allows the microcontroller to leave the stalled slave mode and resume its normal independant functionality. Must be called from within the slave service routine to work correctly.&nbsp;
| colspan="2" | Allows the microcontroller to leave the stalled slave mode and resume its normal independant functionality. Must be called from within the slave service routine to work correctly.&nbsp;
Line 200: Line 220:
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| 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" | Starts up the USB communications and attempts to enumerate. Returns 0 for a successful startup or 255 for a enumeration timeout.&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''
|}




==Property reference==
==Property reference==


{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="mtx-class-macrotable wikitable"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" | [[File:Fc9-prop-icon.png]]
| width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Properties'''  
| width="90%" class="mtx-class-macrohead" | '''Properties'''  
|-
|-
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | USB Properties
| width="90%" class="mtx-class-propfolder" | USB Properties
|-
|-
|-
|-
Line 275: Line 279:
| colspan="2" | Maximum amount of current the USB host will provide before shutting down the USB channel.&nbsp;
| colspan="2" | Maximum amount of current the USB host will provide before shutting down the USB channel.&nbsp;
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Slave Macro Properties
| width="90%" class="mtx-class-propfolder" | Slave Macro Properties
|-
|-
|-
|-
Line 289: Line 293:
| colspan="2" | Defines the parameters for the slave service macro allowing data from the host to be automatically passed into the macro.&nbsp;
| colspan="2" | Defines the parameters for the slave service macro allowing data from the host to be automatically passed into the macro.&nbsp;
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | USB Driver
| width="90%" class="mtx-class-propfolder" | USB Driver
|-
|-
|-
|-
Line 308: Line 312:
| colspan="2" | Generates a driver file when set to Yes, Automatically jumps back to No when complete.&nbsp;
| colspan="2" | Generates a driver file when set to Yes, Automatically jumps back to No when complete.&nbsp;
|-
|-
| width="10%" align="center" style="background-color:#EAE1EA;" | [[File:Fc9-conn-icon.png]]
| width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]]
| width="90%" style="background-color:#EAE1EA; color:#4B008D;" | Simulation
| width="90%" class="mtx-class-propfolder" | Simulation
|-
|-
|-
|-

Latest revision as of 14:37, 13 July 2026

Author Matrix Ltd.
Version 1.3
Category Comms: USB


USB Slave component

Component to create and communicate using a generic USB communications profile. Has the ability to allow the device to be a slave to the PC. Compatible with simulation and USB enabled microcontroller devices (PIC/dsPIC).

Component Source Code

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

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

Detailed description

No detailed description exists yet for this component

Examples

No additional examples






Macro reference

CheckRx

CheckRx
Called to check if there is any incoming data waiting to be received. Returns the number of incoming data bytes. Only needed when not running the slave service. 
- BYTE Return


GetByte

GetByte
Retreives the byte at location Idx from the incoming data buffer. 
- BYTE Idx
Specifies the location in the incoming buffer 
- BYTE Return


GetString

GetString
Retreives a string of data from the incoming data buffer starting from location 0 and incrementing up to the NumBytes parameter. 
- BYTE NumBytes
Specifies the maximum number of bytes to try and read. 
- STRING Return


Initialise

Initialise
Starts up the USB communications and attempts to enumerate. Returns 0 for a successful startup or 255 for a enumeration timeout. 
- BYTE Return


RunSlaveService

RunSlaveService
Stalls the microcontroller and waits for an incoming message from the USB, when a message is received the macro defined in the USB Slave properties is automatically run. While the macro is running you can choose to send data back to the PC if you wish. 
- VOID Return


SendByte

SendByte
Adds the byte onto the end of the outgoing data buffer. 
- BYTE Data
Data byte to transmit to the host 
- BYTE Return


SendByteArray

SendByteArray
Adds an array of bytes onto the end of the outgoing data buffer. 
[[File:]] - Data
Data Bytes To Send 
- BYTE Length
Max number of bytes to try and add to the outgoing buffer. 
- BYTE Return


SendString

SendString
Adds a string of bytes onto the end of the outgoing data buffer. 
- STRING Data
Data String To Send 
- BYTE Length
Max number of bytes to try and add to the outgoing buffer. 
- BYTE Return


StopSlaveService

StopSlaveService
Allows the microcontroller to leave the stalled slave mode and resume its normal independant functionality. Must be called from within the slave service routine to work correctly. 
- VOID Return


Property reference

Properties
USB Properties
Vendor ID
USB VID 
Product ID
USB PID 
Device Name
USB Device Name 
Manufacturer
USB Manufacturer 
Major Version
USB Major Version Number 
Minor Version
USB Minor Version Number 
Enumeration Timeout
Specifies if the enumeration (Initialise function) can timeout if taking too long. 
Country Code
Country code used by some regional based USB devices 
Maximum Current (mA)
Maximum amount of current the USB host will provide before shutting down the USB channel. 
Slave Macro Properties
Slave Macro
Flowcode macro to call while the slave service is enabled 
Macro Parameters
Defines the parameters for the slave service macro allowing data from the host to be automatically passed into the macro. 
USB Driver
Driver Directory
Directory to save the generated device driver .inf file 
Driver Filename
Filename assigned to the USB device driver .inf file when generated. 
Generate Driver
Generates a driver file when set to Yes, Automatically jumps back to No when complete. 
Simulation
Instance
Hardware instance to communicate with any connected USB slave devices. 
Timeout (ms)
Simulation host to slave communications timeout in milliseconds 
Label
Text displayed on the I/O flasher comms component.