Basic library for interfacing the AK8975 using I2C. It does not include more advanced functions. The datasheet does not include what the self-test should return for example, so this library does not include the self-test function.

Revision:
1:76f65416ae1b
Parent:
0:bceb91239894
--- a/AK8975.h	Mon May 07 11:36:18 2012 +0000
+++ b/AK8975.h	Mon May 07 12:01:10 2012 +0000
@@ -1,38 +1,6 @@
 /* Library for AK8975 digital compass IC, for use with I2C 
 
 This library contains basic functionality, if you want more, make it ;) 
-
-
-Example program:
-
-#include "mbed.h"
-#include "AK8975.h"
-
-DigitalOut led1(LED1);
-Serial pc(USBTX, USBRX); // tx, rx
-AK8975 mag(p9,p10,0x0E);
-
-
-int main() {
-    int data[3];
-    if (mag.testConnection())
-        pc.printf("Connection succeeded. \n");
-    else
-        pc.printf("Connection failed. \n");
-    
-     while(1) {
-        led1=!led1;
-        mag.startMeasurement();
-        wait(0.5);                      //(or use the isReady() function)
-        mag.getAll(data);
-        pc.printf("X: %d", data[0]);
-        pc.putc('\n');
-        pc.printf("Y: %d", data[1]);
-        pc.putc('\n');
-        pc.printf("Z: %d", data[2]);
-        pc.putc('\n');
-    }
-}
          
 */
 
@@ -67,6 +35,40 @@
 
 #define AK8975_SENSITIVITY  0.3
 
+/** AK8975 magnetometer/digital compass simple library.
+  *
+  * Example:
+  * @code
+  * #include "mbed.h"
+  * #include "AK8975.h"
+  * 
+  * DigitalOut led1(LED1);
+  * Serial pc(USBTX, USBRX); // tx, rx
+  * AK8975 mag(p9,p10,0x0E);
+  * 
+  * 
+  * int main() {
+  *     int data[3];
+  *     if (mag.testConnection())
+  *         pc.printf("Connection succeeded. \n");
+  *     else
+  *         pc.printf("Connection failed. \n");
+  *     
+  *      while(1) {
+  *         led1=!led1;
+  *         mag.startMeasurement();
+  *         wait(0.5);                      //(or use the isReady() function)
+  *         mag.getAll(data);
+  *         pc.printf("X: %d", data[0]);
+  *         pc.putc('\n');
+  *         pc.printf("Y: %d", data[1]);
+  *         pc.putc('\n');
+  *         pc.printf("Z: %d", data[2]);
+  *         pc.putc('\n');
+  *     }
+  * }
+  * @endcode
+  */
 class AK8975 {
     public:
      /**