Skip to content

Commit e602c71

Browse files
committed
Fix RTC issue
1 parent 11cee82 commit e602c71

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

src/components/i2c/controller.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,10 @@ bool I2cController::ScanI2cBus(bool default_bus = true) {
881881
}
882882
}
883883

884+
TwoWire *I2cController::GetI2cBus(bool is_alt_bus) {
885+
return _i2c_bus_default->GetBus();
886+
}
887+
884888
/***********************************************************************/
885889
/*!
886890
@brief Checks if a device was found on the i2c bus. MUST be called

src/components/i2c/controller.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class I2cController {
109109
size_t GetScanDeviceCount();
110110
bool
111111
IsDriverInitialized(wippersnapper_i2c_I2cDeviceDescriptor &device_descriptor);
112-
112+
TwoWire *GetI2cBus(bool is_alt_bus=false);
113113
private:
114114
I2cModel *_i2c_model; ///< Pointer to an I2C model object
115115
I2cHardware *_i2c_bus_default; ///< Pointer to the default I2C bus

src/components/i2c/hardware.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ void I2cHardware::InitBus(bool is_default, const char *sda, const char *scl) {
7171
// to the i2c bus. If the pin is defined, turn the power to the i2c bus on.
7272
#if defined(PIN_I2C_POWER) || defined(TFT_I2C_POWER) || \
7373
defined(NEOPIXEL_I2C_POWER)
74+
WS_DEBUG_PRINTLN("[i2c] Powering on I2C bus...");
7475
TogglePowerPin();
7576
#endif
7677

src/provisioning/sdcard/ws_sdcard.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* please support Adafruit and open-source hardware by purchasing
88
* products from Adafruit!
99
*
10-
* Copyright (c) Brent Rubell 2024 for Adafruit Industries.
10+
* Copyright (c) Brent Rubell 2024-2025 for Adafruit Industries.
1111
*
1212
* BSD license, all text here must be included in any redistribution.
1313
*
@@ -165,17 +165,15 @@ bool ws_sdcard::InitDS3231() {
165165
*/
166166
/**************************************************************************/
167167
bool ws_sdcard::InitPCF8523() {
168-
169-
// TODO: Check if we can see the PCF8523 after
170-
// the initial i2c scan
171168
WsV2._i2c_controller->ScanI2cBus(true);
172169
WS_DEBUG_PRINT("[sd] Scanned I2C Devices: ")
173170
WS_DEBUG_PRINTLN(WsV2._i2c_controller->GetScanDeviceCount());
174171
WS_DEBUG_PRINT("Was Device Found? ");
175172
WS_DEBUG_PRINTLN(WsV2._i2c_controller->WasDeviceScanned(0x68));
176173

174+
177175
_rtc_pcf8523 = new RTC_PCF8523();
178-
if (!_rtc_pcf8523->begin()) {
176+
if (!_rtc_pcf8523->begin(WsV2._i2c_controller->GetI2cBus())) {
179177
WS_DEBUG_PRINTLN("[SD] Error: Failed to initialize PCF8523 RTC on WIRE");
180178
if (!_rtc_pcf8523->begin(&Wire1)) {
181179
WS_DEBUG_PRINTLN("[SD] Error: Failed to initialize PCF8523 RTC on WIRE1");
@@ -706,6 +704,8 @@ bool ws_sdcard::ParseExportedFromDevice(JsonDocument &doc) {
706704

707705
// Configures RTC
708706
const char *rtc_type = exportedFromDevice["rtc"] | "SOFT";
707+
// wait 9 seconds
708+
delay(9000);
709709
if (!ConfigureRTC(rtc_type)) {
710710
WS_DEBUG_PRINTLN("[SD] Error: Failed to to configure a RTC!");
711711
return false;

0 commit comments

Comments
 (0)