Skip to content

Commit ac4f482

Browse files
committed
Ensure single initialization
1 parent 724cba2 commit ac4f482

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/PF1550.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,19 @@ PF1550::PF1550(PF1550_IO & io)
4545

4646
int PF1550::begin()
4747
{
48+
if(_initialized) {
49+
return 0;
50+
}
51+
4852
if (_debug) {
4953
_debug->println("PF1550 begin");
5054
}
51-
return _control.begin();
55+
int returnCode = _control.begin();
56+
57+
if (returnCode == 0) {
58+
_initialized = true;
59+
}
60+
return returnCode;
5261
}
5362

5463
void PF1550::debug(Stream& stream)

src/PF1550.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class PF1550
100100

101101
private:
102102
PF1550_Control _control;
103+
volatile bool _initialized;
103104
Stream* _debug;
104105
};
105106

0 commit comments

Comments
 (0)