@@ -322,12 +322,12 @@ impl CurrentTask {
322
322
}
323
323
324
324
#[ derive( Debug ) ]
325
- pub struct FreeRtosSchedulerState {
325
+ pub struct FreeRtosSystemState {
326
326
pub tasks : Vec < FreeRtosTaskStatus > ,
327
327
pub total_run_time : u32 ,
328
328
}
329
329
330
- impl fmt:: Display for FreeRtosSchedulerState {
330
+ impl fmt:: Display for FreeRtosSystemState {
331
331
fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
332
332
fmt. write_str ( "FreeRTOS tasks\r \n " ) ?;
333
333
@@ -385,6 +385,13 @@ pub struct FreeRtosTaskStatus {
385
385
386
386
pub struct FreeRtosUtils ;
387
387
388
+ #[ derive( Debug , Clone , Copy , PartialEq ) ]
389
+ pub enum FreeRtosSchedulerState {
390
+ Suspended ,
391
+ NotStarted ,
392
+ Running
393
+ }
394
+
388
395
impl FreeRtosUtils {
389
396
// Should only be used for testing purpose!
390
397
pub fn invoke_assert ( ) {
@@ -398,6 +405,17 @@ impl FreeRtosUtils {
398
405
}
399
406
}
400
407
408
+ pub fn scheduler_state ( ) -> FreeRtosSchedulerState {
409
+ unsafe {
410
+ match freertos_rt_xTaskGetSchedulerState ( ) {
411
+ 0 => FreeRtosSchedulerState :: Suspended ,
412
+ 1 => FreeRtosSchedulerState :: NotStarted ,
413
+ 2 => FreeRtosSchedulerState :: Running ,
414
+ _ => unreachable ! ( ) ,
415
+ }
416
+ }
417
+ }
418
+
401
419
pub fn get_tick_count ( ) -> FreeRtosTickType {
402
420
unsafe { freertos_rs_xTaskGetTickCount ( ) }
403
421
}
@@ -410,7 +428,7 @@ impl FreeRtosUtils {
410
428
unsafe { freertos_rs_get_number_of_tasks ( ) as usize }
411
429
}
412
430
413
- pub fn get_all_tasks ( tasks_len : Option < usize > ) -> FreeRtosSchedulerState {
431
+ pub fn get_all_tasks ( tasks_len : Option < usize > ) -> FreeRtosSystemState {
414
432
let tasks_len = tasks_len. unwrap_or ( Self :: get_number_of_tasks ( ) ) ;
415
433
let mut tasks = Vec :: with_capacity ( tasks_len as usize ) ;
416
434
let mut total_run_time = 0 ;
@@ -441,7 +459,7 @@ impl FreeRtosUtils {
441
459
} )
442
460
. collect ( ) ;
443
461
444
- FreeRtosSchedulerState {
462
+ FreeRtosSystemState {
445
463
tasks : tasks,
446
464
total_run_time : total_run_time,
447
465
}
0 commit comments