Skip to content
This repository was archived by the owner on Jan 29, 2023. It is now read-only.

Commit 5fb7e85

Browse files
authored
Merge pull request #10 from Django0/br_fix_warnings_cppCheck_platformio_arduino-cli
Fixed warnings from cppcheck (platformio) and -Wall arduino-cli
2 parents 30c3b70 + b9e76fd commit 5fb7e85

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

src/TimerInterrupt.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,24 @@ class TimerInterrupt
130130
_frequency = 0;
131131
_callback = NULL;
132132
_params = NULL;
133+
_timerDone = false;
134+
_prescalerIndex = NO_PRESCALER;
135+
_OCRValue = 0;
136+
_OCRValueRemaining = 0;
137+
_toggle_count = -1;
133138
};
134139

135-
TimerInterrupt(uint8_t timerNo)
140+
explicit TimerInterrupt(uint8_t timerNo)
136141
{
137142
_timer = timerNo;
138143
_frequency = 0;
139144
_callback = NULL;
140145
_params = NULL;
146+
_timerDone = false;
147+
_prescalerIndex = NO_PRESCALER;
148+
_OCRValue = 0;
149+
_OCRValueRemaining = 0;
150+
_toggle_count = -1;
141151
};
142152

143153
void callback() __attribute__((always_inline))
@@ -246,7 +256,7 @@ class TimerInterrupt
246256
return _timer;
247257
};
248258

249-
volatile long getCount() __attribute__((always_inline))
259+
long getCount() __attribute__((always_inline))
250260
{
251261
return _toggle_count;
252262
};
@@ -262,12 +272,12 @@ class TimerInterrupt
262272
//interrupts();
263273
};
264274

265-
volatile long get_OCRValue() __attribute__((always_inline))
275+
long get_OCRValue() __attribute__((always_inline))
266276
{
267277
return _OCRValue;
268278
};
269279

270-
volatile long get_OCRValueRemaining() __attribute__((always_inline))
280+
long get_OCRValueRemaining() __attribute__((always_inline))
271281
{
272282
return _OCRValueRemaining;
273283
};
@@ -282,7 +292,7 @@ class TimerInterrupt
282292
else
283293
_OCRValueRemaining -= min(MAX_COUNT_8BIT, _OCRValueRemaining);
284294

285-
if (_OCRValueRemaining <= 0)
295+
if (_OCRValueRemaining == 0)
286296
{
287297
// Reset value for next cycle
288298
_OCRValueRemaining = _OCRValue;

src_cpp/TimerInterrupt.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,24 @@ class TimerInterrupt
128128
_frequency = 0;
129129
_callback = NULL;
130130
_params = NULL;
131+
_timerDone = false;
132+
_prescalerIndex = NO_PRESCALER;
133+
_OCRValue = 0;
134+
_OCRValueRemaining = 0;
135+
_toggle_count = -1;
131136
};
132137

133-
TimerInterrupt(uint8_t timerNo)
138+
explicit TimerInterrupt(uint8_t timerNo)
134139
{
135140
_timer = timerNo;
136141
_frequency = 0;
137142
_callback = NULL;
138143
_params = NULL;
144+
_timerDone = false;
145+
_prescalerIndex = NO_PRESCALER;
146+
_OCRValue = 0;
147+
_OCRValueRemaining = 0;
148+
_toggle_count = -1;
139149
};
140150

141151
void callback() __attribute__((always_inline))
@@ -244,7 +254,7 @@ class TimerInterrupt
244254
return _timer;
245255
};
246256

247-
volatile long getCount() __attribute__((always_inline))
257+
long getCount() __attribute__((always_inline))
248258
{
249259
return _toggle_count;
250260
};
@@ -260,12 +270,12 @@ class TimerInterrupt
260270
//interrupts();
261271
};
262272

263-
volatile long get_OCRValue() __attribute__((always_inline))
273+
long get_OCRValue() __attribute__((always_inline))
264274
{
265275
return _OCRValue;
266276
};
267277

268-
volatile long get_OCRValueRemaining() __attribute__((always_inline))
278+
long get_OCRValueRemaining() __attribute__((always_inline))
269279
{
270280
return _OCRValueRemaining;
271281
};
@@ -280,7 +290,7 @@ class TimerInterrupt
280290
else
281291
_OCRValueRemaining -= min(MAX_COUNT_8BIT, _OCRValueRemaining);
282292

283-
if (_OCRValueRemaining <= 0)
293+
if (_OCRValueRemaining == 0)
284294
{
285295
// Reset value for next cycle
286296
_OCRValueRemaining = _OCRValue;

0 commit comments

Comments
 (0)