cmsis_os.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #include "main.h"
  3. #include <stdbool.h>
  4. void osDelay(uint32_t ms);
  5. // some FreeRTOS types
  6. typedef void(*TaskFunction_t)(void*);
  7. typedef size_t UBaseType_t;
  8. typedef uint32_t StackType_t;
  9. typedef uint32_t StaticTask_t;
  10. typedef pthread_t* TaskHandle_t;
  11. typedef enum {
  12. SemaphoreTypeMutex,
  13. SemaphoreTypeCounting,
  14. } SemaphoreType;
  15. typedef struct {
  16. SemaphoreType type;
  17. pthread_mutex_t mutex;
  18. uint8_t take_counter;
  19. uint8_t give_counter;
  20. } StaticSemaphore_t;
  21. typedef StaticSemaphore_t* SemaphoreHandle_t;
  22. typedef uint32_t StaticQueue_t;
  23. typedef StaticQueue_t* QueueHandle_t;
  24. #define portMAX_DELAY -1
  25. typedef enum {
  26. pdTRUE = 1,
  27. pdFALSE = 0
  28. } BaseType_t;
  29. typedef int32_t TickType_t;
  30. #define tskIDLE_PRIORITY 0
  31. TaskHandle_t xTaskCreateStatic(
  32. TaskFunction_t pxTaskCode,
  33. const char * const pcName,
  34. const uint32_t ulStackDepth,
  35. void * const pvParameters,
  36. UBaseType_t uxPriority,
  37. StackType_t * const puxStackBuffer,
  38. StaticTask_t * const pxTaskBuffer
  39. );
  40. void vTaskDelete(TaskHandle_t xTask);
  41. TaskHandle_t xTaskGetCurrentTaskHandle(void);
  42. SemaphoreHandle_t xSemaphoreCreateMutexStatic(StaticSemaphore_t* pxMutexBuffer);
  43. bool task_equal(TaskHandle_t a, TaskHandle_t b);
  44. QueueHandle_t xQueueCreateStatic(
  45. UBaseType_t uxQueueLength,
  46. UBaseType_t uxItemSize,
  47. uint8_t* pucQueueStorageBuffer,
  48. StaticQueue_t* pxQueueBuffer
  49. );
  50. SemaphoreHandle_t xSemaphoreCreateCountingStatic(
  51. UBaseType_t uxMaxCount,
  52. UBaseType_t uxInitialCount,
  53. StaticSemaphore_t *pxSemaphoreBuffer
  54. );
  55. BaseType_t xSemaphoreTake(SemaphoreHandle_t xSemaphore, TickType_t xTicksToWait);
  56. BaseType_t xSemaphoreGive(SemaphoreHandle_t xSemaphore);
  57. BaseType_t xQueueSend(
  58. QueueHandle_t xQueue, const void * pvItemToQueue, TickType_t xTicksToWait
  59. );
  60. BaseType_t xQueueReceive(QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait);