# HG changeset patch # User mkroening@CL-ENS241-07.cedarville.edu # Date 2013-03-14 16:28:30 # Node ID 9a399fff43f2af9e69298fba16efb4543fbca541 # Parent 0fb8009f1a0ad66036394c647d91d2b5038c3648 Accelerometer firmware diff --git a/slave/slave/config.h b/slave/slave/config.h --- a/slave/slave/config.h +++ b/slave/slave/config.h @@ -37,6 +37,7 @@ #define PRESSURE_ADDR 0xEE // Read 0xEF - Write 0xEE #define HUMID_ADDR 0x26 // Read 0x27 - Write 0x26 #define LIGHT_ADDR 0x94 // Read 0x95 - Write 0x94 + #define ACCEL_ADDR 0x38 // Read 0x39 - Write 0x38 #define RTC_ADDR 0xB2 //DEBUG [Used for testing] // Read 0xA3 - Write 0xA2 diff --git a/slave/slave/lib/cameras.c b/slave/slave/lib/cameras.c --- a/slave/slave/lib/cameras.c +++ b/slave/slave/lib/cameras.c @@ -13,5 +13,32 @@ #include #include "cameras.h" + #include "i2c.h" - \ No newline at end of file + int8_t xmsb; // Acceleration data in x-direction (MSB) + int8_t ymsb; // Acceleration data in y-direction (MSB) + int8_t zmsb; // Acceleration data in z-direction (MSB) + + + + void cameras_readAccelXYZ() + { + xmsb = i2c_read(ACCEL_ADDR, 0x01); + ymsb = i2c_read(ACCEL_ADDR, 0x03); + zmsb = i2c_read(ACCEL_ADDR, 0x05); + } + + int8_t cameras_getAccelX() + { + return xmsb; + } + + int8_t cameras_getAccelY() + { + return ymsb; + } + + int8_t cameras_getAccelZ() + { + return zmsb; + } \ No newline at end of file diff --git a/slave/slave/lib/cameras.h b/slave/slave/lib/cameras.h --- a/slave/slave/lib/cameras.h +++ b/slave/slave/lib/cameras.h @@ -10,7 +10,10 @@ #define CAMERAS_H_ +void cameras_readAccelXYZ(void); // Reads acceleration values - +int8_t cameras_getAccelX(void); // Returns x-acceleration +int8_t cameras_getAccelY(void); // Returns y-acceleration +int8_t cameras_getAccelZ(void); // Returns z-acceleration #endif /* CAMERAS_H_ */ \ No newline at end of file diff --git a/slave/slave/modules.c b/slave/slave/modules.c --- a/slave/slave/modules.c +++ b/slave/slave/modules.c @@ -139,6 +139,7 @@ void modules_cameras() { // Gathers data and performs functions for cameras daughter board + cameras_readAccelXYZ(); } \ No newline at end of file