Skip to content

Commit 4bc8a48

Browse files
committed
Fix: SAMD51 Target
1 parent f70f9ae commit 4bc8a48

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

src/Wippersnapper_V2.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@
7474
#include <map>
7575
#include <string>
7676
#include <vector>
77+
#ifdef ARDUINO_ARCH_SAMD
78+
#include <algorithm>
79+
#endif
7780

7881
// Nanopb dependencies
7982
#include <nanopb/pb_common.h>

src/components/ds18x20/controller.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,13 @@ bool DS18X20Controller::Handle_Ds18x20Add(pb_istream_t *stream) {
6464
// Extract the OneWire pin from the message
6565
uint8_t pin_name = atoi(_DS18X20_model->GetDS18x20AddMsg()->onewire_pin + 1);
6666

67-
// Initialize the DS18X20Hardware object
67+
#ifdef ARDUINO_ARCH_SAMD
68+
auto new_dsx_driver = new DS18X20Hardware(pin_name, _num_drivers);
69+
std::unique_ptr<DS18X20Hardware> unique_driver(new_dsx_driver);
70+
#else
6871
auto new_dsx_driver =
6972
std::make_unique<DS18X20Hardware>(pin_name, _num_drivers);
73+
#endif
7074
// Attempt to get the sensor's ID on the OneWire bus to show it's been init'd
7175
bool is_initialized = new_dsx_driver->GetSensor();
7276

@@ -103,7 +107,11 @@ bool DS18X20Controller::Handle_Ds18x20Add(pb_istream_t *stream) {
103107

104108
// If the sensor was successfully initialized, add it to the controller
105109
if (is_initialized == true) {
110+
#ifdef ARDUINO_ARCH_SAMD
111+
_DS18X20_pins.push_back(std::move(unique_driver));
112+
#else
106113
_DS18X20_pins.push_back(std::move(new_dsx_driver));
114+
#endif
107115
_num_drivers++;
108116
}
109117

src/components/i2c/hardware.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void I2cHardware::InitBus(bool is_default, const char *sda, const char *scl) {
145145
_bus->setSDA(_bus_sda);
146146
_bus->setSCL(_bus_scl);
147147
_bus->begin();
148-
#elif defined(ARDUINO_ARCH_SAM)
148+
#elif defined(ARDUINO_ARCH_SAMD)
149149
_bus = new TwoWire(&PERIPH_WIRE, _bus_sda, _bus_scl);
150150
_bus->begin();
151151
#else

src/provisioning/sdcard/ws_sdcard.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ void ws_sdcard::calculateFileLimits() {
9090
bool ws_sdcard::InitDS1307() {
9191
_rtc_ds1307 = new RTC_DS1307();
9292
if (!_rtc_ds1307->begin()) {
93-
#ifndef ARDUINO_ARCH_ESP8266
93+
#if !defined(ARDUINO_ARCH_ESP8266) && !defined(ARDUINO_ARCH_SAMD)
9494
if (!_rtc_ds1307->begin(&Wire1)) {
9595
WS_DEBUG_PRINTLN("[SD] Runtime Error: Failed to initialize DS1307 RTC");
9696
delete _rtc_ds1307;
@@ -114,7 +114,7 @@ bool ws_sdcard::InitDS3231() {
114114
WS_DEBUG_PRINTLN("Begin DS3231 init");
115115
_rtc_ds3231 = new RTC_DS3231();
116116
if (!_rtc_ds3231->begin(&Wire)) {
117-
#ifndef ARDUINO_ARCH_ESP8266
117+
#if !defined(ARDUINO_ARCH_ESP8266) && !defined(ARDUINO_ARCH_SAMD)
118118
if (!_rtc_ds3231->begin(&Wire1)) {
119119
WS_DEBUG_PRINTLN("[SD] Runtime Error: Failed to initialize DS3231 RTC");
120120
delete _rtc_ds3231;
@@ -139,7 +139,7 @@ bool ws_sdcard::InitPCF8523() {
139139
if (!_rtc_pcf8523->begin(&Wire)) {
140140
WS_DEBUG_PRINTLN(
141141
"[SD] Runtime Error: Failed to initialize PCF8523 RTC on WIRE");
142-
#ifndef ARDUINO_ARCH_ESP8266
142+
#if !defined(ARDUINO_ARCH_ESP8266) && !defined(ARDUINO_ARCH_SAMD)
143143
if (!_rtc_pcf8523->begin(&Wire1)) {
144144
WS_DEBUG_PRINTLN(
145145
"[SD] Runtime Error: Failed to initialize PCF8523 RTC on WIRE1");

0 commit comments

Comments
 (0)