Framework of classes and program to measure tilt angles using accelerometers

Dependencies:   C12832 mbed

Fork of tilt_angles by Mark Petovello

Committer:
mpetovello
Date:
Fri Nov 25 15:18:28 2016 +0000
Revision:
1:64f1aefe1842
Parent:
0:3bffc1862262
Removed MMA7660 library (unnecessary)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mpetovello 0:3bffc1862262 1 /**
mpetovello 0:3bffc1862262 2 * File : ENGO333_I2C.h
mpetovello 0:3bffc1862262 3 * Created by : Chandra Tjhai
mpetovello 0:3bffc1862262 4 * Created on : September 10, 2016
mpetovello 0:3bffc1862262 5 *
mpetovello 0:3bffc1862262 6 * Description :
mpetovello 0:3bffc1862262 7 * This file contains a class to handle I2C bus operation for ENGO 333.
mpetovello 0:3bffc1862262 8 */
mpetovello 0:3bffc1862262 9
mpetovello 0:3bffc1862262 10 #ifndef ENGO333_I2C_H
mpetovello 0:3bffc1862262 11 #define ENGO333_I2C_H
mpetovello 0:3bffc1862262 12
mpetovello 0:3bffc1862262 13 #include "mbed.h"
mpetovello 0:3bffc1862262 14
mpetovello 0:3bffc1862262 15 /**
mpetovello 0:3bffc1862262 16 * Class
mpetovello 0:3bffc1862262 17 * A class to handle I2C read/write operation
mpetovello 0:3bffc1862262 18 */
mpetovello 0:3bffc1862262 19 class ENGO333_I2C
mpetovello 0:3bffc1862262 20 {
mpetovello 0:3bffc1862262 21 private:
mpetovello 0:3bffc1862262 22 I2C i2c; // Object for handling I2C bus operations
mpetovello 0:3bffc1862262 23
mpetovello 0:3bffc1862262 24 public:
mpetovello 0:3bffc1862262 25 /**
mpetovello 0:3bffc1862262 26 * Constructor
mpetovello 0:3bffc1862262 27 *
mpetovello 0:3bffc1862262 28 * Input
mpetovello 0:3bffc1862262 29 * sda = SDA or I2C serial data pin
mpetovello 0:3bffc1862262 30 * scl = SCL or I2C serial clock pin
mpetovello 0:3bffc1862262 31 */
mpetovello 0:3bffc1862262 32 ENGO333_I2C(PinName sda, PinName scl);
mpetovello 0:3bffc1862262 33
mpetovello 0:3bffc1862262 34 /**
mpetovello 0:3bffc1862262 35 * Destructor
mpetovello 0:3bffc1862262 36 */
mpetovello 0:3bffc1862262 37 ~ENGO333_I2C();
mpetovello 0:3bffc1862262 38
mpetovello 0:3bffc1862262 39 /**
mpetovello 0:3bffc1862262 40 * Function :
mpetovello 0:3bffc1862262 41 * Set I2C bus frequency
mpetovello 0:3bffc1862262 42 *
mpetovello 0:3bffc1862262 43 * Input :
mpetovello 0:3bffc1862262 44 * freq = desired frequency in Hz
mpetovello 0:3bffc1862262 45 */
mpetovello 0:3bffc1862262 46 void setSpeed(int freq);
mpetovello 0:3bffc1862262 47
mpetovello 0:3bffc1862262 48 /**
mpetovello 0:3bffc1862262 49 * Function :
mpetovello 0:3bffc1862262 50 * Write one byte data into device's register
mpetovello 0:3bffc1862262 51 *
mpetovello 0:3bffc1862262 52 * Input :
mpetovello 0:3bffc1862262 53 * deviceAddress = Device's I2C address
mpetovello 0:3bffc1862262 54 * registerAddress = Device's register address to be written on
mpetovello 0:3bffc1862262 55 * value = Value to be written on device's register address
mpetovello 0:3bffc1862262 56 */
mpetovello 0:3bffc1862262 57 void writeOneByte(char deviceAddress, char registerAddress, char value);
mpetovello 0:3bffc1862262 58
mpetovello 0:3bffc1862262 59 /**
mpetovello 0:3bffc1862262 60 * Function :
mpetovello 0:3bffc1862262 61 * Read one byte from device's register address
mpetovello 0:3bffc1862262 62 *
mpetovello 0:3bffc1862262 63 * Input :
mpetovello 0:3bffc1862262 64 * deviceAddress = Device's I2C address
mpetovello 0:3bffc1862262 65 * registerAddress = Device's register address to be read
mpetovello 0:3bffc1862262 66 *
mpetovello 0:3bffc1862262 67 * Return :
mpetovello 0:3bffc1862262 68 * One byte data read from device's register
mpetovello 0:3bffc1862262 69 */
mpetovello 0:3bffc1862262 70 char readOneByte(char deviceAddress, char registerAddress);
mpetovello 0:3bffc1862262 71
mpetovello 0:3bffc1862262 72 /**
mpetovello 0:3bffc1862262 73 * Function :
mpetovello 0:3bffc1862262 74 * Read multiple bytes from device's register address
mpetovello 0:3bffc1862262 75 *
mpetovello 0:3bffc1862262 76 * Input :
mpetovello 0:3bffc1862262 77 * deviceAddress = Device's I2C address
mpetovello 0:3bffc1862262 78 * registerAddress = Device's register address to be read
mpetovello 0:3bffc1862262 79 * value = Array of data to store values read from device's register
mpetovello 0:3bffc1862262 80 */
mpetovello 0:3bffc1862262 81 void readBytes(char deviceAddress, char registerAddress, char* value, int length);
mpetovello 0:3bffc1862262 82 };
mpetovello 0:3bffc1862262 83
mpetovello 0:3bffc1862262 84 #endif