Changeset - f7fad1196562
[Not reviewed]
default
0 3 0
mkroening@CL-ENS241-07.cedarville.edu - 12 years ago 2013-03-21 16:56:16
mkroening@CL-ENS241-07.cedarville.edu
Camera functions
3 files changed with 15 insertions and 5 deletions:
0 comments (0 inline, 0 general)
slave/slave/lib/cameras.c
Show inline comments
 
@@ -25,29 +25,24 @@
 
 {
 
	 xmsb = i2c_read(ACCEL_ADDR, 0x01);
 
	 ymsb = i2c_read(ACCEL_ADDR, 0x03);
 
	 zmsb = i2c_read(ACCEL_ADDR, 0x05);
 
 }
 
 
 
 void cameras_sendPulse()
 
 {
 
	 PORTA |= (1 << PA0);	// Pull pin on usb high
 
	 PORTA |= (1 << PA1);	// Pull pin on usb high
 
	 PORTA |= (1 << PA2);	// Pull pin on usb high
 
	 PORTA |= (1 << PA3);	// Pull pin on usb high
 
	 _delay_ms(250);
 
	 PORTA &= ~(1 << PA0);	// Pull pin on usb low
 
	 PORTA &= ~(1 << PA1);	// Pull pin on usb low
 
	 PORTA &= ~(1 << PA2);	// Pull pin on usb low
 
	 PORTA &= ~(1 << PA3);	// Pull pin on usb low
 
 }
 
 
 
 int8_t cameras_getAccelX()
 
 {
 
	 return xmsb;
 
 }
 
 
 
 int8_t cameras_getAccelY()
 
 {
 
	 return ymsb;
 
 }
 
 
slave/slave/modules.c
Show inline comments
 
@@ -6,26 +6,28 @@
 
 */ 
 
 
 #include <inttypes.h>
 
 #include <avr/io.h>
 
 #include <avr/interrupt.h>
 
 #include "config.h"
 
 #include <util/delay.h>
 
 #include "modules.h"
 
 #include "lib/spi.h"
 
 #include "lib/i2c.h"
 
 #include "lib/sensors.h"
 
 #include "lib/loopTimer.h"
 
 #include "lib/led.h"
 
 
 
 uint32_t lastPicture;
 
 uint8_t pulseOn;
 
 
 
 void modules_setup(uint8_t id)
 
 {
 
	switch(id)
 
	{
 
		case 0:
 
			modules_generic_setup();
 
			break;
 
			
 
		case 1:
 
			modules_sensors_setup();
 
			break;
 
@@ -100,24 +102,27 @@
 
	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
 
 }
 
  
 
  
 
  
 
 void modules_cameras_setup()
 
 {
 
	 lastPicture = time_millis();
 
	 pulseOn = time_millis();	 
 
	 
 
	 DDRA |= (1 << DDA0);	// Set PA0 to Output for Camera
 
	 DDRA |= (1 << DDA1);	// Set PA1 to Output for Camera
 
	 DDRA |= (1 << DDA2);	// Set PA2 to Output for Camera
 
	 DDRA |= (1 << DDA3);	// Set PA3 to Output for Camera
 
 }
 
  
 
 
 void modules_generic()
 
 {
 
	// Gathers data and performs functions for generic daughter board
 
	
 
 }
 
@@ -137,21 +142,30 @@
 
 {
 
	// 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();
 
		
 
		if ((time_millis() - pulseOn) > CAMERA_PULSE)
 
		{
 
			PORTA &= ~(1 << PA0);	// Pull pin on usb low
 
			PORTA &= ~(1 << PA1);	// Pull pin on usb low
 
			PORTA &= ~(1 << PA2);	// Pull pin on usb low
 
			PORTA &= ~(1 << PA3);	// Pull pin on usb low
 
			
 
		if ((time_millis() - lastPicture) > CAMERA_FREQ)	// Frequency of photos
 
		{
 
			cameras_sendPulse();
 
			lastPicture = time_millis();
 
		}
 
			
 
			pulseOn = time_millis();
 
		}
 
 
 } 
 
  
 
\ No newline at end of file
slave/slave/slave.c
Show inline comments
 
@@ -78,24 +78,25 @@ int main(void)
 
			
 
    while(1)
 
    {	
 
		wdt_reset();	// Resets WDT (to prevent restart)
 
		
 
		// Master communication
 
		masterComm_checkParser();	//Checks parser for data requests from master
 

	
 
		// Main slave operations
 
		if ((time_millis() - lastLoop) > SENSOR_LOOP)	// Uses program timer to run every so often. Time interval defined in config.h
 
		{
 
			led_on(0);
 
			
 
			sensors_readBatt();				// Read Battery level
 
			sensors_readBoardTemp();		// Read board temperature sensor (Common on all slaves) (Data Read)
 
			modules_run(io_getModuleId());	// Runs specific module functions (like data reading)
 
			
 
			io_regulateTemp();			// Gets board temperature and enables heater if below threshold
 

	
 
			snprintf(buff,128,"|ModuleID: %u |BoardTemp: %i |Millis: %lu |Lux: %lu |Pressure: %lu |Altitude: %lu |Battery: %u \r\n ",io_getModuleId(),sensors_getBoardTemp(),time_millis(),sensors_getLux(),sensors_getPressure(),sensors_getAltitude(),sensors_getBatt()); //DEBUG
 
			serial1_sendString(buff); //DEBUG
 
			
 
			led_off(0);
 
			lastLoop = time_millis();
 
			
0 comments (0 inline, 0 general)