Skip to content

Commit 015ca5a

Browse files
committed
Fixed comments from review in HardwareTimer
1 parent 0b936e5 commit 015ca5a

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

cores/arduino/HardwareTimer.cpp

+18-3
Original file line numberDiff line numberDiff line change
@@ -932,9 +932,24 @@ void HardwareTimer::detachInterrupt(uint32_t channel)
932932
args[channel] = NULL;
933933
}
934934

935-
void* HardwareTimer::getArg(uint32_t channel){
936-
if (channel > (TIMER_CHANNELS + 1)) {
937-
Error_Handler();
935+
/**
936+
* @brief Get argument attached to (rollover) event.
937+
* @retval Associated pointer to attached argument or NULL if not set.
938+
*/
939+
void *HardwareTimer::getArg()
940+
{
941+
return args[0];
942+
}
943+
944+
/**
945+
* @brief Get argument attached to Capture/Compare event.
946+
* @param channel: arduino channel [1..4]
947+
* @retval Associated pointer to attached argument or NULL if not set.
948+
*/
949+
void *HardwareTimer::getArg(uint32_t channel)
950+
{
951+
if ((channel == 0) || (channel > (TIMER_CHANNELS + 1))) {
952+
Error_Handler(); // only channel 1..4 have an interrupt
938953
}
939954
return args[channel];
940955
}

cores/arduino/HardwareTimer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ class HardwareTimer {
129129
void attachInterrupt(void (*handler)(HardwareTimer *), void *arg = NULL); // Attach interrupt callback which will be called upon update event (timer rollover)
130130
void detachInterrupt(); // remove interrupt callback which was attached to update event
131131
bool hasInterrupt(); //returns true if a timer rollover interrupt has already been set
132+
void *getArg(); // Getter for attached argument to event (timer rollover)
132133
//Add interrupt to capture/compare channel
133134
void attachInterrupt(uint32_t channel, void (*handler)(HardwareTimer *), void *arg = NULL); // Attach interrupt callback which will be called upon compare match event of specified channel
134135
void detachInterrupt(uint32_t channel); // remove interrupt callback which was attached to compare match event of specified channel
135136
bool hasInterrupt(uint32_t channel); //returns true if an interrupt has already been set on the channel compare match
136-
137-
void* getArg(uint32_t channel = 0);
137+
void *getArg(uint32_t channel); // Getter for attached argument to compare match event of specified channel
138138

139139
void timerHandleDeinit(); // Timer deinitialization
140140

0 commit comments

Comments
 (0)