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
 
@@ -57,9 +57,9 @@ unsigned char i2c_readX(unsigned char ac
 
 
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
 
@@ -61,21 +61,53 @@ void masterComm_types()
 
			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
 
			
slave/slave/lib/masterComm.h
Show inline comments
 
@@ -8,12 +8,16 @@
 
#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
 
 
slave/slave/lib/sensors.c
Show inline comments
 
@@ -216,13 +216,13 @@ int8_t sensors_getBoardTemp(void)	// Get
 
 
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
 
{
0 comments (0 inline, 0 general)