some fixes, strange zeros in between
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
16
ads1210.cpp
16
ads1210.cpp
@ -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;
|
||||
|
12
ads1210.h
12
ads1210.h
@ -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
|
||||
|
Reference in New Issue
Block a user