cmsis_rtos2/
lib.rs

1#![deny(warnings)]
2#![no_std]
3
4#[allow(non_upper_case_globals)]
5#[allow(non_camel_case_types)]
6#[allow(non_snake_case)]
7pub mod cmsis_os2;
8
9#[allow(non_upper_case_globals)]
10#[allow(non_camel_case_types)]
11#[allow(non_snake_case)]
12pub mod os_tick;
13
14pub use cmsis_os2::*;
15
16
17pub fn rtos_kernel_initialize() -> cmsis_os2::osStatus_t {
18    unsafe {
19        cmsis_os2::osKernelInitialize()
20    }
21}
22
23pub fn rtos_kernel_start() -> cmsis_os2::osStatus_t {
24    unsafe {
25        cmsis_os2::osKernelStart()
26    }
27}
28
29pub fn rtos_kernel_get_tick_freq_hz() -> u32 {
30    unsafe {
31        cmsis_os2::osKernelGetTickFreq()
32    }
33}
34
35pub fn rtos_kernel_get_sys_timer_freq_hz() -> u32 {
36    unsafe {
37        cmsis_os2::osKernelGetSysTimerFreq()
38    }
39}
40
41pub fn rtos_os_thread_new(func: osThreadFunc_t,  argument: *mut cty::c_void,  attr: *const osThreadAttr_t) -> osThreadId_t {
42    unsafe {
43        cmsis_os2::osThreadNew(func, argument, attr)
44    }
45}
46
47pub fn rtos_os_thread_yield()  -> cmsis_os2::osStatus_t {
48    unsafe {
49        cmsis_os2::osThreadYield()
50    }
51}
52
53pub fn rtos_os_delay(ticks: u32) -> cmsis_os2::osStatus_t {
54    unsafe {
55        cmsis_os2::osDelay(ticks)
56    }
57}
58
59pub fn rtos_os_timer_new(func: osTimerFunc_t, timer_type: osTimerType_t,  argument: *mut cty::c_void,  attr: *const osTimerAttr_t) -> osTimerId_t {
60    unsafe {
61        cmsis_os2::osTimerNew(func, timer_type, argument, attr)
62    }
63}
64
65pub fn rtos_os_timer_start(timer_id: osTimerId_t, ticks: u32) -> osStatus_t {
66    unsafe {
67        cmsis_os2::osTimerStart(timer_id, ticks)
68    }
69}
70
71pub fn rtos_os_timer_stop(timer_id: osTimerId_t) -> osStatus_t {
72    unsafe {
73        cmsis_os2::osTimerStop(timer_id)
74    }
75}
76
77
78pub fn rtos_os_msg_queue_new(msg_count: u32,
79                             msg_size: u32,
80                             attr: *const osMessageQueueAttr_t) -> osMessageQueueId_t {
81    unsafe {
82        cmsis_os2::osMessageQueueNew(msg_count, msg_size, attr)
83    }
84}
85
86pub fn rtos_os_msg_queue_put(mq_id: osMessageQueueId_t,
87                             msg_ptr: *const cty::c_void,
88                             msg_prio: u8,
89                             timeout: u32) -> osStatus_t {
90    unsafe  {
91        cmsis_os2::osMessageQueuePut(mq_id, msg_ptr, msg_prio, timeout)
92    }
93
94}
95
96pub fn rtos_os_msg_queue_get(mq_id: osMessageQueueId_t,
97                             msg_ptr: *mut cty::c_void,
98                             msg_prio: *mut u8,
99                             timeout: u32) -> osStatus_t {
100    unsafe {
101        cmsis_os2::osMessageQueueGet(mq_id, msg_ptr, msg_prio, timeout)
102    }
103}
104
105
106
107