Add LPC1768
Dependencies: mbed-rtos mbed Xbus
Fork of MTi-1_example by
Go to the source code of this file.
Functions | |
static Serial | pc (PC_TX, PC_RX) |
Serial port for communication with the host PC. | |
static I2C | mt (MT_SDA, MT_SCL) |
I2C master used for communication with the MT. | |
static SPI | mt (MT_MOSI, MT_MISO, MT_SCLK) |
SPI master used for communication with the MT. | |
static DigitalOut | cs (MT_nCS, 1) |
Chip select line for the MT. | |
static RawSerial | mt (MT_TX, MT_RX) |
Serial port for communication with the MT. | |
static InterruptIn | drdy (MT_DRDY) |
Interrput line used by MT to signal that data is available. | |
static DigitalOut | mtReset (MT_NRESET, 0) |
MT reset line. | |
static void * | allocateMessageData (size_t bufSize) |
Allocate message data buffer from the message data pool. | |
static void | deallocateMessageData (void const *buffer) |
Deallocate message data previously allocated from the message data pool. | |
static void | configureMtCommunicationInterface (void) |
Configure the serial port used for communication with the motion tracker. | |
static void | sendMessage (XbusMessage const *m) |
Send a message to the MT. | |
static void | mtLowLevelHandler (void) |
RX Interrupt handler for the MT serial port. | |
static XbusMessage const * | doTransaction (XbusMessage const *m) |
Send a message to the MT and wait for a response. | |
static void | dumpResponse (XbusMessage const *response) |
Dump information from a message to the PC serial port. | |
static void | sendCommand (XsMessageId cmdId) |
Send a command to the MT and wait for a response. | |
static void | handlePcCommand (char cmd) |
Handle a command from the PC. | |
static void | mtMessageHandler (struct XbusMessage const *message) |
XbusParser callback function to handle received messages. | |
static void | configurePcInterface (void) |
Configure the serial port used to communicate with the host PC. | |
static uint32_t | readDeviceId (void) |
Read the device ID of the motion tracker. | |
static bool | setOutputConfiguration (OutputConfiguration const *conf, uint8_t elements) |
Sets MT output configuration. | |
static bool | configureMotionTracker (void) |
Sets the motion tracker output configuration based on the function of the attached device. | |
bool | waitForWakeup (uint32_t timeout) |
Wait for a wakeup message from the MTi. | |
void | sendWakeupAck (void) |
Send wakeup acknowledge message to MTi. | |
void | restoreCommunication (void) |
Restore communication with the MTi. | |
static bool | wakeupMotionTracker (void) |
Releases the MTi reset line and waits for a wakeup message. | |
static void | printMessageData (struct XbusMessage const *message) |
Output the contents of a data message to the PC serial port. | |
Variables | |
static XbusParser * | xbusParser |
XbusParser used to parse incoming Xbus messages from the MT. | |
MemoryPool< XbusMessage, MEMORY_POOL_SIZE > | g_messagePool |
Memory pool used for storing Xbus messages when passing them to the main thread. | |
MemoryPool< uint8_t[MAX_XBUS_DATA_SIZE], MEMORY_POOL_SIZE > | g_messageDataPool |
Memory pool used for storing the payload of Xbus messages. | |
Queue< XbusMessage, DATA_QUEUE_SIZE > | g_dataQueue |
Queue used to pass data messages to the main thread for processing. | |
Queue< XbusMessage, RESPONSE_QUEUE_SIZE > | g_responseQueue |
Queue used for passing all other messages to the main thread for processing. |
Detailed Description
Copyright (C) Xsens Technologies B.V., 2015.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Definition in file main.cpp.
Function Documentation
static void* allocateMessageData | ( | size_t | bufSize ) | [static] |
static bool configureMotionTracker | ( | void | ) | [static] |
Sets the motion tracker output configuration based on the function of the attached device.
The output configuration depends on the type of MTi-1 device connected. An MTI-1 (IMU) device does not have an onboard orientation filter so cannot output quaternion data, only inertial and magnetic measurement data. MTi-2 and MTi-3 devices have an onboard filter so can send quaternions.
static void configureMtCommunicationInterface | ( | void | ) | [static] |
static void configurePcInterface | ( | void | ) | [static] |
static DigitalOut cs | ( | MT_nCS | , |
1 | |||
) | [static] |
Chip select line for the MT.
static void deallocateMessageData | ( | void const * | buffer ) | [static] |
static XbusMessage const* doTransaction | ( | XbusMessage const * | m ) | [static] |
static InterruptIn drdy | ( | MT_DRDY | ) | [static] |
Interrput line used by MT to signal that data is available.
static void dumpResponse | ( | XbusMessage const * | response ) | [static] |
static void handlePcCommand | ( | char | cmd ) | [static] |
static RawSerial mt | ( | MT_TX | , |
MT_RX | |||
) | [static] |
Serial port for communication with the MT.
We use a RawSerial port as the Stream inteface used by the regular Serial class can have problems with the RTOS when using interrupts.
static SPI mt | ( | MT_MOSI | , |
MT_MISO | , | ||
MT_SCLK | |||
) | [static] |
SPI master used for communication with the MT.
static I2C mt | ( | MT_SDA | , |
MT_SCL | |||
) | [static] |
I2C master used for communication with the MT.
static void mtLowLevelHandler | ( | void | ) | [static] |
static void mtMessageHandler | ( | struct XbusMessage const * | message ) | [static] |
XbusParser callback function to handle received messages.
- Parameters:
-
message Pointer to the last received message.
In this example received messages are copied into one of two message queues for later handling by the main thread. Data messages are put in one queue, while all other responses are placed in the second queue. This is done so that data and other messages can be handled separately by the application code.
static DigitalOut mtReset | ( | MT_NRESET | , |
0 | |||
) | [static] |
MT reset line.
MT is held in reset on startup.
static Serial pc | ( | PC_TX | , |
PC_RX | |||
) | [static] |
Serial port for communication with the host PC.
static void printMessageData | ( | struct XbusMessage const * | message ) | [static] |
static uint32_t readDeviceId | ( | void | ) | [static] |
void restoreCommunication | ( | void | ) |
static void sendCommand | ( | XsMessageId | cmdId ) | [static] |
static void sendMessage | ( | XbusMessage const * | m ) | [static] |
Send a message to the MT.
This function formats the message data and writes this to the MT I2C interface. It does not wait for any response.
This function formats the message data and writes this to the MT SPI interface. It does not wait for any response.
This function formats the message data and writes this to the MT serial port. It does not wait for any response.
void sendWakeupAck | ( | void | ) |
static bool setOutputConfiguration | ( | OutputConfiguration const * | conf, |
uint8_t | elements | ||
) | [static] |
Sets MT output configuration.
- Parameters:
-
conf Pointer to an array of OutputConfiguration elements. elements The number of elements in the configuration array.
The response from the device indicates the actual values that will be used by the motion tracker. These may differ from the requested parameters as the motion tracker validates the requested parameters before applying them.
bool waitForWakeup | ( | uint32_t | timeout ) |
Wait for a wakeup message from the MTi.
- Parameters:
-
timeout Time to wait to receive the wakeup message.
- Returns:
- true if wakeup received within timeout, else false.
The MTi sends an XMID_Wakeup message once it has completed its bootup procedure. If this is acknowledged by an XMID_WakeupAck message then the MTi will stay in configuration mode. Otherwise it will automatically enter measurement mode with the stored output configuration.
static bool wakeupMotionTracker | ( | void | ) | [static] |
Variable Documentation
Queue<XbusMessage, DATA_QUEUE_SIZE> g_dataQueue |
MemoryPool<uint8_t[MAX_XBUS_DATA_SIZE], MEMORY_POOL_SIZE> g_messageDataPool |
MemoryPool<XbusMessage, MEMORY_POOL_SIZE> g_messagePool |
Queue<XbusMessage, RESPONSE_QUEUE_SIZE> g_responseQueue |
XbusParser* xbusParser [static] |
Generated on Mon Aug 15 2022 22:29:59 by 1.7.2