Skip to content

Commit

Permalink
Move NVM initialization to sl_platform_init() in matter_support submo…
Browse files Browse the repository at this point in the history
…dule

Also move nvm3_Sem creation to nvm3_lockBegin()
  • Loading branch information
selissia committed Apr 26, 2023
1 parent fa3563a commit ffc2fbf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 9 additions & 10 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,16 +71,9 @@ 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);

if (nvm3_Sem == NULL)
{
return CHIP_ERROR_NO_MEMORY;
}
xSemaphoreGive(nvm3_Sem);
#endif // not BRD4325A
return MapNvm3Error(nvm3_open(nvm3_defaultHandle, nvm3_defaultInit));
// nvm3_Sem is created in nvm3_lockBegin()
// nvm3_open() is called by nvm3_initDefault() in sl_platform_init() in SLC-generated sl_event_handler.c
return CHIP_NO_ERROR;
}

void SilabsConfig::DeInit()
Expand Down

0 comments on commit ffc2fbf

Please sign in to comment.