@@ -273,13 +273,14 @@ uint8_t HardwarePWM::freeChannelCount(void) const
273
273
// returns true ONLY when (1) no PWM channel has a pin, and (2) the owner token is nullptr
274
274
bool HardwarePWM::takeOwnership (uint32_t token)
275
275
{
276
+
276
277
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)" );
278
279
return false ;
279
280
}
280
281
281
282
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)" );
283
284
return false ;
284
285
}
285
286
@@ -296,22 +297,22 @@ bool HardwarePWM::takeOwnership(uint32_t token)
296
297
bool HardwarePWM::releaseOwnership (uint32_t token)
297
298
{
298
299
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)" );
300
301
return false ;
301
302
}
302
303
303
304
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" );
305
306
return false ;
306
307
}
307
308
308
309
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" );
310
311
return false ;
311
312
}
312
313
313
314
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" );
315
316
return false ; // if it's enabled, do not allow ownership to be released, even with no pins in use
316
317
}
317
318
0 commit comments