Sample program for interfacing with PNI's RM3100 Breakout Board

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers RM3100MagDriver.h Source File

RM3100MagDriver.h

Go to the documentation of this file.
00001 /**
00002 * @file        RM3100MagDriver.h
00003 *
00004 * @brief       RM3100 driver
00005 * @authors     Betty Zhang, Daniel Delsuc
00006 * @date        03/03/2017
00007 * @copyright   (C) 2017 PNI Corp
00008 *
00009 * @copyright   This sample code is provided "as is" without express or implied warranty.
00010 *
00011 */
00012 #ifndef __RM3100_H_
00013 #define __RM3100_H_
00014 
00015 #include "main.h"
00016 
00017 
00018 #define MAX_I2C_WRITE               32
00019 
00020 #define RM3100_I2C_ADDRESS_7bit         0x20
00021 #define RM3100_I2C_ADDRESS_8bit         0x20 << 1 // MBED uses 8 bit address
00022 
00023 #define RM3100_MAG_REG              0x00
00024 #define RM3100_BEACON_REG           0x01
00025 #define RM3100_TMRC_REG             0x0B
00026 
00027 #define RM3100_REVID_REG            0x36
00028 #define RM3100_TEST3_REG            0x72
00029 
00030 #define RM3100_LROSCADJ_REG         0x63
00031 
00032 #define RM3100_LROSCADJ_VALUE       0xA7
00033 #define RM3100_SLPOSCADJ_VALUE      0x08 
00034 
00035 #define RM3100_ENABLED              0x79
00036 #define RM3100_DISABLED             0x00
00037 
00038 #define RM3100_QX2_REG      0x24
00039 #define RM3100_QX1_REG      0x25
00040 #define RM3100_QX0_REG      0x26
00041 #define RM3100_QY2_REG      0x27
00042 #define RM3100_QY1_REG      0x28
00043 #define RM3100_QY0_REG      0x29
00044 #define RM3100_QZ2_REG      0x2A
00045 #define RM3100_QZ1_REG      0x2B
00046 #define RM3100_QZ0_REG      0x2C
00047 
00048 #define RM3100_PNI_KEY1_REG     0x2D
00049 #define RM3100_PNI_KEY2_REG     0x2E
00050 
00051 #define RM3100_CCPX1_REG        0x04
00052 #define RM3100_CCPX0_REG        0x05
00053 #define RM3100_CCPY1_REG        0x06
00054 #define RM3100_CCPY0_REG        0x07
00055 #define RM3100_CCPZ1_REG        0x08
00056 #define RM3100_CCPZ0_REG        0x09
00057 
00058 #define RM3100_NOS_REG          0x0A
00059 
00060 #define CCP0    0xC8    /* 200 Cycle Count */
00061 #define CCP1    0x00
00062 #define NOS     0x01    /* Number of Samples for averaging*/
00063 
00064 #define TMRC    0x04    /* Default rate 125 Hz */
00065 
00066 /************************/
00067 /*     Enumerations     */
00068 /************************/
00069 /**
00070 * @enum SensorPowerMode
00071 *
00072 * @brief Possible sensor power modes supported.
00073 *
00074 */
00075 typedef enum {
00076     SensorPowerModePowerDown = 0,       
00077     SensorPowerModeSuspend = 1,       
00078     SensorPowerModeActive = 255,  
00079 } SensorPowerMode;
00080 
00081 /**
00082 * @enum SensorStatus
00083 *
00084 * @brief Sensor status results.
00085 */
00086 typedef enum {
00087     /* Valid Responses */
00088     SensorOK,                       /**< @brief Sensor responded with expected data. */
00089     SensorInitialized,              /**< @brief Sensor has been initialized. */
00090 
00091     /* Error Responses */
00092     SensorUnknownError,             /**< @brief An unknown error has occurred. */
00093     SensorErrorNonExistant,         /**< @brief Unable to communicate with sensor, sensor did not ACK. */
00094     SensorErrorUnexpectedDevice,    /**< @brief A different sensor was detected at the address. */
00095 
00096     SensorStatusPending = 255,      /**< @brief Reserved for internal used */
00097 } SensorStatus;
00098 
00099 #endif /* __RM3100_H_ */
00100