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

Fixed warnings from cppcheck (platformio) and -Wall arduino-cli #10

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/TimerInterrupt.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,24 @@ class TimerInterrupt
_frequency = 0;
_callback = NULL;
_params = NULL;
_timerDone = false;
_prescalerIndex = NO_PRESCALER;
_OCRValue = 0;
_OCRValueRemaining = 0;
_toggle_count = -1;
};

TimerInterrupt(uint8_t timerNo)
explicit TimerInterrupt(uint8_t timerNo)
{
_timer = timerNo;
_frequency = 0;
_callback = NULL;
_params = NULL;
_timerDone = false;
_prescalerIndex = NO_PRESCALER;
_OCRValue = 0;
_OCRValueRemaining = 0;
_toggle_count = -1;
};

void callback() __attribute__((always_inline))
Expand Down Expand Up @@ -246,7 +256,7 @@ class TimerInterrupt
return _timer;
};

volatile long getCount() __attribute__((always_inline))
long getCount() __attribute__((always_inline))
{
return _toggle_count;
};
Expand All @@ -262,12 +272,12 @@ class TimerInterrupt
//interrupts();
};

volatile long get_OCRValue() __attribute__((always_inline))
long get_OCRValue() __attribute__((always_inline))
{
return _OCRValue;
};

volatile long get_OCRValueRemaining() __attribute__((always_inline))
long get_OCRValueRemaining() __attribute__((always_inline))
{
return _OCRValueRemaining;
};
Expand All @@ -282,7 +292,7 @@ class TimerInterrupt
else
_OCRValueRemaining -= min(MAX_COUNT_8BIT, _OCRValueRemaining);

if (_OCRValueRemaining <= 0)
if (_OCRValueRemaining == 0)
{
// Reset value for next cycle
_OCRValueRemaining = _OCRValue;
Expand Down
20 changes: 15 additions & 5 deletions src_cpp/TimerInterrupt.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,24 @@ class TimerInterrupt
_frequency = 0;
_callback = NULL;
_params = NULL;
_timerDone = false;
_prescalerIndex = NO_PRESCALER;
_OCRValue = 0;
_OCRValueRemaining = 0;
_toggle_count = -1;
};

TimerInterrupt(uint8_t timerNo)
explicit TimerInterrupt(uint8_t timerNo)
{
_timer = timerNo;
_frequency = 0;
_callback = NULL;
_params = NULL;
_timerDone = false;
_prescalerIndex = NO_PRESCALER;
_OCRValue = 0;
_OCRValueRemaining = 0;
_toggle_count = -1;
};

void callback() __attribute__((always_inline))
Expand Down Expand Up @@ -244,7 +254,7 @@ class TimerInterrupt
return _timer;
};

volatile long getCount() __attribute__((always_inline))
long getCount() __attribute__((always_inline))
{
return _toggle_count;
};
Expand All @@ -260,12 +270,12 @@ class TimerInterrupt
//interrupts();
};

volatile long get_OCRValue() __attribute__((always_inline))
long get_OCRValue() __attribute__((always_inline))
{
return _OCRValue;
};

volatile long get_OCRValueRemaining() __attribute__((always_inline))
long get_OCRValueRemaining() __attribute__((always_inline))
{
return _OCRValueRemaining;
};
Expand All @@ -280,7 +290,7 @@ class TimerInterrupt
else
_OCRValueRemaining -= min(MAX_COUNT_8BIT, _OCRValueRemaining);

if (_OCRValueRemaining <= 0)
if (_OCRValueRemaining == 0)
{
// Reset value for next cycle
_OCRValueRemaining = _OCRValue;
Expand Down