some fixes, strange zeros in between
This commit is contained in:
@ -21,7 +21,7 @@ void setup() {
|
|||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
|
||||||
led(LED_PIN);
|
led.begin(LED_PIN);
|
||||||
ads1210.begin(ADC_CS_PIN, ADC_RDY_PIN);
|
ads1210.begin(ADC_CS_PIN, ADC_RDY_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,6 +31,6 @@ void loop() {
|
|||||||
if (secondTick.check() == 1) {
|
if (secondTick.check() == 1) {
|
||||||
led.toggle();
|
led.toggle();
|
||||||
|
|
||||||
Serial << "AdcValue: " << adc1210.value << endl;
|
Serial << "AdcValue: " << _HEX(ads1210.value) << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
16
ads1210.cpp
16
ads1210.cpp
@ -69,26 +69,14 @@ void ADS1210::exec() {
|
|||||||
res.in[3] = 0;
|
res.in[3] = 0;
|
||||||
disableCS();
|
disableCS();
|
||||||
|
|
||||||
Serial << "DOR4x8: " << _HEX(res.in[3]) << " " << _HEX(res.in[2]) << " " << _HEX(res.in[1]) << " " << _HEX(res.in[0]) << 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;
|
// Serial << "DOR1x32: " << _HEX(res.out) << endl;
|
||||||
|
|
||||||
value = res.out;
|
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 {
|
void ADS1210::setMode(uint8_t mode) const {
|
||||||
uint8_t cmr = readRegister(ADDR_CMR2);
|
uint8_t cmr = readRegister(ADDR_CMR2);
|
||||||
cmr &= ~CMR_MD_Mask;
|
cmr &= ~CMR_MD_Mask;
|
||||||
|
12
ads1210.h
12
ads1210.h
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
class ADS1210 {
|
class ADS1210 {
|
||||||
public:
|
public:
|
||||||
ADS1210() : value(0);
|
ADS1210() : value(0) {};
|
||||||
void begin(uint8_t csPin, uint8_t drdyPin);
|
void begin(uint8_t csPin, uint8_t drdyPin);
|
||||||
void exec();
|
void exec();
|
||||||
|
|
||||||
@ -55,11 +55,11 @@ private:
|
|||||||
const uint8_t CMD_MD_Sleep = 0xc0;
|
const uint8_t CMD_MD_Sleep = 0xc0;
|
||||||
|
|
||||||
const uint8_t CMR_Gain_Mask = (0x07 << 2);
|
const uint8_t CMR_Gain_Mask = (0x07 << 2);
|
||||||
const uint8_t CMD_Gain_1 = 0;
|
const uint8_t CMR_Gain_1 = 0;
|
||||||
const uint8_t CMD_Gain_2 = (0x01 << 2);
|
const uint8_t CMR_Gain_2 = (0x01 << 2);
|
||||||
const uint8_t CMD_Gain_4 = (0x02 << 2);
|
const uint8_t CMR_Gain_4 = (0x02 << 2);
|
||||||
const uint8_t CMD_Gain_8 = (0x03 << 2);
|
const uint8_t CMR_Gain_8 = (0x03 << 2);
|
||||||
const uint8_t CMD_Gain_16 = (0x04 << 2);
|
const uint8_t CMR_Gain_16 = (0x04 << 2);
|
||||||
|
|
||||||
// bit values
|
// bit values
|
||||||
// INSR
|
// INSR
|
||||||
|
8
led.h
8
led.h
@ -15,18 +15,18 @@ public:
|
|||||||
void on() {
|
void on() {
|
||||||
m_state = 1;
|
m_state = 1;
|
||||||
digitalWrite(m_pin, m_state);
|
digitalWrite(m_pin, m_state);
|
||||||
}
|
};
|
||||||
void off() {
|
void off() {
|
||||||
m_state = 0;
|
m_state = 0;
|
||||||
digitalWrite(m_pin, m_state);
|
digitalWrite(m_pin, m_state);
|
||||||
}
|
};
|
||||||
void toggle() {
|
void toggle() {
|
||||||
m_state ^= 1;
|
m_state ^= 1;
|
||||||
digitalWrite(m_pin, m_state);
|
digitalWrite(m_pin, m_state);
|
||||||
}
|
};
|
||||||
private:
|
private:
|
||||||
uint8_t m_state;
|
uint8_t m_state;
|
||||||
uint8_t m_pin;
|
uint8_t m_pin;
|
||||||
}
|
};
|
||||||
|
|
||||||
#endif // _LED_H_
|
#endif // _LED_H_
|
||||||
|
Reference in New Issue
Block a user