uTrack
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
utIMU.c File Reference

Support for managing and polling an inertial navigation unit for sensor data. More...

#include "uTrack.h"
#include "utHAL.h"
#include "utIMU.h"
#include "utIMUCommandPool.h"
#include "lpc23xx.h"
#include "lpc2387_config.h"
#include "utNmeaDriver.h"
#include "utNmeaOutput.h"
#include "utMonitor.h"
#include "utPayloads_IMU.h"
#include "utVersion.h"
#include <stdlib.h>
#include <stdarg.h>
#include <math.h>
#include "utSPI_2387.h"

Data Structures

struct  UT_IMU_COMMAND_CONTROL
 

Macros

#define IMU_MIN_RATE   1
 Minimum IMU message poll rate in Hertz.
 
#define IMU_MAX_RATE   200
 Maximum IMU message poll rate in Hertz.
 
#define MAX_RX_QUEUE   1024
 
#define MAX_TX_QUEUE   512
 
#define TIMEOUT   5000
 
#define UT_PI   3.14159
 Our definition of PI. Should be moved to a global/maths appropriate location.
 
#define REV_32(val)   (__rev(*(u32 *) &val))
 
#define REV_16(val)   (u16) __rev((*(u32 *) &val) << 16)
 
#define LOG_IMU_TBUFFER_SIZE   81
 Length of the temporary buffer used for logging.
 
#define irqWatchDogTimeout   5000
 

Enumerations

enum  IMU_DetectState {
  IMU_DETECT_NONE = 0 , IMU_DETECT_SERIAL = 0x01 , IMU_DETECT_HW = 0x02 , IMU_DETECT_FW = 0x04 ,
  IMU_DETECT_ALL = 0x07
}
 
enum  UT_IMU_SOFT_STATE {
  UT_IMU_SOFT_OFF , UT_IMU_POWER_WAIT , UT_IMU_DETECT_MODULE , UT_IMU_CONFIG ,
  UT_IMU_SOFT_ON , UT_IMU_SOFT_RUNNING
}
 The (software) state this module is in.
 
enum  UT_IMU_ORIENTATION {
  UT_IMU_AXIS_DECK , UT_IMU_AXIS_BOW , UT_IMU_AXIS_STERN , UT_IMU_AXIS_PORT ,
  UT_IMU_AXIS_STARBOARD , UT_IMU_AXIS_UNITY
}
 
enum  UT_IMU_CAL_MODE { UT_IMU_CAL_MODE_NORMAL , UT_IMU_CAL_MODE_FROM_FILE }
 
enum  UT_IMU_CAL_SENSOR { UT_IMU_CAL_MODE_SENSOR_BOTH , UT_IMU_CAL_MODE_SENSOR_ACC , UT_IMU_CAL_MODE_SENSOR_MAG }
 

Functions

void updateLogFlags (UT_IMU_PollCmd id)
 
void utIMU_NotifyMissedUpdates (u32 n)
 
bool utIMU_Notify (UT_DeviceMessage state)
 
void utIMU_SetStoreOptions (UT_NMEA_Store *nmeaStore)
 
void normalize_quat (double *quat)
 
void vec_sub (double *vec_result, double *vec1, double *vec2)
 
void vec_add (double *vec_result, double *vec1, double *vec2)
 
double vec_length (double *vec)
 
void matrix_mult (double *vec_result, double matrix[3][3], double *vec)
 
void startupCheck (u32 now)
 
void checkMissedUpdates (u32 now)
 
void checkErrorState (u32 now)
 
bool getFlagsFromToken (const char *token, UT_IMU_CmdFieldDetails *flags, bool log)
 

Variables

UT_IMU_CAL_MODE CAL_MODE = UT_IMU_CAL_MODE_NORMAL
 
UT_IMU_CAL_SENSOR CAL_SENSOR = UT_IMU_CAL_MODE_SENSOR_BOTH
 
double yaw
 
int array_count
 
int stop
 

Detailed Description

Support for managing and polling an inertial navigation unit for sensor data.

This software module is used to interact with an IMU via SPI bus. The SPI implementaiton under the HAL is moderately entangled in support for this module.

Author
Oscar Key
Date
16/07/2013

Macro Definition Documentation

◆ IMU_MIN_RATE

#define IMU_MIN_RATE   1

Minimum IMU message poll rate in Hertz.

Function Documentation

◆ utIMU_Notify()

bool utIMU_Notify ( UT_DeviceMessage  state)

Checks that the IMU module is present in the device

Parameters
void
Returns
bool - if the IMU module is present return true, else false
Note

The Notify function passes a message to the software module, informing it of expected module state. It returns a value that is considered a response to a query about the specified state.

Parameters
stateA state message.
Returns
Whether or not this software module is in the desired state.

◆ utIMU_NotifyMissedUpdates()

void utIMU_NotifyMissedUpdates ( u32  n)

Tell the IMU software module that some number of polls have been missed, either in transmission or reception. Used by the SPI code that handles the actual polling in utSPI_2387.c

Parameters
nThe number of polls that were missed.

◆ utIMU_SetStoreOptions()

void utIMU_SetStoreOptions ( UT_NMEA_Store *  nmeaStore)

The SetStoreOptions function applies the options the IMU desires to the provided store. Other options will be overriden.

Parameters
nmeaStoreThe store to configure.