Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: I2C_Temp_sensor IR_Helicopter_Controller
Fork of AccelSensor by
AccelSensor.h
00001 #ifndef MBED_NOKIALCD_H 00002 #define MBED_NOKIALCD_H 00003 00004 #include "mbed.h" 00005 00006 //http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Accelerometers/MMA8452Q.pdf 00007 //http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Accelerometers/MMA8452Q-Breakout-v11-fixed.pdf 00008 //http://cache.freescale.com/files/sensors/doc/app_note/AN4069.pdf 00009 00010 // The SparkFun breakout board defaults to 1, set to 0 if SA0 jumper on the bottom of the board is set 00011 #define ADDRESS 0x1D // 0x1D if SA0 is high, 0x1C if low 00012 //Define a few of the registers that we will be accessing on the MMA8452 00013 #define OUT_X_MSB 0x01 //1 00014 #define XYZ_DATA_CFG 0x0E //14 00015 #define WHO_AM_I 0x0D //13 00016 #define CTRL_REG1 0x2A //42 00017 #define GSCALE 2 // Sets full-scale range to +/-2, 4, or 8g. Used to calc real g values. 00018 00019 class AccelSensor { 00020 public: 00021 AccelSensor(PinName sda, PinName scl); 00022 void active(); 00023 void standby(); 00024 void init(); 00025 void readData(int *destination); 00026 private: 00027 void readRegisters(char reg, int range, char* dest); 00028 char readRegister(char reg); 00029 void writeRegister(char reg, char data); 00030 I2C _i2c; 00031 }; 00032 00033 #endif
Generated on Sun Jul 17 2022 17:42:58 by
