Bill Greiman
Well-known member
I have updated the ChRt library to release 19.1.3 of ChibiOS and added support for Teensy 4.0.
Release 19.1.3 is about two years newer than the version I used in the last update of ChRt. There are many new features and improvements.
Giovanni Di Sirio is the author of ChibiOS. Giovanni has excellent understanding of RTOS theory and algorithms. He also has more than 25 years of practical experience working with RTOS applications.
Teensy 4.0 does a context switch in about 200 ns with this version of ChibiOS.
Teensy 4.0 is supported in both periodic and tick-less mode. Tick-less mode is great since there is little interrupt overhead. ChibiOS has a true tick-less mode. Other RTOSs like FreeRTOS only have a tick-less idle mode when no tasks are run-able.
See this article about ChibiOS tick-less mode.
I have run the system timer as fast as one MHz and it works with no extra overhead. chThdSleepUntil() then has a resolution of one microsecond.
Teensy 4.0 is a great match for ChibiOS. The GPT timer exactly fits the ChibiOS requirement. Most functions are a single line of code. Here are the low level timer functions for ChibiOS.
Release 19.1.3 is about two years newer than the version I used in the last update of ChRt. There are many new features and improvements.
Giovanni Di Sirio is the author of ChibiOS. Giovanni has excellent understanding of RTOS theory and algorithms. He also has more than 25 years of practical experience working with RTOS applications.
Teensy 4.0 does a context switch in about 200 ns with this version of ChibiOS.
Teensy 4.0 is supported in both periodic and tick-less mode. Tick-less mode is great since there is little interrupt overhead. ChibiOS has a true tick-less mode. Other RTOSs like FreeRTOS only have a tick-less idle mode when no tasks are run-able.
See this article about ChibiOS tick-less mode.
I have run the system timer as fast as one MHz and it works with no extra overhead. chThdSleepUntil() then has a resolution of one microsecond.
Teensy 4.0 is a great match for ChibiOS. The GPT timer exactly fits the ChibiOS requirement. Most functions are a single line of code. Here are the low level timer functions for ChibiOS.
Code:
/**
* @brief Returns the time counter value.
*
* @return The counter value.
*
* @notapi
*/
static inline systime_t st_lld_get_counter(void) {
return (systime_t)GPT2_CNT;
}
/**
* @brief Starts the alarm.
* @note Makes sure that no spurious alarms are triggered after
* this call.
*
* @param[in] time the time to be set for the first alarm
*
* @notapi
*/
static inline void st_lld_start_alarm(systime_t time) {
GPT2_OCR1 = (uint32_t)time;
GPT2_SR |= GPT_SR_OF1;
GPT2_IR = GPT_IR_OF1IE;
}
/**
* @brief Stops the alarm interrupt.
*
* @notapi
*/
static inline void st_lld_stop_alarm(void) {
GPT2_IR = 0;
}
/**
* @brief Sets the alarm time.
*
* @param[in] time the time to be set for the next alarm
*
* @notapi
*/
static inline void st_lld_set_alarm(systime_t time) {
GPT2_OCR1 = (uint32_t)time;
}
/**
* @brief Returns the current alarm time.
*
* @return The currently set alarm time.
*
* @notapi
*/
static inline systime_t st_lld_get_alarm(void) {
return (systime_t)GPT2_OCR1;
}
/**
* @brief Determines if the alarm is active.
*
* @return The alarm status.
* @retval false if the alarm is not active.
* @retval true is the alarm is active
*
* @notapi
*/
static inline bool st_lld_is_alarm_active(void) {
return (GPT2_IR & GPT_SR_OF1) != 0;
}