• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

blues / note-arduino / 13307521056

13 Feb 2025 12:19PM CUT coverage: 94.831%. Remained the same
13307521056

Pull #131

github

web-flow
Merge 707de2580 into d8e8fbdc4
Pull Request #131: chore: Update Arduino CLI

104 of 127 branches covered (81.89%)

Branch coverage included in aggregate %.

318 of 318 relevant lines covered (100.0%)

16.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/src/NoteTxn_Arduino.cpp
1
#include "NoteTxn_Arduino.hpp"
2

3
#ifndef NOTE_MOCK
4
  #include <Arduino.h>
5
#else
6
  #include "mock/mock-arduino.hpp"
7
  #include "mock/mock-parameters.hpp"
8
#endif
9

10
NoteTxn *
11
make_note_txn (
7✔
12
    NoteTxn::param_t txn_parameters_
13
)
14
{
15
    static NoteTxn * note_txn = nullptr;
16
    if (!txn_parameters_) {
7✔
17
        if (note_txn) {
3!
18
            delete note_txn;
3!
19
            note_txn = nullptr;
3✔
20
        }
21
    } else if (!note_txn) {
4✔
22
        const uint8_t * txn_pins = reinterpret_cast<uint8_t *>(txn_parameters_);
3✔
23
        note_txn = new NoteTxn_Arduino(txn_pins[0], txn_pins[1]);
3!
24
    }
25
    return note_txn;
7✔
26
}
27

28
NoteTxn_Arduino::NoteTxn_Arduino
16✔
29
(
30
    uint8_t ctx_pin_,
31
    uint8_t rtx_pin_
32
) :
16✔
33
    _ctx_pin(ctx_pin_),
16✔
34
    _rtx_pin(rtx_pin_)
16✔
35
{
36
    // Float CTX/RTX to conserve energy
37
    ::pinMode(_ctx_pin, INPUT);
16!
38
    ::pinMode(_rtx_pin, INPUT);
16!
39
}
16✔
40

41
bool
42
NoteTxn_Arduino::start (
10✔
43
    uint32_t timeout_ms_
44
)
45
{
46
    bool result = false;
10✔
47

48
    // Signal Request To Transact
49
    ::pinMode(_rtx_pin, OUTPUT);
10✔
50
    ::digitalWrite(_rtx_pin, HIGH);
10✔
51

52
    // Await Clear To Transact Signal
53
    ::pinMode(_ctx_pin, INPUT_PULLUP);
10✔
54
    for (uint32_t timeout = (::millis() + timeout_ms_)
10✔
55
       ; ::millis() < timeout
22✔
56
       ; ::delay(1)
12✔
57
    ) {
58
        if (HIGH == ::digitalRead(_ctx_pin)) {
19✔
59
            result = true;
7✔
60
            break;
7✔
61
        }
62
    }
63

64
    // Float CTX to conserve energy
65
    ::pinMode(_ctx_pin, INPUT);
10✔
66

67
    // Abandon request on timeout
68
    if (!result) {
10✔
69
        stop();
3✔
70
    }
71

72
    return result;
10✔
73
}
74

75
void
76
NoteTxn_Arduino::stop (
4✔
77
    void
78
)
79
{
80
    // Float RTX pin
81
    ::pinMode(_rtx_pin, INPUT);
4✔
82
}
4✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc