1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #ifndef _OSAL_H_
- #define _OSAL_H_
- #include <freertos/FreeRTOS.h>
- #include <freertos/task.h>
- #include <unistd.h>
- #include <stdint.h>
- #include <esp_timer.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define OS_SUCCESS ESP_OK
- #define OS_FAIL ESP_FAIL
- typedef TaskHandle_t othread_t;
- static inline int httpd_os_thread_create(othread_t *thread,
- const char *name, uint16_t stacksize, int prio,
- void (*thread_routine)(void *arg), void *arg,
- BaseType_t core_id)
- {
- StaticTask_t *xTaskBuffer = (StaticTask_t*) heap_caps_malloc(sizeof(StaticTask_t), (MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT));
- StackType_t *xStack = heap_caps_malloc(stacksize,(MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT));
- *thread = xTaskCreateStaticPinnedToCore(thread_routine, name, stacksize, arg, prio, xStack,xTaskBuffer,core_id);
- if (*thread) {
- return OS_SUCCESS;
- }
- return OS_FAIL;
- }
- static inline void httpd_os_thread_delete(void)
- {
- vTaskDelete(xTaskGetCurrentTaskHandle());
- }
- static inline void httpd_os_thread_sleep(int msecs)
- {
- vTaskDelay(msecs / portTICK_RATE_MS);
- }
- static inline othread_t httpd_os_thread_handle(void)
- {
- return xTaskGetCurrentTaskHandle();
- }
- #ifdef __cplusplus
- }
- #endif
- #endif
|