Skip to content

Commit b4d9a7c

Browse files
committed
[HardwareTimer] Fix issue when no channel N state
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 0f5c113 commit b4d9a7c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cores/arduino/HardwareTimer.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ void HardwareTimer::pause()
115115
/* Starting from G4, new Channel state implementation prevents to restart a channel,
116116
if the channel has not been explicitly be stopped with HAL interface */
117117
TIM_CHANNEL_STATE_SET_ALL(&(_timerObj.handle), HAL_TIM_CHANNEL_STATE_READY);
118+
#endif
119+
#if defined(TIM_CHANNEL_N_STATE_SET_ALL)
118120
TIM_CHANNEL_N_STATE_SET_ALL(&(_timerObj.handle), HAL_TIM_CHANNEL_STATE_READY);
119121
#endif
120122
}
@@ -144,9 +146,12 @@ void HardwareTimer::pauseChannel(uint32_t channel)
144146
#if defined(TIM_CHANNEL_STATE_SET)
145147
/* Starting from G4, new Channel state implementation prevents to restart a channel,
146148
if the channel has not been explicitly be stopped with HAL interface */
149+
#if defined(TIM_CHANNEL_N_STATE_SET)
147150
if (isComplementaryChannel[channel - 1]) {
148151
TIM_CHANNEL_N_STATE_SET(&(_timerObj.handle), getChannel(channel), HAL_TIM_CHANNEL_STATE_READY);
149-
} else {
152+
} else
153+
#endif
154+
{
150155
TIM_CHANNEL_STATE_SET(&(_timerObj.handle), getChannel(channel), HAL_TIM_CHANNEL_STATE_READY);
151156
}
152157
#endif

0 commit comments

Comments
 (0)