I have device on STM32L051 (battery monitor) that uses I2C, UART and GPIO, now implemented using STM32 HAL.
Most of time CPU is in STOP mode, wakes up by EXTI 4 times per second, makes I2C transmission and sleeps again.
On STM32 HAL I work with I2C from EXTI handler with no problems.
Now I want to move to ChibiOS 18 HAL. STOP mode looks a bit complicated when using RTOS and I actually don't need scheduler and other RTOS features on this small application, so I'm trying to run HAL without RTOS, using OSAL from hal/osal/os-less/ARMCMx. Everything works until I try to use I2C from EXTI callback:
Code: Select all
void alert_cb(void *arg) {
(void) arg;
osalSysLockFromISR();
do_some_i2c_transmissions();
osalSysUnlockFromISR();
}
Then it spins forever in this loop inside osalThreadSuspendS called from i2cMasterTransmitTimeout:
hal/osal/os-less/ARMCMx/osal.c:209
Code: Select all
while (self.message == MSG_WAIT) {
osalSysUnlock();
/* A state-changing interrupt could occur here and cause the loop to
terminate, an hook macro is executed while waiting.*/
OSAL_IDLE_HOOK();
osalSysLock();
}
As I understand I can't work with I2C from ISR handler? With NIL RTOS I can use semaphores to pass event from ISR to thread and it works (tried already), but how to solve it without RTOS?