os.h (1767B)
1 #ifndef __OS_H__ 2 #define __OS_H__ 3 4 #include "FreeRTOS.h" 5 #include "queue.h" 6 #include "task.h" 7 8 /* 9 * Number of cirtical tasks, queues, and interrupts (doggies ;P ) to be checked by watchdog 10 * ** Periodic events: 11 * 1. Capture timer interrupt 12 * 2. Channel switching task 13 * 3. Detector data queue 14 * 4. Detector task 15 * ** Semi-rare events: 16 * 5. Classifier data queue 17 * 6. Classifier task 18 * ** Rare events: 19 * 7. Usart receive interrupt 20 * 8. Packet task 21 */ 22 #define OS_DOGGY_NUM 0x08 23 #define OS_DOGGY_RESET_VALUE (0x01 << 0x00) 24 #define OS_DOGGY_TIM_CAPTURE (0x01 << 0x01) 25 #define OS_DOGGY_CHANNEL_T (0x01 << 0x02) 26 #define OS_DOGGY_DETECTOR_Q (0x01 << 0x03) 27 #define OS_DOGGY_DETECTOR_T (0x01 << 0x04) 28 #define OS_DOGGY_CLASSIFIER_Q (0x01 << 0x05) 29 #define OS_DOGGY_CLASSIFIER_T (0x01 << 0x06) 30 #define OS_DOGGY_UART_DATA (0x01 << 0x07) 31 #define OS_DOGGY_PACKET_T (0x01 << 0x08) 32 33 extern volatile uint16_t osDoggyRegister; 34 35 enum OS_DOGGY_REG_SAFE_VALUES { 36 PERIODIC_CHAIN = 37 (OS_DOGGY_DETECTOR_T | OS_DOGGY_DETECTOR_Q | OS_DOGGY_CHANNEL_T | OS_DOGGY_TIM_CAPTURE), 38 CLASSIFIER_CHAIN = (OS_DOGGY_CLASSIFIER_T | OS_DOGGY_CLASSIFIER_Q), 39 UART_CHAIN = (OS_DOGGY_PACKET_T | OS_DOGGY_UART_DATA), 40 }; 41 42 typedef struct { 43 TaskFunction_t function; 44 const char *const name; 45 const configSTACK_DEPTH_TYPE stackSize; 46 void *const parameters; 47 UBaseType_t priority; 48 } OS_TaskAttr_t; 49 50 typedef struct { 51 UBaseType_t length; 52 UBaseType_t itemSize; 53 uint8_t *pxStorageBuf; 54 StaticQueue_t *pxQueueBuf; 55 } OS_QueueAttr_t; 56 57 void os_init_rtos(void); 58 TaskHandle_t os_create_task(const OS_TaskAttr_t attr, TaskHandle_t handle); 59 QueueHandle_t os_create_queue(const OS_QueueAttr_t attr, QueueHandle_t handle); 60 61 #endif // __OS_H__