panic-stubbing FreeRTOS calls for tests

This commit is contained in:
2025-11-17 22:41:04 +01:00
parent b42fb93d98
commit 8bba968d02
+141
View File
@@ -23,6 +23,9 @@ impl Sizes {
pub const TASK_MINIMAL_STACK_SIZE: usize = 10240;
}
#[cfg(not(test))]
extern "C" {
////////////////////////
/// FreeRTOS API
@@ -101,6 +104,144 @@ extern "C" {
//int hw_device_open(const char * path, size_t path_len);
pub fn hw_device_open(path: *const core::ffi::c_char, path_len: core::ffi::c_size_t) -> core::ffi::c_int;
}
#[cfg(test)]
pub use test_api::*;
#[cfg(test)]
mod test_api{
use core::ptr;
use super::*;
////////////////////////
/// FreeRTOS API
/// shimmed in mission/freeRTOS_rust_helper.c
//void *create_task_static(TaskFunction_t taskFunction, void *parameter,
// char *task_data, uint32_t task_data_len, char *stack, uint32_t stack_size)
pub fn freertos_create_task_static(
taskFunction: TaskFunction,
parameter: *const core::ffi::c_void,
priority: u32,
task_data: *mut core::ffi::c_char,
task_data_len: u32,
stack: *mut core::ffi::c_char,
stack_size: u32,
) -> *const core::ffi::c_void{
panic!("freeRTOS APIs are not implemented for tests");
ptr::null()
}
// pub fn stop_it();
pub fn freertos_task_suspend(handle: *const core::ffi::c_void){
panic!("freeRTOS APIs are not implemented for tests");
}
pub fn freertos_task_delete(handle: *const core::ffi::c_void) -> !{
panic!("freeRTOS APIs are not implemented for tests");
loop{}
}
pub fn freertos_task_storage_set(
handle: *const core::ffi::c_void,
data: *const core::ffi::c_void,
){
panic!("freeRTOS APIs are not implemented for tests");
}
pub fn freertos_task_storage_get(handle: *const core::ffi::c_void) -> *const core::ffi::c_void{
panic!("freeRTOS APIs are not implemented for tests");
ptr::null()
}
pub fn freertos_task_delay(milliseconds: u32){
panic!("freeRTOS APIs are not implemented for tests");
}
pub fn freertos_task_stack_watermark() -> u32{
panic!("freeRTOS APIs are not implemented for tests");
1
}
pub fn freertos_task_current() -> *const core::ffi::c_void{
panic!("freeRTOS APIs are not implemented for tests");
ptr::null()
}
// TODO this should be passed by compile time value
pub fn freertos_task_priority_max() -> u32{
panic!("freeRTOS APIs are not implemented for tests");
u32::MAX
}
//void *freertos_queue_create_static(uint32_t depth, uint32_t element_size,
// char *queue_data, uint32_t queue_data_len,
// uint8_t *queue, uint32_t queue_len) {
pub fn freertos_queue_create_static(
depth: u32,
element_size: u32,
queue_data: *mut core::ffi::c_char,
queue_data_len: u32,
queue: *mut u8,
) -> *const core::ffi::c_void{
panic!("freeRTOS APIs are not implemented for tests");
ptr::null()
}
pub fn freertos_queue_receive(
queue: *const core::ffi::c_void,
message: *const core::ffi::c_void,
) -> u8{
panic!("freeRTOS APIs are not implemented for tests");
1
}
pub fn freertos_queue_send(
queue: *const core::ffi::c_void,
message: *const core::ffi::c_void,
) -> u8{
panic!("freeRTOS APIs are not implemented for tests");
1
}
pub fn freertos_mutex_create_static(
mutex_data: *const core::ffi::c_char,
mutex_data_len: u32,
) -> *const core::ffi::c_void{
panic!("freeRTOS APIs are not implemented for tests");
ptr::null()
}
pub fn freertos_mutex_take(mutex: *const core::ffi::c_void) -> u8{
panic!("freeRTOS APIs are not implemented for tests");
1
}
pub fn freertos_mutex_give(mutex: *const core::ffi::c_void) -> u8{
panic!("freeRTOS APIs are not implemented for tests");
1
}
//uint8_t freertos_simple_once(uint8_t *once_data)
pub fn freertos_simple_once(once_data: *const u8) -> u8{
panic!("freeRTOS APIs are not implemented for tests");
1
}
//int freertos_get_sys_error()
pub fn freertos_get_sys_error() -> core::ffi::c_int{
panic!("freeRTOS APIs are not implemented for tests");
1
}
////////////////////////
/// Harware Abstraction API in common/include/interfaces.h
/// Used for access to peripherals to make switching between linux and embedded easier
//int hw_device_open(const char * path, size_t path_len);
pub fn hw_device_open(path: *const core::ffi::c_char, path_len: core::ffi::c_size_t) -> core::ffi::c_int{
panic!("freeRTOS APIs are not implemented for tests");
1
}
}
////////////////////////
/// libc API (read/write/etc)
#[cfg(target_env = "gnu")]