Team H - TVZ Seminar / Library for QMC5883L
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers QMC5883L.h Source File

QMC5883L.h

00001 #ifndef QMC5883L_H
00002 #define QMC5883L_H
00003 
00004 #include "mbed.h"
00005 #include "math.h"
00006 
00007 #define pi 3.14159265359 
00008 
00009 /* Registri */
00010 #define OUT_X_LSB    0x00 //ro - read only
00011 #define OUT_X_MSB    0x01 //ro
00012 #define OUT_Y_LSB    0x02 //ro
00013 #define OUT_Y_MSB    0x03 //ro
00014 #define OUT_Z_LSB    0x04 //ro
00015 #define OUT_Z_MSB    0x05 //ro
00016 #define STATUS       0x06 //ro
00017 #define TEMP_LSB     0x07 //ro
00018 #define TEMP_MSB     0x08 //ro
00019 #define CONTROL_A    0x09 //rw - read write
00020 #define CONTROL_B    0x0A //rw
00021 #define SET_RESET    0x0B //rw
00022 #define CHIP_ID      0x0D //ro 
00023 
00024 
00025 
00026 class QMC5883L
00027 {
00028     public:
00029         QMC5883L(PinName sda, PinName scl);
00030         void    setRange(int range);    //postavi range 2G ili 8G (2 ili 8)
00031         void    init();  
00032         short   getXvalue();
00033         short   getYvalue();
00034         short   getZvalue();
00035         float   getTemp();
00036         double  getHeading();
00037         
00038     private:
00039     
00040         void QMC5883L_w(char QMC5883L_reg, char QMC5883L_data); 
00041         char QMC5883L_r(char QMC5883L_reg); 
00042         short   range_data;
00043         float   mRes;  
00044         
00045      I2C QMC5883L_i2c;
00046 };
00047 
00048 #endif