Hi Ajay,
The SPI interface for the FSRK-USB-2 module requires some extra steps that libfreespace takes care of for you behind the scenes. The FSM-USB-2 datasheet that I've attached to this post talks about the SPI interface in more detail. I've also attached the FSP2XX Reference Manual which contains the message syntax that is referred to in the datasheet.
Here is some further information that might help you get started. You can contact me directly via email at merrill.roller <at>
hillcrestlabs.com with any questions or we can keep the discussion going in the forums.
Thanks,
-Merrill
libfreespace moderator
General Setup
- Pinouts
- Refer to Section 1.5 in the USB-2 datasheet for the pinouts to confirm everything is connected properly. Note that the HI_SEL0 pin needs to be tied to ground to enable SPI mode
- SPI Message Definitions
- Refer to Section 2.3 in the USB-2 datasheet for a listing of the SPI messages that are supported by the module
- The syntax of these messages is defined in the FSP2XX Reference Manual
The USB-2 module is an interrupt-based SPI slave. Once configured properly, there will be motion data available at 125 Hz. Most messages contain a Source and Destination address. The address of the module is 4 and the address of the Master MCU is 0. So, if you are sending a message from your master to the module set Source to 0 and Destination to 4.
General Initialization Procedure
Upon power on, the device will not be outputting data. Specifically, it is running fusion but it will filter data and not send it to the master MCU until it is told that the master is ready to start receivign data. This is defined in the LCP protocol that the FSP2XX reference manual. When you want to start receiving data, you need to send it an LCP Unfilter Request as follows:
LCP Status Request (see Section 8.1 and Section 8.3.1 in the FSP2xx Ref Manual)
0x01 (control class packet)
0x06
0x80 (DParent is 0 because the message is traveling away from the system host)
0x80
0x02 (LCP Status Request)
0x01 (tell the module to stop filtering its data)
After this, the device should send you an UNFILTERED LCP Status Response and will begin to output data.
Data Mode Selection
The default data mode is cursor data (Mouse Packet format, defined in Section 6.1.1 in the Ref Manual). In order to put the module into a new data mode, you use the Data Mode Control V2 Request message (Section 6.2.1.19 of the FSP2XX Ref Manual). Construct this message and send it to the module from your SPI master MCU. Refer to the manual for specific syntax of the message and the options, but a description of the configurable parameters is listed below:
After sending this message, the module will return a Data Mode Control V2 Response message and then it will start to have motion packets available at 125 Hz in the desired data type as defined by this message.
- Should be set to 0 (the master MCU)
Destination
- Should be set to 4 (the module)
Operating Status
- Set this to 0 to choose a new operating mode
Operating Mode Requested
- This controls the power management of the device
- Full Motion - will enter a low power mode when set down and automatically re-enter active mode when picked up
- Sleep - Low power mode, no motion is sent from the device
- Deep Sleep and Deep Deep Sleep - Very low power modes (takes longer to produce accurate data upon start up from these modes)
- Full Motion On - Always on, will not enter a low power mode when set down (this mode is very good for debugging with)
Operating Status
- Set this to 0 to choose a new output mode
Packet Select
- This selects the desired output mode
- Body Frame is angular velocity and linear acceleration
- User Frame is angular position (quaternion)
- MotionEngine Output allows for a configurable packet where you can pick and choose the data types you want. It is a little harder to configure, but it is the most flexible message. Refer to Section 6.1.11 for details on how to use it.
Format Select and FF7-FF0
- Used with the MotionEngine Output to select the data types that you want to receive
Reading Motion Data
After you have set the data mode, wait for a Data Mode Control V2 Response from the module to confirm your selection was received. Now the device will report motion data in the desired type.
The format for each of the packets is defined in the FSP2XX Reference Manual:
Mouse Section 6.1.1
Body Frame Section 6.1.6
BodyUser Frame Section 6.1.8
MotionEngine Output Section 6.1.11