executing GPT etc callbacks in a thread, not ISR context
Posted: Mon Feb 17, 2014 5:25 pm
Hi, I'm new to ChibiOS. I compiled and run the RTOS on a STM32F103 dev board with simple ADC via DMA, multithreading demos etc. Now I wrote a simple own async implementation for sending RC switch-compliant commands to wireless AC sockets which is based on GPT callbacks/bitbanging.
The code works ok, the time diagram the method produces is perfect, yet I was slightly surprised by the fact that the OS concept dictates the callback code being executed in an ISR context - this is generally ok when the callback is fast and simple nor there's a need to use general API functions, but might be a problem otherwise. Moreover, the programmer has to always keep in mind which callback functions are called from an ISR, and which - from thread contexts.
I remember I used a ISR return address forging technique on a x86/MS-DOS to release the ISR context (store and patch ISR return address in the stack) - which frees the ISR context and runs the interrupt-driven user function in the user context. I wonder if such technique can (or planned to) be used in this RTOS for the callbacks? I understand that besides bringing in the cross-thread execution there might be platform-dependent restrictions from doing this - but on the other hand, you should be switching threads the alike manner in the scheduler.
Thank you,
Gleb
The code works ok, the time diagram the method produces is perfect, yet I was slightly surprised by the fact that the OS concept dictates the callback code being executed in an ISR context - this is generally ok when the callback is fast and simple nor there's a need to use general API functions, but might be a problem otherwise. Moreover, the programmer has to always keep in mind which callback functions are called from an ISR, and which - from thread contexts.
I remember I used a ISR return address forging technique on a x86/MS-DOS to release the ISR context (store and patch ISR return address in the stack) - which frees the ISR context and runs the interrupt-driven user function in the user context. I wonder if such technique can (or planned to) be used in this RTOS for the callbacks? I understand that besides bringing in the cross-thread execution there might be platform-dependent restrictions from doing this - but on the other hand, you should be switching threads the alike manner in the scheduler.
Thank you,
Gleb