Changeset - f859ce69ebdb
[Not reviewed]
default
0 4 0
kripperger@CL-SEC241-09.cedarville.edu - 12 years ago 2013-02-01 17:06:48
kripperger@CL-SEC241-09.cedarville.edu
Master comms
4 files changed with 39 insertions and 3 deletions:
0 comments (0 inline, 0 general)
slave/slave/lib/i2c.h
Show inline comments
 
@@ -51,15 +51,15 @@ unsigned char i2c_readNak(void);	//read 
 
 
unsigned char i2c_readX(unsigned char ack);	//read one byte from the I2C device. Implemented as a macro, which calls either i2c_readAck or i2c_readNak
 
#define i2c_readX(ack)  (ack) ? i2c_readAck() : i2c_readNak(); 
 
	//When ack is 1: send ack, request more data from device
 
	//When ack is 0: send nak, read is followed by a stop condition
 
	//Returns byte read from I2C device
 
 
void i2c_write(unsigned char addr, unsigned char reg, unsigned char data); //Does complete write. Can be used as stand alone function.
 
 
unsigned char i2c_read(unsigned char addr, unsigned char reg);
 
 
/////////////////added for humidity
 
unsigned char i2c_read16(unsigned char addr);
 
uint16_t i2c_read16(unsigned char addr);
 
 
#endif /* I2C_H_ */
 
\ No newline at end of file
slave/slave/lib/masterComm.c
Show inline comments
 
@@ -55,33 +55,65 @@ void masterComm_types()
 
		case 3:
 
			// Camera
 
			dataTypes = DATATYPES_CAMERA;
 
			break;
 
			
 
		default:
 
			dataTypes = DATATYPES_GENERIC;
 
			break;
 
	}
 
}
 
 
 
void masterComm_packetSend_unsigned(uint8_t id, uint32_t data)
 
{
 
	serial0_sendChar('[');
 
	snprintf(buff2,64,"%u%u",id,data);
 
	serial0_sendString(buff2);
 
	serial0_sendChar(']');
 
	serial0_sendChar(masterComm_checksum(buff2));
 
}
 
 
void masterComm_packetSend_signed(uint8_t id, int32_t data)
 
{
 
	serial0_sendChar('[');
 
	snprintf(buff2,64,"%u%d",id,data);
 
	serial0_sendString(buff2);
 
	serial0_sendChar(']');
 
	serial0_sendChar(masterComm_checksum(buff2));
 
}
 
 
 
 
void masterComm_modules()
 
{
 
	// Send BoardTemperature (Common for all modules)
 
	masterComm_packetSend_signed(0,sensors_getBoardTemp());
 
 
	
 
	// Send Heater Status (Common for all modules)
 
	serial0_sendChar('[');
 
	snprintf(buff2,64,"0%u",sensors_getBoardTemp());
 
	snprintf(buff2,64,"1%u",/*Heater Status Function Here */2);
 
	serial0_sendString(buff2);
 
	serial0_sendChar(']');	
 
	serial0_sendChar(masterComm_checksum(buff2));	
 
	
 
	// Send Battery Level (Common for all modules)
 
	serial0_sendChar('[');
 
	snprintf(buff2,64,"2%u",/*Heater Status Function Here */2);
 
	serial0_sendString(buff2);
 
	serial0_sendChar(']');	
 
	serial0_sendChar(masterComm_checksum(buff2));	
 
	
 
	
 
	// Send module specific sensor readings
 
	switch(io_getModuleId())
 
	{
 
		case 0:
 
			// Generic
 
			
 
			break;
 
		
 
		case 1:
 
			// Sensors
 
			
 
			// Send SPI Temperature (Air)
slave/slave/lib/masterComm.h
Show inline comments
 
@@ -2,21 +2,25 @@
 
 * masterComm.h
 
 *
 
 * Created: 1/22/2013 3:40:43 PM
 
 *  Author: kripperger
 
 */ 
 
 
#ifndef MASTERCOMM_H_
 
#define MASTERCOMM_H_
 
 
char masterComm_checksum(const char* stringPtr);
 
 
void masterComm_types();	// Calculates the number of types the module has
 
 
void masterComm_packetSend_unsigned(uint8_t id, uint32_t data);	//Creates the sensor specific packets and sends them
 
void masterComm_packetSend_signed(uint8_t id, int32_t data);
 
 
void masterComm_modules();	// Sends sensor data depending on module
 
 
void masterComm_checkParser();	// Runs parser and checks for data request
 
void masterComm_send();		// Sends data after being requested
 
 
 
 
 
#endif /* MASTERCOMM_H_ */
 
\ No newline at end of file
slave/slave/lib/sensors.c
Show inline comments
 
@@ -210,21 +210,21 @@ int16_t sensors_getSpiTemp(void)	// Gets
 
}
 
 
int8_t sensors_getBoardTemp(void)	// Gets board temperature from variable
 
{
 
	return boardTemp;
 
}
 
 
int32_t sensors_getPressure(void)	// Gets pressure from variable
 
{
 
	return pressure;
 
}
 
 
int sensors_getHumid(void)			// Gets relative humidity from variable
 
uint16_t sensors_getHumid(void)			// Gets relative humidity from variable
 
{
 
	return humid;
 
}
 
 
uint8_t sensors_getLight(void)		// Gets light from variable
 
{
 
	return light;
 
}
 
\ No newline at end of file
0 comments (0 inline, 0 general)