Component: USB Slave (Comms: USB)
Author | Matrix Ltd. |
Version | 1.1 (Release) |
Category | Comms: USB |
Contents
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).
Examples
No additional examples
Downloadable macro reference
SendString
Adds a string of bytes onto the end of the outgoing data buffer.
Parameters
- <- STRING Data
- Data String To Send
- This parameter may be returned back to the caller
- BYTE Length
- Max number of bytes to try and add to the outgoing buffer.
Return value
GetString
Retreives a string of data from the incoming data buffer starting from location 0 and incrementing up to the NumBytes parameter.
Parameters
- BYTE NumBytes
- Specifies the maximum number of bytes to try and read.
Return value
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.
Parameters
- This macro has no parameters
Return value
- This call does not return a value
SendByte
Adds the byte onto the end of the outgoing data buffer.
Parameters
- BYTE Data
- Data byte to transmit to the host
Return value
SendByteArray
Adds an array of bytes onto the end of the outgoing data buffer.
Parameters
- <- BYTE Data
- Data Bytes To Send
- This parameter may be returned back to the caller
- BYTE Length
- Max number of bytes to try and add to the outgoing buffer.
Return value
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.
Parameters
- This macro has no parameters
Return value
GetByte
Retreives the byte at location Idx from the incoming data buffer.
Parameters
- BYTE Idx
- Specifies the location in the incoming buffer
Return value
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.
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Initialise
Starts up the USB communications and attempts to enumerate.
Returns 0 for a successful startup or 255 for a enumeration timeout.
Parameters
- This macro has no parameters
Return value
Simulation macro reference
This component does not contain any simulation macros
Property reference
Vendor ID
This property is of type Signed integer and can be referenced with the variable name vendor_ID.
USB VID
Product ID
This property is of type Signed integer and can be referenced with the variable name product_ID.
USB PID
Device Name
This property is of type Line of text and can be referenced with the variable name dev_name.
USB Device Name
Manufacturer
This property is of type Line of text and can be referenced with the variable name dev_manufacturer.
USB Manufacturer
Major Version
This property is of type Signed integer and can be referenced with the variable name major_version.
USB Major Version Number
Minor Version
This property is of type Signed integer and can be referenced with the variable name minor_version.
USB Minor Version Number
Enumeration Timeout
This property is of type True or false and can be referenced with the variable name enumeration_tout.
Specifies if the enumeration (Initialise function) can timeout if taking too long.
Country Code
This property is of type Fixed list of ints and can be referenced with the variable name country_code.
Country code used by some regional based USB devices
Maximum Current (mA)
This property is of type Signed integer and can be referenced with the variable name max_current.
Maximum amount of current the USB host will provide before shutting down the USB channel.
Slave Macro
This property is of type Line of text and can be referenced with the variable name slave_macro.
Flowcode macro to call while the slave service is enabled
Macro Parameters
This property is of type Fixed list of ints and can be referenced with the variable name slave_params.
Defines the parameters for the slave service macro allowing data from the host to be automatically passed into the macro.
Driver Directory
This property is of type Line of text and can be referenced with the variable name driver_directory.
Directory to save the generated device driver .inf file
Driver Filename
This property is of type Line of text and can be referenced with the variable name driver_filename.
Filename assigned to the USB device driver .inf file when generated.
Generate Driver
This property is of type True or false and can be referenced with the variable name gen_driver.
Generates a driver file when set to Yes, Automatically jumps back to No when complete.
Instance
This property is of type Fixed list of ints and can be referenced with the variable name Instance.
Hardware instance to communicate with any connected USB slave devices.
Timeout (ms)
This property is of type Unsigned integer and can be referenced with the variable name SimTimeout.
Simulation host to slave communications timeout in milliseconds
Label
This property is of type Line of text and can be referenced with the variable name label.
Text displayed on the I/O flasher comms component.