LIS3DH / STMicroelectronics / MEMS motion sensor, 3-axis accelerometer library

Dependents:   GR-PEACH_test_wo_rtos GR-PEACH_test_on_rtos_works_well Skywire_Demo_3 Skywire_Kinetis_K64_demo ... more

Files at this revision

API Documentation at this revision

Comitter:
kenjiArai
Date:
Sun Sep 07 01:26:25 2014 +0000
Parent:
0:5d5aac272642
Child:
2:cc943f8d76a2
Commit message:
Added I2C clock frequency change function

Changed in this revision

LIS3DH.cpp Show annotated file Show diff for this revision Revisions of this file
LIS3DH.h Show annotated file Show diff for this revision Revisions of this file
--- a/LIS3DH.cpp	Fri Aug 29 13:27:20 2014 +0000
+++ b/LIS3DH.cpp	Sun Sep 07 01:26:25 2014 +0000
@@ -7,7 +7,7 @@
  *  http://www.page.sannet.ne.jp/kenjia/index.html
  *  http://mbed.org/users/kenjiArai/
  *      Created: July      14th, 2014 
- *      Revised: August    29th, 2014
+ *      Revised: September  7th, 2014
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
@@ -24,7 +24,8 @@
 }
 
 LIS3DH::LIS3DH (I2C& p_i2c,
-    uint8_t addr, uint8_t data_rate, uint8_t fullscale) : i2c(p_i2c) { 
+    uint8_t addr, uint8_t data_rate, uint8_t fullscale) : i2c(p_i2c) {
+    i2c.frequency(400000); 
     initialize (addr, data_rate, fullscale);
 }
 
@@ -131,6 +132,10 @@
     return 1;
 }
 
+void LIS3DH::frequency(int hz) {
+    i2c.frequency(hz);
+}
+
 uint8_t LIS3DH::read_reg(uint8_t addr) {
     if (acc_ready == 1){
         dbf[0] = addr; 
--- a/LIS3DH.h	Fri Aug 29 13:27:20 2014 +0000
+++ b/LIS3DH.h	Sun Sep 07 01:26:25 2014 +0000
@@ -7,7 +7,7 @@
  *  http://www.page.sannet.ne.jp/kenjia/index.html
  *  http://mbed.org/users/kenjiArai/
  *      Created: July      14th, 2014 
- *      Revised: August    29th, 2014
+ *      Revised: September  7th, 2014
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
@@ -181,6 +181,12 @@
       */
     uint8_t data_ready();
 
+    /** Set I2C clock frequency
+      * @param freq.
+      * @return none
+      */
+    void frequency(int hz);
+
     /** Read register (general purpose)
       * @param register's address
       * @return register data