1 /* 2 * Copyright (c) 2018 Intel Corporation 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_INCLUDE_CMSIS_TYPES_H_ 8 #define ZEPHYR_INCLUDE_CMSIS_TYPES_H_ 9 10 #include <stdbool.h> 11 #include <zephyr/kernel.h> 12 #include <zephyr/portability/cmsis_os2.h> 13 14 /** @brief Size for names of RTOS objects. */ 15 #define CMSIS_OBJ_NAME_MAX_LEN 16 16 17 /** 18 * @brief Control block for a CMSIS-RTOSv2 thread. 19 * 20 * Application can use manual user-defined allocation for RTOS objects by supplying a pointer to 21 * thread control block. Control block is initiazed within `osThreadNew()`. 22 */ 23 struct cmsis_rtos_thread_cb { 24 sys_dnode_t node; 25 struct k_thread z_thread; 26 struct k_poll_signal poll_signal; 27 struct k_poll_event poll_event; 28 uint32_t signal_results; 29 char name[CMSIS_OBJ_NAME_MAX_LEN]; 30 uint32_t attr_bits; 31 }; 32 33 /** 34 * @brief Control block for a CMSIS-RTOSv2 timer. 35 * 36 * Application can use manual user-defined allocation for RTOS objects by supplying a pointer to 37 * timer control block. Control block is initiazed within `osTimerNew()`. 38 */ 39 struct cmsis_rtos_timer_cb { 40 struct k_timer z_timer; 41 osTimerType_t type; 42 uint32_t status; 43 bool is_cb_dynamic_allocation; 44 char name[CMSIS_OBJ_NAME_MAX_LEN]; 45 void (*callback_function)(void *argument); 46 void *arg; 47 }; 48 49 /** 50 * @brief Control block for a CMSIS-RTOSv2 mutex. 51 * 52 * Application can use manual user-defined allocation for RTOS objects by supplying a pointer to 53 * mutex control block. Control block is initiazed within `osMutexNew()`. 54 */ 55 struct cmsis_rtos_mutex_cb { 56 struct k_mutex z_mutex; 57 bool is_cb_dynamic_allocation; 58 char name[CMSIS_OBJ_NAME_MAX_LEN]; 59 uint32_t state; 60 }; 61 62 /** 63 * @brief Control block for a CMSIS-RTOSv2 semaphore. 64 * 65 * Application can use manual user-defined allocation for RTOS objects by supplying a pointer to 66 * semaphore control block. Control block is initiazed within `osSemaphoreNew()`. 67 */ 68 struct cmsis_rtos_semaphore_cb { 69 struct k_sem z_semaphore; 70 bool is_cb_dynamic_allocation; 71 char name[CMSIS_OBJ_NAME_MAX_LEN]; 72 }; 73 74 /** 75 * @brief Control block for a CMSIS-RTOSv2 memory pool. 76 * 77 * Application can use manual user-defined allocation for RTOS objects by supplying a pointer to 78 * memory pool control block. Control block is initiazed within `osMemoryPoolNew()`. 79 */ 80 struct cmsis_rtos_mempool_cb { 81 struct k_mem_slab z_mslab; 82 void *pool; 83 char is_dynamic_allocation; 84 bool is_cb_dynamic_allocation; 85 char name[CMSIS_OBJ_NAME_MAX_LEN]; 86 }; 87 88 /** 89 * @brief Control block for a CMSIS-RTOSv2 message queue. 90 * 91 * Application can use manual user-defined allocation for RTOS objects by supplying a pointer to 92 * message queue control block. Control block is initiazed within `osMessageQueueNew()`. 93 */ 94 struct cmsis_rtos_msgq_cb { 95 struct k_msgq z_msgq; 96 void *pool; 97 char is_dynamic_allocation; 98 bool is_cb_dynamic_allocation; 99 char name[CMSIS_OBJ_NAME_MAX_LEN]; 100 }; 101 102 /** 103 * @brief Control block for a CMSIS-RTOSv2 event flag. 104 * 105 * Application can use manual user-defined allocation for RTOS objects by supplying a pointer to 106 * event flag control block. Control block is initiazed within `osEventFlagsNew()`. 107 */ 108 struct cmsis_rtos_event_cb { 109 struct k_poll_signal poll_signal; 110 struct k_poll_event poll_event; 111 uint32_t signal_results; 112 bool is_cb_dynamic_allocation; 113 char name[CMSIS_OBJ_NAME_MAX_LEN]; 114 }; 115 116 #endif 117