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

Commit 9eff41b

Browse files
authored
Fix warnings
See PR [Fixed warnings from cppcheck (platformio) and -Wall arduino-cli](#10)
1 parent 5fb7e85 commit 9eff41b

File tree

3 files changed

+62
-50
lines changed

3 files changed

+62
-50
lines changed

src/TimerInterrupt.h

+18-18
Original file line numberDiff line numberDiff line change
@@ -126,28 +126,28 @@ class TimerInterrupt
126126

127127
TimerInterrupt()
128128
{
129-
_timer = -1;
130-
_frequency = 0;
131-
_callback = NULL;
132-
_params = NULL;
133-
_timerDone = false;
134-
_prescalerIndex = NO_PRESCALER;
135-
_OCRValue = 0;
136-
_OCRValueRemaining = 0;
137-
_toggle_count = -1;
129+
_timer = -1;
130+
_frequency = 0;
131+
_callback = NULL;
132+
_params = NULL;
133+
_timerDone = false;
134+
_prescalerIndex = NO_PRESCALER;
135+
_OCRValue = 0;
136+
_OCRValueRemaining = 0;
137+
_toggle_count = -1;
138138
};
139139

140140
explicit TimerInterrupt(uint8_t timerNo)
141141
{
142-
_timer = timerNo;
143-
_frequency = 0;
144-
_callback = NULL;
145-
_params = NULL;
146-
_timerDone = false;
147-
_prescalerIndex = NO_PRESCALER;
148-
_OCRValue = 0;
149-
_OCRValueRemaining = 0;
150-
_toggle_count = -1;
142+
_timer = timerNo;
143+
_frequency = 0;
144+
_callback = NULL;
145+
_params = NULL;
146+
_timerDone = false;
147+
_prescalerIndex = NO_PRESCALER;
148+
_OCRValue = 0;
149+
_OCRValueRemaining = 0;
150+
_toggle_count = -1;
151151
};
152152

153153
void callback() __attribute__((always_inline))

src_cpp/TimerInterrupt.h

+20-18
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
1.1.1 K.Hoang 06/12/2020 Add example Change_Interval. Bump up version to sync with other TimerInterrupt Libraries
3030
****************************************************************************************************************************/
3131

32+
#pragma once
33+
3234
#ifndef TimerInterrupt_h
3335
#define TimerInterrupt_h
3436

@@ -124,28 +126,28 @@ class TimerInterrupt
124126

125127
TimerInterrupt()
126128
{
127-
_timer = -1;
128-
_frequency = 0;
129-
_callback = NULL;
130-
_params = NULL;
131-
_timerDone = false;
132-
_prescalerIndex = NO_PRESCALER;
133-
_OCRValue = 0;
134-
_OCRValueRemaining = 0;
135-
_toggle_count = -1;
129+
_timer = -1;
130+
_frequency = 0;
131+
_callback = NULL;
132+
_params = NULL;
133+
_timerDone = false;
134+
_prescalerIndex = NO_PRESCALER;
135+
_OCRValue = 0;
136+
_OCRValueRemaining = 0;
137+
_toggle_count = -1;
136138
};
137139

138140
explicit TimerInterrupt(uint8_t timerNo)
139141
{
140-
_timer = timerNo;
141-
_frequency = 0;
142-
_callback = NULL;
143-
_params = NULL;
144-
_timerDone = false;
145-
_prescalerIndex = NO_PRESCALER;
146-
_OCRValue = 0;
147-
_OCRValueRemaining = 0;
148-
_toggle_count = -1;
142+
_timer = timerNo;
143+
_frequency = 0;
144+
_callback = NULL;
145+
_params = NULL;
146+
_timerDone = false;
147+
_prescalerIndex = NO_PRESCALER;
148+
_OCRValue = 0;
149+
_OCRValueRemaining = 0;
150+
_toggle_count = -1;
149151
};
150152

151153
void callback() __attribute__((always_inline))

src_h/TimerInterrupt.h

+24-14
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,28 @@ class TimerInterrupt
126126

127127
TimerInterrupt()
128128
{
129-
_timer = -1;
130-
_frequency = 0;
131-
_callback = NULL;
132-
_params = NULL;
129+
_timer = -1;
130+
_frequency = 0;
131+
_callback = NULL;
132+
_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)
136-
{
137-
_timer = timerNo;
138-
_frequency = 0;
139-
_callback = NULL;
140-
_params = NULL;
140+
explicit TimerInterrupt(uint8_t timerNo)
141+
{
142+
_timer = timerNo;
143+
_frequency = 0;
144+
_callback = NULL;
145+
_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;

0 commit comments

Comments
 (0)