Changeset - 9a399fff43f2
[Not reviewed]
default
0 4 0
mkroening@CL-ENS241-07.cedarville.edu - 12 years ago 2013-03-14 16:28:30
mkroening@CL-ENS241-07.cedarville.edu
Accelerometer firmware
4 files changed with 34 insertions and 2 deletions:
0 comments (0 inline, 0 general)
slave/slave/config.h
Show inline comments
 
/*
 
 * config.h
 
 *
 
 * Created: 10/25/2012 10:00:09 PM
 
 *  Author: mkanning
 
 */
 
 
 
 #ifndef CONFIG_H_
 
 #define CONFIG_H_
 
 
 #define F_CPU 11059200				// Clock frequency (used in calculations)
 
 
//Serial
 
#define USART0_BAUDRATE 115200
 
#define USART1_BAUDRATE 115200 
 
 
// Circular serial buffer size. Must be at least MAX_CMD_LEN + 5
 
#define BUFFER_SIZE 32
 
 
// Maximum payload size of command
 
#define MAX_PAYLOAD_LEN 16
 
 
// Number of datatypes to transmit per module type
 
#define DATATYPES_GENERIC 3
 
#define DATATYPES_SENSOR 8
 
#define DATATYPES_GEIGER 4
 
#define DATATYPES_CAMERA 3
 
 
//Sensors and IO
 
#define SENSOR_LOOP 100				// Frequency of sensor reads (in ms) (should be 200)
 
#define HEATER_THRESHOLD 40			// Temperature threshold in Fahrenheit where heater is activated
 
 
 //I2C Addresses
 
 #define EEPROM_ADDR 0xA0		// Read 0xA1 - Write 0xA0
 
 #define BOARDTEMP_ADDR 0x90	// Read 0x91 - Write 0x90
 
 #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
 
 
 
 
 #endif /* CONFIG_H_ */
 
\ No newline at end of file
slave/slave/lib/cameras.c
Show inline comments
 
/*
 
 * cameras.c
 
 *
 
 * Created: 11/19/2012 9:25:23 PM
 
 *  Author: kripperger
 
 */ 
 
 
 
 #include <inttypes.h>
 
 #include <avr/io.h>
 
 #include <avr/interrupt.h>
 
 #include "../config.h"
 
 #include <util/delay.h>
 
 #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
slave/slave/lib/cameras.h
Show inline comments
 
/*
 
 * cameras.h
 
 *
 
 * Created: 11/19/2012 9:25:36 PM
 
 *  Author: kripperger
 
 */ 
 
 
 
#ifndef CAMERAS_H_
 
#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
slave/slave/modules.c
Show inline comments
 
@@ -94,51 +94,52 @@
 
	PCICR |= (1 << PCIE0);		// Enable ioc section PCIF0
 
	
 
	// Setup for interrupt from Timer2
 
	ASSR &= ~(1 << EXCLK);	// Disable external clock input (enabling crystal use)
 
	ASSR |= (1 << AS2);		// Enable timer2 async mode with an external crystal	
 
	_delay_ms(250);			// Let external 32KHz crystal stabilize
 
	TCCR2B = 0x05;			// Set the prescaler to 128: 32.768kHz / 128 = 1Hz overflow
 
	TIFR2 = 0x01;			// Reset timer2 overflow interrupt flag
 
	TIMSK2 = 0x01;			// Enable interrupt on overflow
 
	
 
	sei();					// Enable all interrupts
 
 }
 
  
 
  
 
  
 
 void modules_cameras_setup()
 
 {
 
	  	  
 
 }
 
  
 
 
 void modules_generic()
 
 {
 
	// Gathers data and performs functions for generic daughter board
 
	
 
 }
 
  
 
 void modules_sensors()
 
 {
 
	// Gathers data and performs functions for sensor daughter board
 
	sensors_readBoardTemp();		//Data Read
 
	sensors_readSpiTemp();			//Data Read
 
	sensors_readPressure();			//Data Read
 
	//sensors_readHumid();			//Data Read
 
	sensors_readLux();				//Data Read
 
	 
 
 }
 
  
 
 void modules_geiger()
 
 {
 
	// No data gatering function needed for geiger daughter board
 
		// This is taken care of in interrupt (See geiger.c)
 
	  
 
 }
 
  
 
 void modules_cameras()
 
 {
 
	// Gathers data and performs functions for cameras daughter board
 
	cameras_readAccelXYZ();
 
  
 
 } 
 
  
 
\ No newline at end of file
0 comments (0 inline, 0 general)