SmartWheels self-driving race car. Designed for NXP Cup. Uses FRDM-KL25Z, area-scan camera, and simple image processing to detect and navigate any NXP spec track.
Dependencies: TSI USBDevice mbed-dev
Fork of SmartWheels by
Diff: RemovedSources/IMUManager.h.txt
- Branch:
- Drift
- Revision:
- 87:15fcf7891bf9
- Parent:
- 64:43ab429a37e0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RemovedSources/IMUManager.h.txt Wed Apr 19 04:06:01 2017 +0000 @@ -0,0 +1,121 @@ +#if 0 + +#pragma once +#ifndef IMU_MANAGER_H +#define IMU_MANAGER_H + +#define ACCEL_MAG_SA0_0 +//#define ACCEL_MAG_SA0_1 +#define ACCEL_MAG_SA1_0 +//#define ACCEL_MAG_SA1_1 + +#if defined(ACCEL_MAG_SA1_0) && defined(ACCEL_MAG_SA0_0) + #define ACCEL_MAG_SA1 0 + #define ACCEL_MAG_SA0 0 + #define FXOS8700CQ_SLAVE_ADDR 0x1E +#elif defined(ACCEL_MAG_SA1_0) && defined(ACCEL_MAG_SA0_1) + #define ACCEL_MAG_SA1 0 + #define ACCEL_MAG_SA0 1 + #define FXOS8700CQ_SLAVE_ADDR 0x1D +#elif defined(ACCEL_MAG_SA1_1) && defined(ACCEL_MAG_SA0_0) + #define ACCEL_MAG_SA1 1 + #define ACCEL_MAG_SA0 0 + #define FXOS8700CQ_SLAVE_ADDR 0x1C +#elif defined(ACCEL_MAG_SA1_1) && defined(ACCEL_MAG_SA0_1) + #define ACCEL_MAG_SA1 1 + #define ACCEL_MAG_SA0 1 + #define FXOS8700CQ_SLAVE_ADDR 0x1F +#else + #error Must choose a SA0 and SA1 value for Accel and Mag +#endif + +#define FXOS8700CQ_STATUS 0x00 + +#define FXOS8700CQ_F_SETUP 0x09 + +#define FXOS8700CQ_SYSMOD 0x0B + +#define FXOS8700CQ_WHOAMI 0x0D +#define FXOS8700CQ_WHOAMI_VAL 0xC7 + +#define FXOS8700CQ_XYZ_DATA_CFG 0x0E +#define FXOS8700CQ_XYZ_DATA_2G 0x00 +#define FXOS8700CQ_XYZ_DATA_4G 0x01 +#define FXOS8700CQ_XYZ_DATA_8G 0x02 + +#define FXOS8700CQ_XYZ_DATA_SC FXOS8700CQ_XYZ_DATA_2G + +#if FXOS8700CQ_XYZ_DATA_SC == FXOS8700CQ_XYZ_DATA_2G + #define ACCELER_SCALE_F_MG 0.244f +#elif FXOS8700CQ_XYZ_DATA_SC == FXOS8700CQ_XYZ_DATA_4G + #define ACCELER_SCALE_F_MG 0.488f +#elif FXOS8700CQ_XYZ_DATA_SC == FXOS8700CQ_XYZ_DATA_8G + #define ACCELER_SCALE_F_MG 0.976f +#else + #error Must define a scale for accelerometer! +#endif + +#define FXOS8700CQ_HP_FILTER_CUTOFF 0x0F + +#define FXOS8700CQ_CTRL_REG1 0x2A +#define FXOS8700CQ_CTRL_REG1_v 0x05 + +#define FXOS8700CQ_CTRL_REG2 0x2B +#define FXOS8700CQ_RESET_MASK 0x40 + +#define FXOS8700CQ_OFF_X 0x2F + +#define FXOS8700CQ_OFF_Y 0x30 + +#define FXOS8700CQ_OFF_Z 0x31 +#define OFFSET_SCALE_F 2.0f + +#define FXOS8700CQ_TEMP 0x51 + +#define FXOS8700CQ_M_CTRL_REG1 0x5B + +#define FXOS8700CQ_M_CTRL_REG2 0x5C + +#define FXOS8700CQ_READ_LEN 7 // status plus 6 channels = 13 bytes + +#define IMU_UPDATE_TICK_RATE 0.002f +#define IMU_DEFAULT_G 9.8f + +#include <mbed.h> + +#ifdef __cplusplus +extern "C" { +#endif + +struct imu_vec3 +{ + float x; + float y; + float z; +}; + +uint8_t imu_manager_init(); + +void imu_manager_calibrate(); + +void imu_manager_begin_tick(); + +void imu_manager_update(); + +const volatile struct imu_vec3* imu_manager_get_accl(); + +const volatile struct imu_vec3* imu_manager_get_velocity(); + +const volatile struct imu_vec3* imu_manager_get_position(); + +float imu_manager_get_temp(); + +//const volatile struct imu_vec3* imu_manager_get_magt(); + +#ifdef __cplusplus +} +#endif + +#endif //IMU_MANAGER_H + +#endif //if 0 \ No newline at end of file