disable PWM ownership within ISR()

takeOwnership / releaseOwnership must be called in thread-context
This commit is contained in:
hathach committed 2020-08-25 18:00:54 +07:00
1 parent c3f8e34790
commit 1f2b65bd45
1 file changed
+8 -24
+8 -24
View File
@@ -287,18 +287,10 @@ bool HardwarePWM::takeOwnership(uintptr_t token)
if ( this->usedChannelCount() != 0 ) return false;
if ( this->enabled() ) return false;
if ( isInISR() )
{
UBaseType_t intr_status = taskENTER_CRITICAL_FROM_ISR();
_owner_token = token;
taskEXIT_CRITICAL_FROM_ISR(intr_status);
}
else
{
taskENTER_CRITICAL();
_owner_token = token;
taskEXIT_CRITICAL();
}
// This function must not be called within ISR
taskENTER_CRITICAL();
_owner_token = token;
taskEXIT_CRITICAL();
return true;
}
@@ -326,18 +318,10 @@ bool HardwarePWM::releaseOwnership(uintptr_t token)
return false; // if it's enabled, do not allow ownership to be released, even with no pins in use
}
if ( isInISR() )
{
UBaseType_t intr_status = taskENTER_CRITICAL_FROM_ISR();
_owner_token = 0;
taskEXIT_CRITICAL_FROM_ISR(intr_status);
}
else
{
taskENTER_CRITICAL();
_owner_token = 0;
taskEXIT_CRITICAL();
}
// This function must not be called within ISR
taskENTER_CRITICAL();
_owner_token = 0;
taskEXIT_CRITICAL();
return true;
}