Snake in mux scan func and handler, not operational yet
This commit is contained in:
parent
c5c2091ff7
commit
2466a8568a
3 changed files with 26 additions and 2 deletions
|
|
@ -587,7 +587,11 @@ bool I2cController::Handle_I2cBusScan(pb_istream_t *stream) {
|
|||
// TODO: Print out what was scanned? or do this at the end
|
||||
}
|
||||
|
||||
// TODO If Muxes are present, scan them
|
||||
// Case 3: Do we have a MUX on the default bus?
|
||||
if (_i2c_model->GetI2cBusScanMsg()->i2c_mux_descriptors_count > 0) {
|
||||
// Iterate through the MUX descriptors, scanning each MUX
|
||||
}
|
||||
|
||||
// TODO Scan I2C Port 1 for Muxes
|
||||
// TODO Scan I2C Port 2 for Muxes
|
||||
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@ bool I2cHardware::ScanBus(wippersnapper_i2c_I2cBusScanned *scan_results) {
|
|||
#endif */
|
||||
|
||||
// Get the SDA and SCL pins from the bus
|
||||
// TODO: Abstract this?
|
||||
char i2c_bus_scl[15] = {0}, i2c_bus_sda[15] = {0};
|
||||
snprintf(i2c_bus_scl, sizeof(i2c_bus_scl), "D%u", _bus_scl);
|
||||
snprintf(i2c_bus_sda, sizeof(i2c_bus_sda), "D%u", _bus_sda);
|
||||
|
|
@ -165,6 +166,7 @@ bool I2cHardware::ScanBus(wippersnapper_i2c_I2cBusScanned *scan_results) {
|
|||
|
||||
if (endTransmissionRC == 0) {
|
||||
WS_DEBUG_PRINTLN("[i2c] Found Device!");
|
||||
// TODO: Abstract this? Allow for mux flags to be set here, too
|
||||
scan_results
|
||||
->i2c_bus_found_devices[scan_results->i2c_bus_found_devices_count]
|
||||
.i2c_device_address = address;
|
||||
|
|
@ -292,4 +294,21 @@ void I2cHardware::SelectMuxChannel(uint32_t channel) {
|
|||
@returns True if a MUX is present on the bus, False otherwise.
|
||||
*/
|
||||
/***********************************************************************/
|
||||
bool I2cHardware::HasMux() { return _has_mux; }
|
||||
bool I2cHardware::HasMux() { return _has_mux; }
|
||||
|
||||
bool I2cHardware::ScanMux(wippersnapper_i2c_I2cBusScanned* scan_results) {
|
||||
if (!HasMux()) {
|
||||
WS_DEBUG_PRINTLN("[i2c] ERROR: No MUX present on the bus!");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (uint8_t ch = 0; ch < _mux_max_channels; ch++) {
|
||||
SelectMuxChannel(ch);
|
||||
WS_DEBUG_PRINT("[i2c] Scanning MUX Channel: ");
|
||||
WS_DEBUG_PRINTLN(ch);
|
||||
if (!ScanBus(scan_results)) {
|
||||
WS_DEBUG_PRINTLN("[i2c] ERROR: Failed to scan MUX channel!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -43,6 +43,7 @@ public:
|
|||
void SelectMuxChannel(uint32_t channel);
|
||||
bool HasMux();
|
||||
void ClearMuxChannel();
|
||||
bool ScanMux(wippersnapper_i2c_I2cBusScanned* scan_results);
|
||||
private:
|
||||
void TogglePowerPin();
|
||||
wippersnapper_i2c_I2cBusStatus _bus_status; ///< I2C bus status
|
||||
|
|
|
|||
Loading…
Reference in a new issue