Skip to content

Commit 20b4d6a

Browse files
committed
chore: migrate Arduino API calls to note-c abstractions
1 parent 6a362dc commit 20b4d6a

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

src/NoteI2c_Arduino.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "NoteI2c_Arduino.hpp"
22

3+
#include "Notecard.h"
4+
35
#if defined(NOTE_C_LOW_MEM)
46
static const char *i2cerr = "i2c {io}";
57
#endif
@@ -105,7 +107,7 @@ NoteI2c_Arduino::receive (
105107
if (!transmission_error) {
106108
// Delay briefly ensuring that the Notecard can
107109
// deliver the data in real-time to the I2C ISR
108-
::delay(2);
110+
NoteDelayMs(2);
109111

110112
const int request_length = requested_byte_count_ + NoteI2c::REQUEST_HEADER_SIZE;
111113
const int response_length = _i2cPort.requestFrom((int)device_address_, request_length);
@@ -139,7 +141,7 @@ NoteI2c_Arduino::receive (
139141
// Flash stalls have been observed on the Notecard ESP. Delaying
140142
// between retries provides time for the Notecard to recover from
141143
// the resource contention.
142-
::delay(1000);
144+
NoteDelayMs(1000);
143145
NOTE_C_LOG_ERROR(result);
144146
NOTE_C_LOG_WARN("serial-over-i2c: reattempting to read Notecard response");
145147
} while (result && (i++ < retry_count));

src/NoteI2c_Arduino.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
#include "NoteI2c.hpp"
55

6-
#include "Notecard.h"
7-
86
#ifndef NOTE_MOCK
97
#include <Wire.h>
108
#else

src/NoteSerial_Arduino.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "NoteSerial_Arduino.hpp"
22

3-
#include "NoteDefines.h"
3+
#include "Notecard.h"
44

55
#ifndef NOTE_MOCK
66
#ifdef NOTE_ARDUINO_SOFTWARE_SERIAL_SUPPORT
@@ -68,7 +68,10 @@ NoteSerial_Arduino<T>::NoteSerial_Arduino
6868
_notecardSerial.begin(_notecardSerialSpeed);
6969

7070
// Wait for the serial port to be ready
71-
for (const size_t startMs = ::millis() ; !_notecardSerial && ((::millis() - startMs) < NOTE_C_SERIAL_TIMEOUT_MS) ;);
71+
for (const size_t startMs = NoteGetMs()
72+
; !_notecardSerial && ((NoteGetMs() - startMs) < NOTE_C_SERIAL_TIMEOUT_MS)
73+
;
74+
);
7275
}
7376

7477
template <typename T>

src/NoteTxn_Arduino.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "NoteTxn_Arduino.hpp"
22

3+
#include "Notecard.h"
4+
35
#ifndef NOTE_MOCK
46
#include <Arduino.h>
57
#else
@@ -78,9 +80,9 @@ NoteTxn_Arduino::start (
7880

7981
// Await Clear To Transact Signal
8082
::pinMode(_ctx_pin, INPUT_PULLUP);
81-
for (uint32_t timeout = (::millis() + timeout_ms_)
82-
; ::millis() < timeout
83-
; ::delay(1)
83+
for (uint32_t timeout = (NoteGetMs() + timeout_ms_)
84+
; NoteGetMs() < timeout
85+
; NoteDelayMs(1)
8486
) {
8587
if (HIGH == ::digitalRead(_ctx_pin)) {
8688
result = true;

0 commit comments

Comments
 (0)