cmsis_os.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. SemaphoreTypeCounting
  13. } SemaphoreType;
  14. typedef struct {
  15. SemaphoreType type;
  16. uint8_t take_counter;
  17. uint8_t give_counter;
  18. } StaticSemaphore_t;
  19. typedef StaticSemaphore_t* SemaphoreHandle_t;
  20. typedef uint32_t StaticQueue_t;
  21. typedef StaticQueue_t* QueueHandle_t;
  22. #define portMAX_DELAY -1
  23. typedef enum {
  24. pdTRUE = 1,
  25. pdFALSE = 0
  26. } BaseType_t;
  27. typedef int32_t TickType_t;
  28. #define tskIDLE_PRIORITY 0
  29. TaskHandle_t xTaskCreateStatic(
  30. TaskFunction_t pxTaskCode,
  31. const char * const pcName,
  32. const uint32_t ulStackDepth,
  33. void * const pvParameters,
  34. UBaseType_t uxPriority,
  35. StackType_t * const puxStackBuffer,
  36. StaticTask_t * const pxTaskBuffer
  37. );
  38. void vTaskDelete(TaskHandle_t xTask);
  39. TaskHandle_t xTaskGetCurrentTaskHandle(void);
  40. SemaphoreHandle_t xSemaphoreCreateMutexStatic(StaticSemaphore_t* pxMutexBuffer);
  41. bool task_equal(TaskHandle_t a, TaskHandle_t b);
  42. QueueHandle_t xQueueCreateStatic(
  43. UBaseType_t uxQueueLength,
  44. UBaseType_t uxItemSize,
  45. uint8_t* pucQueueStorageBuffer,
  46. StaticQueue_t* pxQueueBuffer
  47. );
  48. SemaphoreHandle_t xSemaphoreCreateCountingStatic(
  49. UBaseType_t uxMaxCount,
  50. UBaseType_t uxInitialCount,
  51. StaticSemaphore_t *pxSemaphoreBuffer
  52. );
  53. BaseType_t xSemaphoreTake(SemaphoreHandle_t xSemaphore, TickType_t xTicksToWait);
  54. BaseType_t xSemaphoreGive(SemaphoreHandle_t xSemaphore);
  55. BaseType_t xQueueSend(
  56. QueueHandle_t xQueue, const void * pvItemToQueue, TickType_t xTicksToWait
  57. );
  58. BaseType_t xQueueReceive(QueueHandle_t xQueue, void *pvBuffer, TickType_t xTicksToWait);