Skip to content

Commit 8313b66

Browse files
committed
trim controller
1 parent d86a445 commit 8313b66

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

src/components/i2c/controller.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ bool I2cController::Handle_I2cDeviceAddOrReplace(pb_istream_t *stream) {
858858
bool I2cController::ScanI2cBus(bool default_bus = true) {
859859
_i2c_bus_default->InitBus(default_bus);
860860
_scan_results = wippersnapper_i2c_I2cBusScanned_init_zero;
861-
if (!default_bus)
861+
if (! default_bus)
862862
return _i2c_bus_alt->ScanBus(&_scan_results);
863863
return _i2c_bus_default->ScanBus(&_scan_results);
864864
}
@@ -874,38 +874,41 @@ bool I2cController::ScanI2cBus(bool default_bus = true) {
874874
/***********************************************************************/
875875
bool I2cController::WasDeviceScanned(uint32_t address) {
876876
pb_size_t num_found_devices = _scan_results.i2c_bus_found_devices_count;
877-
WS_DEBUG_PRINT("[i2c] # of Scanned Devices: ");
878-
WS_DEBUG_PRINTLN(num_found_devices);
879877
if (num_found_devices == 0)
880878
return false; // no devices found on bus, or scan was not performed
881879

880+
// Check if the device was found on the bus
882881
for (pb_size_t i; i < num_found_devices; i++) {
883882
if (_scan_results.i2c_bus_found_devices[i].i2c_device_address == address)
884883
return true; // device found on bus!
885884
}
886885
return false; // exhausted all scanned devices, didn't find it
887886
}
888887

888+
/***********************************************************************/
889+
/*!
890+
@brief Returns an i2c address of a device found on the bus.
891+
@param index
892+
The index of the scanned device within scan_results.
893+
@returns The I2C device address of the scanned device.
894+
*/
895+
/***********************************************************************/
889896
uint32_t I2cController::GetScanDeviceAddress(int index) {
890897
if (index < 0 || index >= _scan_results.i2c_bus_found_devices_count)
891898
return 0;
892899
return _scan_results.i2c_bus_found_devices[index].i2c_device_address;
893900
}
894901

902+
/***********************************************************************/
903+
/*!
904+
@brief Gets the number of devices found on the bus.
905+
@returns The number of devices found on the bus.
906+
*/
907+
/***********************************************************************/
895908
size_t I2cController::GetScanDeviceCount() {
896909
return _scan_results.i2c_bus_found_devices_count;
897910
}
898911

899-
void I2cController::PrintScanResults() {
900-
WS_DEBUG_PRINT("[i2c] # of Scanned Devices: ");
901-
WS_DEBUG_PRINTLN(_scan_results.i2c_bus_found_devices_count);
902-
for (pb_size_t i = 0; i < _scan_results.i2c_bus_found_devices_count; i++) {
903-
WS_DEBUG_PRINT("[i2c] Device found at address: ");
904-
WS_DEBUG_PRINTLN(_scan_results.i2c_bus_found_devices[i].i2c_device_address,
905-
HEX);
906-
}
907-
}
908-
909912
/********************************************************************************/
910913
/*!
911914
@brief Enables a MUX channel on the appropriate I2C bus.

src/components/i2c/controller.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ class I2cController {
105105
void ConfigureMuxChannel(uint32_t mux_channel, bool is_alt_bus);
106106
bool ScanI2cBus(bool default_bus);
107107
bool WasDeviceScanned(uint32_t address);
108-
void PrintScanResults();
109108
uint32_t GetScanDeviceAddress(int index);
110109
size_t GetScanDeviceCount();
111110
bool IsDriverInitialized(wippersnapper_i2c_I2cDeviceDescriptor& device_descriptor);

0 commit comments

Comments
 (0)