mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-14 15:31:31 +10:00
Add ADS1X15 ADC (#9846)
* Add ADS1X15 class * Initialize bus and address in ADS1X15Sensor * Initialize member variables and pass bus to ads1x15 begin object * More register values options for ADS1X15 * Mark constructor as explicit * Move ADS1X15 from PowerTelemetry to EnvironmentTelemetry: * Adds ADS to Environment Telemetry * Adds possibility to use template function with multiple devices of the same type on the same bus with different addresses * Moves moduleConfig dev overrides to i2cScan function * Make logs in env telemetry only show what has been collected * Fix channel naming and logging * Remove scannerToSensorsMap for ADS1X15 * Fix ADS1X15 reclock * Fix merge * Trunk format issue * Set port * Remove status overrride * Return status on boot * Set data rate as per coderabbit request. * Add define for ADS type and use it to set SPS * Add object based on define --------- Co-authored-by: Thomas Göttgens <tgoettgens@gmail.com>
This commit is contained in:
co-authored by
Thomas Göttgens
parent
b4c2eb0b78
commit
a65d9aef39
@@ -1040,10 +1040,11 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
||||
break;
|
||||
}
|
||||
|
||||
// ADS1X15 default config register is 8583h
|
||||
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x01), 2);
|
||||
if (registerValue == 0x8583 || registerValue == 0x8580) {
|
||||
type = ADS1115;
|
||||
logFoundDevice("ADS1115 ADC", (uint8_t)addr.address);
|
||||
if (registerValue == 0x8583 || registerValue == 0x8580 || registerValue == 0xf700) {
|
||||
type = ADS1X15;
|
||||
logFoundDevice("ADS1X15 ADC", (uint8_t)addr.address);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1052,6 +1053,19 @@ void ScanI2CTwoWire::scanPort(I2CPort port, uint8_t *address, uint8_t asize)
|
||||
break;
|
||||
}
|
||||
|
||||
case ADS1X15_ADDR_ALT1:
|
||||
case ADS1X15_ADDR_ALT2:
|
||||
case ADS1X15_ADDR_ALT3: {
|
||||
// ADS1X15 default config register is 8583h
|
||||
registerValue = getRegisterValue(ScanI2CTwoWire::RegisterLocation(addr, 0x01), 2);
|
||||
if (registerValue == 0x8583 || registerValue == 0x8580 || registerValue == 0xf700) {
|
||||
type = ADS1X15_ALT;
|
||||
logFoundDevice("ADS1X15_ALT", (uint8_t)addr.address);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
LOG_INFO("Device found at address 0x%x was not able to be enumerated", (uint8_t)addr.address);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user