Skip to content

Commit 8614a6d

Browse files
committed
pair 2: remove debug code
1 parent 0a422f5 commit 8614a6d

File tree

3 files changed

+1
-42
lines changed

3 files changed

+1
-42
lines changed

src/components/i2c/controller.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -705,12 +705,6 @@ bool I2cController::Handle_I2cDeviceAddOrReplace(pb_istream_t *stream) {
705705
// I2cDeviceAddorReplace message
706706
if (device_descriptor.i2c_mux_address != 0x00) {
707707
if (_i2c_bus_alt->HasMux() || _i2c_bus_default->HasMux()) {
708-
WS_DEBUG_PRINTLN("[i2c] Scanning MUX!");
709-
_i2c_bus_default->ScanMux();
710-
WS_DEBUG_PRINT("[i2c] Configuring MUX channel: ");
711-
WS_DEBUG_PRINTLN(device_descriptor.i2c_mux_channel);
712-
WS_DEBUG_PRINT("[i2c] use_alt_bus: ");
713-
WS_DEBUG_PRINTLN(use_alt_bus);
714708
ConfigureMuxChannel(device_descriptor.i2c_mux_channel, use_alt_bus);
715709
did_set_mux_ch = true;
716710
} else {
@@ -772,31 +766,24 @@ bool I2cController::Handle_I2cDeviceAddOrReplace(pb_istream_t *stream) {
772766
// Create new driver
773767
WS_DEBUG_PRINT("[i2c] Creating driver: ");
774768
WS_DEBUG_PRINTLN(device_name);
775-
WS_DEBUG_PRINTLN(device_descriptor.i2c_device_address, HEX);
776-
WS_DEBUG_PRINTLN(device_descriptor.i2c_mux_channel);
777-
WS_DEBUG_PRINTLN(device_status);
778-
779769
drv = CreateI2CDriverByName(
780770
device_name, bus, device_descriptor.i2c_device_address,
781771
device_descriptor.i2c_mux_channel, device_status);
782772
if (drv == nullptr) {
783773
WS_DEBUG_PRINTLN("[i2c] ERROR: I2C driver type not found or unsupported!");
774+
return false;
784775
}
785776

786777
// Configure MUX and bus
787778
if (did_set_mux_ch) {
788-
WS_DEBUG_PRINT("Configuring driver's MUX address: ");
789-
WS_DEBUG_PRINTLN(device_descriptor.i2c_mux_address);
790779
drv->SetMuxAddress(device_descriptor.i2c_mux_address);
791-
WS_DEBUG_PRINTLN("[i2c] Set driver to use MUX");
792780
}
793781

794782
if (use_alt_bus) {
795783
drv->EnableAltI2CBus(_i2c_model->GetI2cDeviceAddOrReplaceMsg()
796784
->i2c_device_description.i2c_bus_scl,
797785
_i2c_model->GetI2cDeviceAddOrReplaceMsg()
798786
->i2c_device_description.i2c_bus_sda);
799-
WS_DEBUG_PRINTLN("[i2c] Set driver to use Alt I2C bus");
800787
}
801788
// Configure the driver
802789
drv->SetSensorTypes(
@@ -919,7 +906,6 @@ void I2cController::ConfigureMuxChannel(uint32_t mux_channel, bool is_alt_bus) {
919906
_i2c_bus_alt->SelectMuxChannel(mux_channel);
920907
return;
921908
}
922-
WS_DEBUG_PRINTLN("[i2c] ConfigureMuxChannel() normal bus");
923909
_i2c_bus_default->ClearMuxChannel(); // sanity-check
924910
_i2c_bus_default->SelectMuxChannel(mux_channel);
925911
}

src/components/i2c/hardware.cpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -261,41 +261,19 @@ bool I2cHardware::AddMuxToBus(uint32_t address_register, const char *name) {
261261
}
262262

263263
_mux_address = address_register;
264-
WS_DEBUG_PRINT("mux_addr: ");
265-
WS_DEBUG_PRINTLN(_mux_address);
266264
_has_mux = true;
267265
// Put MUX in back into its default state cuz we don't know if we're about to
268266
// use it again
269267
ClearMuxChannel();
270268
return true;
271269
}
272270

273-
274-
void I2cHardware::ScanMux() {
275-
for (uint8_t t=0; t<_mux_max_channels; t++) {
276-
_bus->beginTransmission(_mux_address);
277-
_bus->write(1 << t);
278-
_bus->endTransmission();
279-
280-
Serial.print("PCA Port #"); Serial.println(t);
281-
for (uint8_t addr = 0; addr<=127; addr++) {
282-
if (addr == _mux_address) continue;
283-
_bus->beginTransmission(addr);
284-
if (!_bus->endTransmission()) {
285-
Serial.print("Found I2C 0x"); Serial.println(addr,HEX);
286-
}
287-
}
288-
}
289-
}
290-
291271
/***********************************************************************/
292272
/*!
293273
@brief Clears the enabled MUX channel.
294274
*/
295275
/***********************************************************************/
296276
void I2cHardware::ClearMuxChannel() {
297-
WS_DEBUG_PRINT("has_mux: ");
298-
WS_DEBUG_PRINTLN(_has_mux);
299277
if (!_has_mux) {
300278
return;
301279
}
@@ -315,10 +293,6 @@ void I2cHardware::ClearMuxChannel() {
315293
*/
316294
/***********************************************************************/
317295
void I2cHardware::SelectMuxChannel(uint32_t channel) {
318-
WS_DEBUG_PRINT("SelectMuxChannel: ");
319-
WS_DEBUG_PRINTLN(channel);
320-
WS_DEBUG_PRINT("max_channels: ");
321-
WS_DEBUG_PRINTLN(_mux_max_channels);
322296
if (channel > _mux_max_channels - 1) {
323297
return;
324298
}

src/components/i2c/hardware.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class I2cHardware {
4141
void SelectMuxChannel(uint32_t channel);
4242
bool HasMux();
4343
void ClearMuxChannel();
44-
void ScanMux();
4544
private:
4645
void TogglePowerPin();
4746
wippersnapper_i2c_I2cBusStatus _bus_status; ///< I2C bus status

0 commit comments

Comments
 (0)