completed code

Dependencies:   mbed

Committer:
evenbrownie
Date:
Thu Nov 08 20:48:47 2018 +0000
Revision:
0:f43994f44684
Child:
1:491bd986ce22
All I put in were the addresses from the beginning

Who changed what in which revision?

UserRevisionLine numberNew contents of line
evenbrownie 0:f43994f44684 1 /*
evenbrownie 0:f43994f44684 2 * @author: Natasha Sarkar, 2018
evenbrownie 0:f43994f44684 3 */
evenbrownie 0:f43994f44684 4
evenbrownie 0:f43994f44684 5 #include "mbed.h"
evenbrownie 0:f43994f44684 6 #include "sensor_fusion.h"
evenbrownie 0:f43994f44684 7
evenbrownie 0:f43994f44684 8 MPU6050::MPU6050(PinName sda, PinName scl): i2c_object(sda, scl) {
evenbrownie 0:f43994f44684 9 i2c_object.frequency(400000);
evenbrownie 0:f43994f44684 10 }
evenbrownie 0:f43994f44684 11
evenbrownie 0:f43994f44684 12 void MPU6050::start(void) {
evenbrownie 0:f43994f44684 13 /** TO DO
evenbrownie 0:f43994f44684 14 *
evenbrownie 0:f43994f44684 15 * CONFIGURE THE FOLLOWING REGISTERS ACCORDING TO THE DATASHEET:
evenbrownie 0:f43994f44684 16 *
evenbrownie 0:f43994f44684 17 * PWR_MGMT_1 register to take the IMU out of sleep mode
evenbrownie 0:f43994f44684 18 * ACCEL_CONFIG register to the smallest possible full-scale range (why might we want to do that?)
evenbrownie 0:f43994f44684 19 * GYRO_CONFIG register to the largest possible full-scale range to enable the detection of high-velocity rotations
evenbrownie 0:f43994f44684 20 * CONFIG register to the largest possible bandwidth.
evenbrownie 0:f43994f44684 21 */
evenbrownie 0:f43994f44684 22
evenbrownie 0:f43994f44684 23 /** YOUR CODE GOES BELOW */
evenbrownie 0:f43994f44684 24
evenbrownie 0:f43994f44684 25 }
evenbrownie 0:f43994f44684 26
evenbrownie 0:f43994f44684 27 bool MPU6050::read_raw(float *gx, float *gy, float *gz, float *ax, float *ay, float *az) {
evenbrownie 0:f43994f44684 28 /** TO DO
evenbrownie 0:f43994f44684 29 *
evenbrownie 0:f43994f44684 30 * GET THE RAW READINGS FROM THE ACCELEROMETER/GYRSCOPE
evenbrownie 0:f43994f44684 31 *
evenbrownie 0:f43994f44684 32 * Store the readings in the floats pointed to by the given float pointers.
evenbrownie 0:f43994f44684 33 */
evenbrownie 0:f43994f44684 34
evenbrownie 0:f43994f44684 35 /** YOUR CODE GOES BELOW */
evenbrownie 0:f43994f44684 36
evenbrownie 0:f43994f44684 37 }
evenbrownie 0:f43994f44684 38
evenbrownie 0:f43994f44684 39 bool MPU6050::data_ready(void) {
evenbrownie 0:f43994f44684 40 /** TO DO
evenbrownie 0:f43994f44684 41 *
evenbrownie 0:f43994f44684 42 * CHECK THE INT_STATUS REGISTER TO DETERMINE IF DATA IS READY
evenbrownie 0:f43994f44684 43 *
evenbrownie 0:f43994f44684 44 * Return true if it is ready, false otherwise.
evenbrownie 0:f43994f44684 45 */
evenbrownie 0:f43994f44684 46
evenbrownie 0:f43994f44684 47 /** YOUR CODE GOES BELOW */
evenbrownie 0:f43994f44684 48 }
evenbrownie 0:f43994f44684 49
evenbrownie 0:f43994f44684 50 bool MPU6050::write_reg(int addr, int reg, char buf) {
evenbrownie 0:f43994f44684 51 /** TO DO
evenbrownie 0:f43994f44684 52 *
evenbrownie 0:f43994f44684 53 * IMPELEMENT THIS FUNCTION
evenbrownie 0:f43994f44684 54 *
evenbrownie 0:f43994f44684 55 * See the documentation in sensor_fusion.h for detail.
evenbrownie 0:f43994f44684 56 */
evenbrownie 0:f43994f44684 57
evenbrownie 0:f43994f44684 58 /** YOUR CODE GOES BELOW */
evenbrownie 0:f43994f44684 59 }
evenbrownie 0:f43994f44684 60
evenbrownie 0:f43994f44684 61 bool MPU6050::read_reg(char addr, char reg, char *buf, int length) {
evenbrownie 0:f43994f44684 62 /** TO DO
evenbrownie 0:f43994f44684 63 *
evenbrownie 0:f43994f44684 64 * IMPLEMENT THIS FUNCTION
evenbrownie 0:f43994f44684 65 *
evenbrownie 0:f43994f44684 66 * See the documentation in sensor_fusion.h for detail.
evenbrownie 0:f43994f44684 67 */
evenbrownie 0:f43994f44684 68
evenbrownie 0:f43994f44684 69 /** YOUR CODE GOES BELOW */
evenbrownie 0:f43994f44684 70 }
evenbrownie 0:f43994f44684 71