/* * Compass.h * * Created: 1/26/2012 9:14:02 AM * Author: Andrew Kooiman */ #ifndef COMPASS_H #include "oulib.h" #include "i2c_isr.h" #define COMPASS_STANDBY_MODE 0 #define COMPASS_QUERY_MODE 1 #define COMPASS_CONTINUOUS_MODE 2 #define COMPASS_HZ_1 0 #define COMPASS_HZ_5 32 #define COMPASS_HZ_10 64 #define COMPASS_HZ_20 96 #define COMPASS_PERIODIC_SET_RESET_OFF 0 #define COMPASS_PERIODIC_SET_RESET_ON 16 /************************************************************************/ /* Prepares the processor for I2C communication, the compass for */ /* operation, and enables global interrupts */ /************************************************************************/ void compass_init(void); /************************************************************************/ /* Queries the compass for the present heading. This method assumes */ /* that the compass is in query mode. */ /* The heading will be returned in the range 0 ... 3599 in tenths of a */ /* degree. */ /************************************************************************/ int16_t compass_query(void); /************************************************************************/ /* Initiates a calibration routine. The user will have to spin the */ /* compass through two full rotations. */ /************************************************************************/ void compass_calib_start(void); /************************************************************************/ /* Ends the calibration routine. The user should have already called */ /* start_calibration(void) and should have rotated the compass two times in */ /* the past 6 seconds - 3 minutes (20 seconds ideal). */ /************************************************************************/ void compass_calib_end(void); /************************************************************************/ /* Sets the mode of the compass using the format described on the data */ /* sheet. The flag bits are defined at the top of this file, and may */ /* be added together. */ /************************************************************************/ void set_mode(uint8_t mode); /************************************************************************/ /* Saves the current operating mode to EEPROM */ /************************************************************************/ void save_settings_to_EEPROM(void); #endif