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
Hardwares/IMUManager.h@59:b709711bc566, 2017-04-08 (annotated)
- Committer:
- hazheng
- Date:
- Sat Apr 08 17:40:13 2017 +0000
- Revision:
- 59:b709711bc566
- Child:
- 62:bc5caf59fe39
Added IMUManager Class.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hazheng | 59:b709711bc566 | 1 | #pragma once |
hazheng | 59:b709711bc566 | 2 | #ifndef IMU_MANAGER_H |
hazheng | 59:b709711bc566 | 3 | #define IMU_MANAGER_H |
hazheng | 59:b709711bc566 | 4 | |
hazheng | 59:b709711bc566 | 5 | #define ACCEL_MAG_SA0_0 |
hazheng | 59:b709711bc566 | 6 | //#define ACCEL_MAG_SA0_1 |
hazheng | 59:b709711bc566 | 7 | #define ACCEL_MAG_SA1_0 |
hazheng | 59:b709711bc566 | 8 | //#define ACCEL_MAG_SA1_1 |
hazheng | 59:b709711bc566 | 9 | |
hazheng | 59:b709711bc566 | 10 | #if defined(ACCEL_MAG_SA1_0) && defined(ACCEL_MAG_SA0_0) |
hazheng | 59:b709711bc566 | 11 | #define ACCEL_MAG_SA1 0 |
hazheng | 59:b709711bc566 | 12 | #define ACCEL_MAG_SA0 0 |
hazheng | 59:b709711bc566 | 13 | #define FXOS8700CQ_SLAVE_ADDR 0x1E |
hazheng | 59:b709711bc566 | 14 | #elif defined(ACCEL_MAG_SA1_0) && defined(ACCEL_MAG_SA0_1) |
hazheng | 59:b709711bc566 | 15 | #define ACCEL_MAG_SA1 0 |
hazheng | 59:b709711bc566 | 16 | #define ACCEL_MAG_SA0 1 |
hazheng | 59:b709711bc566 | 17 | #define FXOS8700CQ_SLAVE_ADDR 0x1D |
hazheng | 59:b709711bc566 | 18 | #elif defined(ACCEL_MAG_SA1_1) && defined(ACCEL_MAG_SA0_0) |
hazheng | 59:b709711bc566 | 19 | #define ACCEL_MAG_SA1 1 |
hazheng | 59:b709711bc566 | 20 | #define ACCEL_MAG_SA0 0 |
hazheng | 59:b709711bc566 | 21 | #define FXOS8700CQ_SLAVE_ADDR 0x1C |
hazheng | 59:b709711bc566 | 22 | #elif defined(ACCEL_MAG_SA1_1) && defined(ACCEL_MAG_SA0_1) |
hazheng | 59:b709711bc566 | 23 | #define ACCEL_MAG_SA1 1 |
hazheng | 59:b709711bc566 | 24 | #define ACCEL_MAG_SA0 1 |
hazheng | 59:b709711bc566 | 25 | #define FXOS8700CQ_SLAVE_ADDR 0x1F |
hazheng | 59:b709711bc566 | 26 | #else |
hazheng | 59:b709711bc566 | 27 | #error Must choose a SA0 and SA1 value for Accel and Mag |
hazheng | 59:b709711bc566 | 28 | #endif |
hazheng | 59:b709711bc566 | 29 | |
hazheng | 59:b709711bc566 | 30 | #define FXOS8700CQ_STATUS 0x00 |
hazheng | 59:b709711bc566 | 31 | |
hazheng | 59:b709711bc566 | 32 | #define FXOS8700CQ_WHOAMI 0x0D |
hazheng | 59:b709711bc566 | 33 | #define FXOS8700CQ_WHOAMI_VAL 0xC7 |
hazheng | 59:b709711bc566 | 34 | |
hazheng | 59:b709711bc566 | 35 | #define FXOS8700CQ_XYZ_DATA_CFG 0x0E |
hazheng | 59:b709711bc566 | 36 | |
hazheng | 59:b709711bc566 | 37 | #define FXOS8700CQ_CTRL_REG1 0x2A |
hazheng | 59:b709711bc566 | 38 | |
hazheng | 59:b709711bc566 | 39 | #define FXOS8700CQ_M_CTRL_REG1 0x5B |
hazheng | 59:b709711bc566 | 40 | |
hazheng | 59:b709711bc566 | 41 | #define FXOS8700CQ_M_CTRL_REG2 0x5C |
hazheng | 59:b709711bc566 | 42 | |
hazheng | 59:b709711bc566 | 43 | #define FXOS8700CQ_READ_LEN 13 // status plus 6 channels = 13 bytes |
hazheng | 59:b709711bc566 | 44 | |
hazheng | 59:b709711bc566 | 45 | #include <mbed.h> |
hazheng | 59:b709711bc566 | 46 | |
hazheng | 59:b709711bc566 | 47 | #ifdef __cplusplus |
hazheng | 59:b709711bc566 | 48 | extern "C" { |
hazheng | 59:b709711bc566 | 49 | #endif |
hazheng | 59:b709711bc566 | 50 | |
hazheng | 59:b709711bc566 | 51 | struct imu_vec3 |
hazheng | 59:b709711bc566 | 52 | { |
hazheng | 59:b709711bc566 | 53 | uint16_t x; |
hazheng | 59:b709711bc566 | 54 | uint16_t y; |
hazheng | 59:b709711bc566 | 55 | uint16_t z; |
hazheng | 59:b709711bc566 | 56 | }; |
hazheng | 59:b709711bc566 | 57 | |
hazheng | 59:b709711bc566 | 58 | uint8_t imu_manager_init(); |
hazheng | 59:b709711bc566 | 59 | |
hazheng | 59:b709711bc566 | 60 | void imu_manager_update(); |
hazheng | 59:b709711bc566 | 61 | |
hazheng | 59:b709711bc566 | 62 | const volatile struct imu_vec3* imu_manager_get_accl(); |
hazheng | 59:b709711bc566 | 63 | |
hazheng | 59:b709711bc566 | 64 | const volatile struct imu_vec3* imu_manager_get_magt(); |
hazheng | 59:b709711bc566 | 65 | |
hazheng | 59:b709711bc566 | 66 | #ifdef __cplusplus |
hazheng | 59:b709711bc566 | 67 | } |
hazheng | 59:b709711bc566 | 68 | #endif |
hazheng | 59:b709711bc566 | 69 | |
hazheng | 59:b709711bc566 | 70 | #endif //IMU_MANAGER_H |