An eCompass library only for use on FPU enabled platforms like the K64F
Dependents: K64F_eCompass_LCD rtos_compass K64F_eCompass GPS_6Axis_DataLogger_SD_UDP ... more
Fork of eCompass_Lib by
eCompass_Lib.h
00001 /************************************************************************************************ 00002 * File : eCompass.h 00003 * Date : 18/07/2013 00004 * Purpose : Wi-Go eCompass interface and hardware peripherals definition 00005 * Author : Frank Vannieuwkerke 00006 * Description: ported from Avnet Wi-Go code 00007 * For additional information on Wi-Go please visit 00008 * www.em.avnet.com/wi-go 00009 * Additional info on the Freescale eCompass software is available at 00010 * http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=E-Compass 00011 ************************************************************************************************/ 00012 #ifndef ECOMPASS_H__ 00013 #define ECOMPASS_H__ 00014 00015 #include "mbed.h" 00016 #include "MotionSensor.h" 00017 00018 00019 #ifdef __cplusplus 00020 extern "C" { 00021 #endif 00022 00023 typedef short int16; 00024 typedef unsigned short uint16; 00025 typedef unsigned int uint32; 00026 typedef unsigned char byte; 00027 00028 extern void run_eCompass(void); 00029 extern void init_eCompass(void); 00030 extern void calibrate_eCompass(void); 00031 00032 #define NED_COMPASS 1 00033 #define ANDROID_COMPASS 2 00034 #define WINDOWS_COMPASS 3 00035 00036 // Macros for constants used in fractional decimal conversion routine. 00037 // FRAC_2d1 = 2^-1 = 0.5 00038 // FRAC_2d2 = 2^-2 = 0.25 etc... 00039 #define FRAC_2d1 5000 00040 #define FRAC_2d2 2500 00041 #define FRAC_2d3 1250 00042 #define FRAC_2d4 625 00043 00044 // sensor scaling constants 00045 #define FCOUNTSPERUT 10.0F // sensor specific: MAG3110 provide 10 counts / uT 00046 #define FCOUNTSPERG 4096.0F // sensor specific: MMA8451 provide 4096 counts / g in 2g mode 00047 00048 00049 00050 typedef struct { 00051 // Always 1 00052 uint16 packet_id; 00053 // Light sensor 00054 int16 light; 00055 // Counts at a 0.020MS interval when sensor data is processed 00056 uint32 timestamp; 00057 // Ineeger data from accelerometer 00058 int16 acc_x, acc_y, acc_z; 00059 // Integer data from Magnetometer 00060 int16 mag_x, mag_y, mag_z; 00061 // Roll, Pitch, Yaw and Compass from the eCompass algorithm 00062 int16 roll, pitch, yaw, compass; 00063 // Altitude and temperature 00064 int16 alt, temp; 00065 // Data from Accelerometer converted to floating point 00066 float fax, fay, faz; 00067 // Accelerometer data converted to G's 00068 float fGax, fGay, fGaz; 00069 // Data from Magnetometer converted to floating point 00070 float fmx, fmy, fmz; 00071 // Magnetometer data converted to UT's 00072 float fUTmx, fUTmy, fUTmz; 00073 float q0, q1, q2, q3; 00074 00075 } axis6_t; 00076 00077 class eCompass 00078 { 00079 public: 00080 eCompass(); 00081 void run(MotionSensorDataCounts &acc_raw, MotionSensorDataCounts &mag_raw); 00082 void calibrate(void); 00083 void init(void); 00084 00085 00086 private: 00087 }; 00088 00089 #ifdef __cplusplus 00090 } 00091 #endif 00092 00093 #endif
Generated on Tue Jul 12 2022 20:37:41 by 1.7.2