Skip to content

Commit f13f8b7

Browse files
committed
review modifications
1 parent 8313b66 commit f13f8b7

File tree

3 files changed

+15
-52
lines changed

3 files changed

+15
-52
lines changed

src/components/i2c/drivers/drvBase.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,13 @@ class drvBase {
171171
wippersnapper_sensor_SensorType *sensor_types = nullptr,
172172
size_t sensor_types_count = 0) {
173173

174-
// Assign num of sensors
174+
// Assign number of sensors
175175
if (use_default_types) {
176-
// Configure the driver with values from the driver
177-
// NOTE: This is used only for auto-configured sensors
176+
// Configure the driver with values from THE DRIVER
178177
ConfigureDefaultSensorTypes();
179178
_sensors_count = _default_sensor_types_count;
180179
} else {
180+
// Configure the driver with values from THE CONFIG FILE
181181
_sensors_count = sensor_types_count;
182182
}
183183

src/components/i2c/hardware.cpp

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ void I2cHardware::TogglePowerPin() {
6363
/***********************************************************************/
6464
void I2cHardware::InitBus(bool is_default, const char *sda, const char *scl) {
6565
uint8_t pin_sda, pin_scl;
66-
WS_DEBUG_PRINT("is_default: ");
67-
WS_DEBUG_PRINTLN(is_default);
6866
if (!is_default && (sda == nullptr || scl == nullptr)) {
6967
_bus_status = wippersnapper_i2c_I2cBusStatus_I2C_BUS_STATUS_UNSPECIFIED;
7068
return;
@@ -83,7 +81,6 @@ void I2cHardware::InitBus(bool is_default, const char *sda, const char *scl) {
8381
pin_scl = SCL;
8482
#else
8583
// RP2040 BSP uses a different naming scheme than Espressif for I2C pins
86-
WS_DEBUG_PRINTLN("[i2c] Using RP2040 I2C pins...");
8784
pin_sda = PIN_WIRE0_SDA;
8885
pin_scl = PIN_WIRE0_SCL;
8986
#endif
@@ -130,15 +127,13 @@ void I2cHardware::InitBus(bool is_default, const char *sda, const char *scl) {
130127
_bus->setSDA(pin_sda);
131128
_bus->setSCL(pin_scl);
132129
_bus->begin();
133-
WS_DEBUG_PRINTLN("[i2c] RP2040 I2C bus initialized!");
134130
#elif defined(ARDUINO_ARCH_SAM)
135131
_bus = new TwoWire(&PERIPH_WIRE, pin_sda, pin_scl);
136132
_bus->begin();
137133
#else
138134
#error "I2C bus implementation not supported by this platform!"
139135
#endif
140136

141-
WS_DEBUG_PRINTLN("[i2c] I2C bus initialized!");
142137
_bus_status = wippersnapper_i2c_I2cBusStatus_I2C_BUS_STATUS_SUCCESS;
143138
}
144139

@@ -167,15 +162,6 @@ bool I2cHardware::ScanBus(wippersnapper_i2c_I2cBusScanned *scan_results) {
167162
return false;
168163
}
169164

170-
// TODO: WS object needs to be added for this to work?
171-
/* #ifndef ARDUINO_ARCH_ESP32
172-
// Set I2C WDT timeout to catch I2C hangs, SAMD-specific
173-
WS.enableWDT(I2C_WDT_TIMEOUT_MS);
174-
WS.feedWDT();
175-
#endif */
176-
WS_DEBUG_PRINT("Bus Status: ");
177-
WS_DEBUG_PRINTLN(_bus_status);
178-
179165
// Perform a bus scan
180166
WS_DEBUG_PRINTLN("[i2c]: Scanning I2C Bus for Devices...");
181167
for (uint8_t address = 1; address < 127; address++) {
@@ -189,17 +175,6 @@ bool I2cHardware::ScanBus(wippersnapper_i2c_I2cBusScanned *scan_results) {
189175
scan_results
190176
->i2c_bus_found_devices[scan_results->i2c_bus_found_devices_count]
191177
.i2c_device_address = address;
192-
// NOTE: This is disabled because _sda and _scl are not saved, we should be doing this!
193-
/* strcpy(
194-
scan_results
195-
->i2c_bus_found_devices[scan_results->i2c_bus_found_devices_count]
196-
.i2c_bus_sda,
197-
_sda);
198-
strcpy(
199-
scan_results
200-
->i2c_bus_found_devices[scan_results->i2c_bus_found_devices_count]
201-
.i2c_bus_scl,
202-
_scl); */
203178
scan_results->i2c_bus_found_devices_count++;
204179
}
205180
#if defined(ARDUINO_ARCH_ESP32)
@@ -225,18 +200,11 @@ bool I2cHardware::ScanBus(wippersnapper_i2c_I2cBusScanned *scan_results) {
225200
}
226201
#endif // ARDUINO_ARCH_ESP32
227202
else {
228-
// WS_DEBUG_PRINTLN("[i2c] Did not find device: Unknown bus error has
229-
// occured!");
203+
// Did not find a device, keep scanning
230204
continue;
231205
}
232206
}
233207

234-
// TODO: Re-enable this?
235-
/* #ifndef ARDUINO_ARCH_ESP32
236-
// re-enable WipperSnapper SAMD WDT global timeout
237-
WS.enableWDT(WS_WDT_TIMEOUT);
238-
WS.feedWDT();
239-
#endif */
240208
return true;
241209
}
242210

@@ -274,9 +242,9 @@ bool I2cHardware::AddMuxToBus(uint32_t address_register, const char *name) {
274242
*/
275243
/***********************************************************************/
276244
void I2cHardware::ClearMuxChannel() {
277-
if (!_has_mux) {
245+
if (!_has_mux)
278246
return;
279-
}
247+
280248
_bus->beginTransmission(_mux_address);
281249
if (_mux_max_channels == 4)
282250
_bus->write(0b0000);
@@ -293,9 +261,9 @@ void I2cHardware::ClearMuxChannel() {
293261
*/
294262
/***********************************************************************/
295263
void I2cHardware::SelectMuxChannel(uint32_t channel) {
296-
if (channel > _mux_max_channels - 1) {
264+
if (channel > _mux_max_channels - 1)
297265
return;
298-
}
266+
299267
_bus->beginTransmission(_mux_address);
300268
_bus->write(1 << channel);
301269
_bus->endTransmission();

src/provisioning/sdcard/ws_sdcard.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,12 @@ bool ws_sdcard::InitSdCard(uint8_t pin_cs) {
4747
ws_sdcard::ws_sdcard() {
4848
_use_test_data = false;
4949
_is_soft_rtc = false;
50+
5051
_sz_cur_log_file = 0;
5152
_sd_cur_log_files = 0;
5253

53-
delay(4000); // TODO: This is for debugging, remove when ready for final
54-
// version!
55-
bool did_init = false;
5654
// Case 1: Try to initialize the SD card with the pin from the config file
55+
bool did_init = false;
5756
if (WsV2.pin_sd_cs != SD_CS_CFG_NOT_FOUND) {
5857
WS_DEBUG_PRINTLN(
5958
"Attempting to initialize SD card with pin from config file");
@@ -224,9 +223,11 @@ bool ws_sdcard::ConfigureRTC(const char *rtc_type) {
224223
return InitPCF8523();
225224
} else if (strcmp(rtc_type, "SOFT") == 0) {
226225
return InitSoftRTC();
227-
} else
228-
WS_DEBUG_PRINTLN("[SD] Error: Unknown RTC type found in JSON string!");
229-
return false;
226+
}
227+
228+
WS_DEBUG_PRINTLN("[SD] Error: Unknown RTC type found in JSON string!");
229+
WS_DEBUG_PRINTLN("[SD] Falling back to soft RTC...");
230+
return InitSoftRTC();
230231
}
231232

232233
/**************************************************************************/
@@ -728,12 +729,6 @@ bool ws_sdcard::ParseFileConfig() {
728729
}
729730
#endif
730731

731-
// Get JSON document size
732-
// TODO: Remove, this is DEBUG ONLY
733-
size_t doc_size = measureJson(doc);
734-
WS_DEBUG_PRINT("[DBG | SD] Document size: ");
735-
WS_DEBUG_PRINTLN(doc_size);
736-
737732
if (doc.isNull()) {
738733
WS_DEBUG_PRINTLN("[SD] Error: Document is null!");
739734
return false;

0 commit comments

Comments
 (0)