cmsis_os.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 { pdTRUE = 1, pdFALSE = 0 } BaseType_t;
  26. typedef int32_t TickType_t;
  27. #define tskIDLE_PRIORITY 0
  28. TaskHandle_t xTaskCreateStatic(TaskFunction_t pxTaskCode,
  29. const char* const pcName,
  30. const uint32_t ulStackDepth,
  31. void* const pvParameters,
  32. UBaseType_t uxPriority,
  33. StackType_t* const puxStackBuffer,
  34. StaticTask_t* const pxTaskBuffer);
  35. void vTaskDelete(TaskHandle_t xTask);
  36. TaskHandle_t xTaskGetCurrentTaskHandle(void);
  37. SemaphoreHandle_t xSemaphoreCreateMutexStatic(StaticSemaphore_t* pxMutexBuffer);
  38. bool task_equal(TaskHandle_t a, TaskHandle_t b);
  39. QueueHandle_t xQueueCreateStatic(UBaseType_t uxQueueLength,
  40. UBaseType_t uxItemSize,
  41. uint8_t* pucQueueStorageBuffer,
  42. StaticQueue_t* pxQueueBuffer);
  43. SemaphoreHandle_t xSemaphoreCreateCountingStatic(UBaseType_t uxMaxCount,
  44. UBaseType_t uxInitialCount,
  45. StaticSemaphore_t* pxSemaphoreBuffer);
  46. BaseType_t xSemaphoreTake(SemaphoreHandle_t xSemaphore, TickType_t xTicksToWait);
  47. BaseType_t xSemaphoreGive(SemaphoreHandle_t xSemaphore);
  48. BaseType_t xQueueSend(QueueHandle_t xQueue, const void* pvItemToQueue, TickType_t xTicksToWait);
  49. BaseType_t xQueueReceive(QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait);
  50. void* pvTaskGetThreadLocalStoragePointer(TaskHandle_t xTaskToQuery, BaseType_t xIndex);
  51. void vTaskSetThreadLocalStoragePointer(TaskHandle_t xTaskToSet, BaseType_t xIndex, void *pvValue);