@@ -273,13 +273,14 @@ uint8_t HardwarePWM::freeChannelCount(void) const
273273// returns true ONLY when (1) no PWM channel has a pin, and (2) the owner token is nullptr
274274bool HardwarePWM::takeOwnership (uint32_t token)
275275{
276+
276277 if (token == 0 ) {
277- LOG_LV1 (" HwPWM" , " zero / nullptr is not a valid ownership token (attempted use in takeOwnership)" );
278+ if (! isInISR ()) LOG_LV1 (" HwPWM" , " zero is not a valid ownership token (attempted use in takeOwnership)" );
278279 return false ;
279280 }
280281
281282 if (token == this ->_owner_token ) {
282- LOG_LV1 (" HwPWM" , " failing to acquire ownership because already owned by requesting token (cannot take ownership twice)" );
283+ if (! isInISR ()) LOG_LV1 (" HwPWM" , " failing to acquire ownership because already owned by requesting token (cannot take ownership twice)" );
283284 return false ;
284285 }
285286
@@ -296,22 +297,22 @@ bool HardwarePWM::takeOwnership(uint32_t token)
296297bool HardwarePWM::releaseOwnership (uint32_t token)
297298{
298299 if (token == 0 ) {
299- LOG_LV1 (" HwPWM" , " zero / nullptr is not a valid ownership token (attempted use in releaseOwnership)" );
300+ if (! isInISR ()) LOG_LV1 (" HwPWM" , " zero is not a valid ownership token (attempted use in releaseOwnership)" );
300301 return false ;
301302 }
302303
303304 if (!this ->isOwner (token)) {
304- LOG_LV1 (" HwPWM" , " attempt to release ownership when not the current owner" );
305+ if (! isInISR ()) LOG_LV1 (" HwPWM" , " attempt to release ownership when not the current owner" );
305306 return false ;
306307 }
307308
308309 if (this ->usedChannelCount () != 0 ) {
309- LOG_LV1 (" HwPWM" , " attempt to release ownership when at least on channel is still connected" );
310+ if (! isInISR ()) LOG_LV1 (" HwPWM" , " attempt to release ownership when at least on channel is still connected" );
310311 return false ;
311312 }
312313
313314 if (this ->enabled ()) {
314- LOG_LV1 (" HwPWM" , " attempt to release ownership when PWM peripheral is still enabled" );
315+ if (! isInISR ()) LOG_LV1 (" HwPWM" , " attempt to release ownership when PWM peripheral is still enabled" );
315316 return false ; // if it's enabled, do not allow ownership to be released, even with no pins in use
316317 }
317318
0 commit comments