Skip to content

Commit 40e1365

Browse files
ThenujaLNavtajh04Yarik-Popov
authored
[BUGFIX] OBC SPI Driver - bus owner check (#266)
# Purpose - Bug fix for checking if the current task is the mutex holder - EDIT: [Link to notion ticket](https://www.notion.so/uworbital/BUG-Fix-OBC-SPI-driver-50ed1a38fbfa441fab73eb4e53031da8?pvs=4) # New Changes - Updated mutex check to work without the task having to acquire the mutex - Get the mutex holder task handle, get the current task handle and compare the two # Testing - Tested build - Wrote test tasks and verified behaviours. Test task pushed to new test branch [here](4262284#diff-2274f55664008bf88953e91bf95c1d2c00f9a207f0ad7d21d18b8240e808340e) - Test serial output: ```Testing isSpiBusOwner... Acquired mutex PASS: isSpiBusOwner returned TRUE after acquiring mutex Releasing mutex... Released mutex PASS: isSpiBusOwner returned FALSE after releasing mutex PASSED isSpiBusOwner Test! ``` # Outstanding Changes - NA EDIT 2025-03-01: Added more change details, on-board testing --------- Co-authored-by: Navtajhundal <87790825+Navtajh04@users.noreply.github.com> Co-authored-by: Yarik Popov <89220488+Yarik-Popov@users.noreply.github.com>
1 parent 30ae0d6 commit 40e1365

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

obc/app/drivers/rm46/obc_spi_io.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,10 @@ static void spiLogErrors(uint32_t spiErr) {
248248
}
249249

250250
bool isSpiBusOwner(SemaphoreHandle_t spiMutex) {
251-
portENTER_CRITICAL();
252251
TaskHandle_t owner = xSemaphoreGetMutexHolder(spiMutex);
253-
portEXIT_CRITICAL();
252+
TaskHandle_t currentTask = xTaskGetCurrentTaskHandle();
254253

255-
return xSemaphoreGetMutexHolder(spiMutex) == owner;
254+
return currentTask == owner;
256255
}
257256

258257
obc_error_code_t getSpiMutex(spiBASE_t *spi, SemaphoreHandle_t *mutex) {

0 commit comments

Comments
 (0)