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

Commit 75bc9a0

Browse files
authored
Fix warnings for AVR
See PR [Fixed warnings from cppcheck (platformio) and -Wall arduino-cli](khoih-prog/TimerInterrupt#10)
1 parent c9838ac commit 75bc9a0

File tree

3 files changed

+1328
-38
lines changed

3 files changed

+1328
-38
lines changed

src/AVRTimerInterrupt_Generic.h

+29-19
Original file line numberDiff line numberDiff line change
@@ -203,21 +203,31 @@ class TimerInterrupt
203203

204204
public:
205205

206-
TimerInterrupt()
207-
{
208-
_timer = -1;
209-
_frequency = 0;
210-
_callback = NULL;
211-
_params = NULL;
212-
};
213-
214-
TimerInterrupt(uint8_t timerNo)
215-
{
216-
_timer = timerNo;
217-
_frequency = 0;
218-
_callback = NULL;
219-
_params = NULL;
220-
};
206+
TimerInterrupt()
207+
{
208+
_timer = -1;
209+
_frequency = 0;
210+
_callback = NULL;
211+
_params = NULL;
212+
_timerDone = false;
213+
_prescalerIndex = NO_PRESCALER;
214+
_OCRValue = 0;
215+
_OCRValueRemaining = 0;
216+
_toggle_count = -1;
217+
};
218+
219+
explicit TimerInterrupt(uint8_t timerNo)
220+
{
221+
_timer = timerNo;
222+
_frequency = 0;
223+
_callback = NULL;
224+
_params = NULL;
225+
_timerDone = false;
226+
_prescalerIndex = NO_PRESCALER;
227+
_OCRValue = 0;
228+
_OCRValueRemaining = 0;
229+
_toggle_count = -1;
230+
};
221231

222232
void callback() __attribute__((always_inline))
223233
{
@@ -892,7 +902,7 @@ class TimerInterrupt
892902
return _timer;
893903
};
894904

895-
volatile long getCount() __attribute__((always_inline))
905+
long getCount() __attribute__((always_inline))
896906
{
897907
return _toggle_count;
898908
};
@@ -908,12 +918,12 @@ class TimerInterrupt
908918
//interrupts();
909919
};
910920

911-
volatile long get_OCRValue() __attribute__((always_inline))
921+
long get_OCRValue() __attribute__((always_inline))
912922
{
913923
return _OCRValue;
914924
};
915925

916-
volatile long get_OCRValueRemaining() __attribute__((always_inline))
926+
long get_OCRValueRemaining() __attribute__((always_inline))
917927
{
918928
return _OCRValueRemaining;
919929
};
@@ -928,7 +938,7 @@ class TimerInterrupt
928938
else
929939
_OCRValueRemaining -= min(MAX_COUNT_8BIT, _OCRValueRemaining);
930940

931-
if (_OCRValueRemaining <= 0)
941+
if (_OCRValueRemaining == 0)
932942
{
933943
// Reset value for next cycle
934944
_OCRValueRemaining = _OCRValue;

0 commit comments

Comments
 (0)