Skip to content

Commit f5c2c93

Browse files
committed
Print I2C driver info
1 parent 6ace339 commit f5c2c93

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

src/components/i2c/controller.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,15 @@ void I2cController::ConfigureMuxChannel(uint32_t mux_channel, bool is_alt_bus) {
10281028
_i2c_bus_default->SelectMuxChannel(mux_channel);
10291029
}
10301030

1031+
void I2cController::PrintAllDrivers() {
1032+
WS_DEBUG_PRINTLN("[i2c] Printing all drivers...");
1033+
for (auto *drv : _i2c_drivers) {
1034+
if (drv == nullptr)
1035+
continue; // skip null drivers
1036+
drv->printSensorInfo();
1037+
}
1038+
}
1039+
10311040
/***********************************************************************/
10321041
/*!
10331042
@brief Handles polling, reading, and logger for i2c devices

src/components/i2c/controller.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class I2cController {
117117
bool
118118
IsDriverInitialized(wippersnapper_i2c_I2cDeviceDescriptor &device_descriptor);
119119
TwoWire *GetI2cBus(bool is_alt_bus = false);
120+
void PrintAllDrivers();
120121

121122
private:
122123
I2cModel *_i2c_model; ///< Pointer to an I2C model object

src/components/i2c/drivers/drvBase.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,31 @@ class drvBase {
846846
}
847847
}
848848

849+
void printSensorInfo() {
850+
WS_DEBUG_PRINT("Sensor Name: ");
851+
WS_DEBUG_PRINT(_name);
852+
WS_DEBUG_PRINT("\tI2C Address: 0x");
853+
WS_DEBUG_PRINT(_address, HEX);
854+
if (_has_alt_i2c_bus) {
855+
WS_DEBUG_PRINT("\tI2C Address (Alt Bus): 0x");
856+
WS_DEBUG_PRINT(_address, HEX);
857+
}
858+
if (HasMux()) {
859+
WS_DEBUG_PRINT("\tI2C MUX Address: 0x");
860+
WS_DEBUG_PRINT(_i2c_mux_addr, HEX);
861+
WS_DEBUG_PRINT("\tI2C MUX Channel: ");
862+
WS_DEBUG_PRINT(_i2c_mux_channel);
863+
}
864+
WS_DEBUG_PRINT("\tSCL Pin: ");
865+
WS_DEBUG_PRINT(_pin_scl);
866+
WS_DEBUG_PRINT("\tSDA Pin: ");
867+
WS_DEBUG_PRINT(_pin_sda);
868+
WS_DEBUG_PRINT("\tSensor Period: ");
869+
WS_DEBUG_PRINT(_sensor_period);
870+
WS_DEBUG_PRINT("\tSensor Period remaining: ");
871+
WS_DEBUG_PRINT(millis() - _sensor_period_prv);
872+
}
873+
849874
protected:
850875
TwoWire *_i2c; ///< Pointer to the I2C bus
851876
bool _has_alt_i2c_bus; ///< True if the device is on an alternate I2C bus

src/provisioning/tinyusb/Wippersnapper_FS.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,10 @@ bool Wippersnapper_FS::WriteFileConfig() {
476476
refreshMassStorage();
477477
delay(500);
478478
InitUsbMsc();
479+
WS_PRINTER.flush();
480+
delay(500);
481+
WS_PRINTER.println("Config file written to flash!"); // List current config / components and periods
482+
WsV2._i2c_controller->PrintAllDrivers();
479483
return true;
480484
}
481485

0 commit comments

Comments
 (0)