some fixes, strange zeros in between

This commit is contained in:
hg
2014-11-05 19:19:20 +01:00
parent d16530898e
commit ed17033c78
4 changed files with 14 additions and 26 deletions

View File

@ -21,7 +21,7 @@ void setup() {
Serial.begin(9600);
delay(1000);
led(LED_PIN);
led.begin(LED_PIN);
ads1210.begin(ADC_CS_PIN, ADC_RDY_PIN);
}
@ -31,6 +31,6 @@ void loop() {
if (secondTick.check() == 1) {
led.toggle();
Serial << "AdcValue: " << adc1210.value << endl;
Serial << "AdcValue: " << _HEX(ads1210.value) << endl;
}
}

View File

@ -69,26 +69,14 @@ void ADS1210::exec() {
res.in[3] = 0;
disableCS();
Serial << "DOR4x8: " << _HEX(res.in[3]) << " " << _HEX(res.in[2]) << " " << _HEX(res.in[1]) << " " << _HEX(res.in[0]) << endl;
Serial << "DOR1x32: " << _HEX(res.out) << endl;
// Serial << "DOR4x8: " << _HEX(res.in[3]) << " " << _HEX(res.in[2]) << " " << _HEX(res.in[1]) << " " << _HEX(res.in[0]) << endl;
// Serial << "DOR1x32: " << _HEX(res.out) << endl;
value = res.out;
}
}
void ADS1210::disableRefO() const {
uint8_t cmr = readRegister(ADDR_CMR3);
cmr &= ~CMR_REFO;
writeRegister(ADDR_CMR3, cmr);
}
void ADS1210::enableRefO() const {
uint8_t cmr = readRegister(ADDR_CMR3);
cmr |= CMR_REFO;
writeRegister(ADDR_CMR3, cmr);
}
void ADS1210::setMode(uint8_t mode) const {
uint8_t cmr = readRegister(ADDR_CMR2);
cmr &= ~CMR_MD_Mask;

View File

@ -10,7 +10,7 @@
class ADS1210 {
public:
ADS1210() : value(0);
ADS1210() : value(0) {};
void begin(uint8_t csPin, uint8_t drdyPin);
void exec();
@ -55,11 +55,11 @@ private:
const uint8_t CMD_MD_Sleep = 0xc0;
const uint8_t CMR_Gain_Mask = (0x07 << 2);
const uint8_t CMD_Gain_1 = 0;
const uint8_t CMD_Gain_2 = (0x01 << 2);
const uint8_t CMD_Gain_4 = (0x02 << 2);
const uint8_t CMD_Gain_8 = (0x03 << 2);
const uint8_t CMD_Gain_16 = (0x04 << 2);
const uint8_t CMR_Gain_1 = 0;
const uint8_t CMR_Gain_2 = (0x01 << 2);
const uint8_t CMR_Gain_4 = (0x02 << 2);
const uint8_t CMR_Gain_8 = (0x03 << 2);
const uint8_t CMR_Gain_16 = (0x04 << 2);
// bit values
// INSR

8
led.h
View File

@ -15,18 +15,18 @@ public:
void on() {
m_state = 1;
digitalWrite(m_pin, m_state);
}
};
void off() {
m_state = 0;
digitalWrite(m_pin, m_state);
}
};
void toggle() {
m_state ^= 1;
digitalWrite(m_pin, m_state);
}
};
private:
uint8_t m_state;
uint8_t m_pin;
}
};
#endif // _LED_H_