Use mutexes to guard the MCP
This commit is contained in:
parent
a3783ceffa
commit
59f9b29df3
5 changed files with 164 additions and 77 deletions
|
@ -9,6 +9,8 @@ void buttonTask(void *parameter)
|
|||
while (1)
|
||||
{
|
||||
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
|
||||
std::lock_guard<std::mutex> lock(mcpMutex);
|
||||
|
||||
TickType_t currentTime = xTaskGetTickCount();
|
||||
if ((currentTime - lastDebounceTime) >= debounceDelay)
|
||||
{
|
||||
|
@ -35,11 +37,14 @@ void buttonTask(void *parameter)
|
|||
}
|
||||
}
|
||||
mcp.clearInterrupts();
|
||||
// Very ugly, but for some reason this is necessary
|
||||
while (!digitalRead(MCP_INT_PIN))
|
||||
{
|
||||
mcp.clearInterrupts();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
// Very ugly, but for some reason this is necessary
|
||||
while (!digitalRead(MCP_INT_PIN))
|
||||
{
|
||||
mcp.clearInterrupts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue