Changeset - 1b16ee7a83df
[Not reviewed]
default
0 2 0
ethanzonca@CL-ENS241-08.cedarville.edu - 12 years ago 2013-04-29 20:55:03
ethanzonca@CL-ENS241-08.cedarville.edu
Fixed pin reading
2 files changed with 12 insertions and 3 deletions:
0 comments (0 inline, 0 general)
slave/slave/lib/sensors.c
Show inline comments
 
@@ -245,30 +245,38 @@ void sensors_readAnalog(uint8_t pin)
 
	
 
	analogL = ADCL;				// Read low battery byte from ADC (all 8 bits)
 
	analog[pin] = ADCH;				// Read high battery byte from ADC (only two LSBs)
 
	
 
	analogL = ADCL;				// Second Read low battery byte from ADC (all 8 bits)
 
	analog[pin] = ADCH;				// Second Read high battery byte from ADC (only two LSBs)
 
	
 
	analog[pin] = analog[pin] << 8;
 
	analog[pin] |= analogL;
 
	analog[pin] = (analog[pin] * 10.0) / 67.4;
 
}
 
 
void sensors_readDigital(uint8_t pin)
 
void sensors_readDigitalPORTA(uint8_t pin)
 
{
 
	DDRA &= ~(1 << pin);		// Set pin to input
 
	digital = PINA;
 
	digital |= (~(1 << pin)) & PINA;
 
}
 
 
void sensors_readDigitalPORTD(uint8_t pin)
 
{
 
	if(pin > 3 && pin < 7)
 
	{
 
		DDRD &= ~(1 << pin);		// Set pin to input
 
		digital |= (~(1 << pin)) & PIND;
 
	}
 
}
 
 
int16_t sensors_getSpiTemp(void)	// Gets spi temperature from variable
 
{
 
	return spiTemp;
 
}
 
 
int8_t sensors_getBoardTemp(void)	// Gets board temperature from variable
 
{
 
	return boardTemp;
 
}
 
 
int32_t sensors_getPressure(void)	// Gets pressure from variable
slave/slave/lib/sensors.h
Show inline comments
 
@@ -9,25 +9,26 @@
 
#ifndef SENSORS_H_
 
#define SENSORS_H_
 
 
 
void sensors_setupPressure(void);	// Reads pressure calibration values
 
void sensors_readSpiTemp(void);		// Reads spi temperature
 
void sensors_readBoardTemp(void);	// Reads board temperature
 
void sensors_readPressure(void);	// Reads pressure
 
void sensors_readHumid(void);		// Reads humidity
 
void sensors_readLux(void);			// Reads lux
 
void sensors_readBatt(void);		// Reads battery voltage from ADC
 
void sensors_readAnalog(uint8_t pin);	// Reads generic analog voltage from ADC
 
void sensors_readDigital(uint8_t pin);	// Reads generic analog voltage from ADC
 
void sensors_readDigitalPORTA(uint8_t pin);	// Read digital pin on PORTA
 
void sensors_readDigitalPORTD(uint8_t pin); // Read digital pin on PORTD
 
 
int16_t sensors_getSpiTemp(void);	// Gets spi temperature from variable
 
int8_t sensors_getBoardTemp(void);	// Gets board temperature from variable
 
int32_t sensors_getPressure(void);	// Gets pressure from variable
 
uint16_t sensors_getHumid(void);	// Gets humidity from variable
 
uint32_t sensors_getLux(void);		// Gets lux from variable
 
uint16_t sensors_getBatt(void);		// Gets battery voltage from variable
 
uint32_t sensors_getAltitude(void);	// Gets altitude from variable
 
int16_t sensors_getAnalog(uint8_t pin);		// Gets battery voltage from variable
 
uint8_t sensors_getDigital(uint8_t pin);		// Gets battery voltage from variable
 
 
#endif /* SENSORS_H_ */
 
\ No newline at end of file
0 comments (0 inline, 0 general)