mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Refactor I2C result to use notifications, allowing faster task yield
Some checks are pending
CI / build (MHP30) (push) Waiting to run
CI / tests (push) Waiting to run
CI / build (Pinecil) (push) Waiting to run
CI / build (Pinecilv2) (push) Waiting to run
CI / build (S60) (push) Waiting to run
CI / build (S60P) (push) Waiting to run
CI / build (T55) (push) Waiting to run
CI / build (TS100) (push) Waiting to run
CI / check_c-cpp (push) Waiting to run
CI / build (TS101) (push) Waiting to run
CI / build (TS80) (push) Waiting to run
CI / build (TS80P) (push) Waiting to run
CI / build_multi-lang (Pinecil) (push) Waiting to run
CI / build_multi-lang (Pinecilv2) (push) Waiting to run
CI / upload_metadata (push) Blocked by required conditions
CI / check_python (push) Waiting to run
CI / check_shell (push) Waiting to run
CI / check_docs (push) Waiting to run
Some checks are pending
CI / build (MHP30) (push) Waiting to run
CI / tests (push) Waiting to run
CI / build (Pinecil) (push) Waiting to run
CI / build (Pinecilv2) (push) Waiting to run
CI / build (S60) (push) Waiting to run
CI / build (S60P) (push) Waiting to run
CI / build (T55) (push) Waiting to run
CI / build (TS100) (push) Waiting to run
CI / check_c-cpp (push) Waiting to run
CI / build (TS101) (push) Waiting to run
CI / build (TS80) (push) Waiting to run
CI / build (TS80P) (push) Waiting to run
CI / build_multi-lang (Pinecil) (push) Waiting to run
CI / build_multi-lang (Pinecilv2) (push) Waiting to run
CI / upload_metadata (push) Blocked by required conditions
CI / check_python (push) Waiting to run
CI / check_shell (push) Waiting to run
CI / check_docs (push) Waiting to run
So that one I2C done, task can directly swap and pickup later if I2C is blocking
This commit is contained in:
@@ -122,7 +122,8 @@ void FRToSI2C::CpltCallback() {
|
|||||||
// Unlock the semaphore && allow task switch if desired by RTOS
|
// Unlock the semaphore && allow task switch if desired by RTOS
|
||||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||||
|
|
||||||
vTaskNotifyGiveFromISR(IRQTaskWaitingHandle, &xHigherPriorityTaskWoken);
|
xSemaphoreGiveFromISR(I2CSemaphore, &xHigherPriorityTaskWoken);
|
||||||
|
xTaskNotifyFromISR(IRQTaskWaitingHandle, IRQFailureMarker ? 2 : 1, eSetValueWithOverwrite, &xHigherPriorityTaskWoken);
|
||||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,11 +169,9 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t read_address, uint8_t *p_b
|
|||||||
I2C_Enable(I2C0_ID);
|
I2C_Enable(I2C0_ID);
|
||||||
|
|
||||||
// Wait for transfer in background
|
// Wait for transfer in background
|
||||||
ulTaskNotifyTake(pdTRUE, TICKS_100MS);
|
uint32_t result = 0;
|
||||||
|
xTaskNotifyWait(0xFFFFFFFF, 0xFFFFFFFF, &result, TICKS_100MS);
|
||||||
bool ok = !IRQFailureMarker; // Capture before unlock so it doesnt get overwritten
|
return result == 1;
|
||||||
unlock();
|
|
||||||
return ok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress, uint8_t *p_buffer, uint16_t number_of_byte) {
|
bool FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress, uint8_t *p_buffer, uint16_t number_of_byte) {
|
||||||
@@ -211,11 +210,9 @@ bool FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress, uint8_t *p_bu
|
|||||||
I2C_Enable(I2C0_ID);
|
I2C_Enable(I2C0_ID);
|
||||||
|
|
||||||
// Wait for transfer in background
|
// Wait for transfer in background
|
||||||
ulTaskNotifyTake(pdTRUE, TICKS_100MS);
|
uint32_t result = 0;
|
||||||
|
xTaskNotifyWait(0xFFFFFFFF, 0xFFFFFFFF, &result, TICKS_100MS);
|
||||||
bool ok = !IRQFailureMarker; // Capture before unlock so it doesnt get overwritten
|
return result == 1;
|
||||||
unlock();
|
|
||||||
return ok;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FRToSI2C::Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size) { return Mem_Write(DevAddress, pData[0], pData + 1, Size - 1); }
|
bool FRToSI2C::Transmit(uint16_t DevAddress, uint8_t *pData, uint16_t Size) { return Mem_Write(DevAddress, pData[0], pData + 1, Size - 1); }
|
||||||
|
|||||||
Reference in New Issue
Block a user