Skip to content

Commit

Permalink
Use tryEnter for LfsFlash lock
Browse files Browse the repository at this point in the history
  • Loading branch information
danielschloms committed Jul 6, 2024
1 parent fbe811f commit 79fe6a4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Sts1CobcSw/FileSystem/LfsFlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ auto readBuffer = flash::Page{};
auto programBuffer = decltype(readBuffer){};
auto lookaheadBuffer = flash::Page{};

auto mutex = RODOS::Semaphore();

lfs_config const lfsConfig = lfs_config{.context = nullptr,
.read = &Read,
.prog = &Program,
Expand Down Expand Up @@ -137,12 +139,16 @@ auto Sync([[maybe_unused]] lfs_config const * config) -> int

auto Lock(const struct lfs_config * config) -> int
{
return 0;
if (mutex.tryEnter()){
return 0;
}
return -99;
}


auto Unlock(const struct lfs_config * config) -> int
{
mutex.leave();
return 0;
}
}

0 comments on commit 79fe6a4

Please sign in to comment.