Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Silabs] Move NVM semaphore creation to nvm3_lockBegin() #26270

Merged
merged 3 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions src/platform/silabs/SilabsConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ static StaticSemaphore_t nvm3_SemStruct;

void nvm3_lockBegin(void)
{
if (nvm3_Sem == NULL)
{
nvm3_Sem = xSemaphoreCreateBinaryStatic(&nvm3_SemStruct);
xSemaphoreGive(nvm3_Sem);
}

VerifyOrDie(nvm3_Sem != NULL);
xSemaphoreTake(nvm3_Sem, portMAX_DELAY);
}
Expand All @@ -65,15 +71,8 @@ namespace Internal {

CHIP_ERROR SilabsConfig::Init()
{
#ifndef BRD4325A // TODO: fix semaphore usage in nvm3_lock for siwx917. use weak implementation for that board instead
nvm3_Sem = xSemaphoreCreateBinaryStatic(&nvm3_SemStruct);
// nvm3_Sem is created in nvm3_lockBegin()

if (nvm3_Sem == NULL)
{
return CHIP_ERROR_NO_MEMORY;
}
xSemaphoreGive(nvm3_Sem);
#endif // not BRD4325A
return MapNvm3Error(nvm3_open(nvm3_defaultHandle, nvm3_defaultInit));
}

Expand Down