Go to the documentation of this file. 27 #ifndef _CSP_PLATFORM_H_ 28 #define _CSP_PLATFORM_H_ 37 #if defined(CSP_POSIX) || defined(CSP_WINDOWS) || defined(CSP_MACOSX) 38 #define CSP_BASE_TYPE int 39 #define CSP_MAX_DELAY (UINT32_MAX) 40 #define CSP_INFINITY (UINT32_MAX) 41 #define CSP_DEFINE_CRITICAL(lock) static csp_bin_sem_handle_t lock 42 #define CSP_INIT_CRITICAL(lock) ({(csp_bin_sem_create(&lock) == CSP_SEMAPHORE_OK) ? CSP_ERR_NONE : CSP_ERR_NOMEM;}) 43 #define CSP_ENTER_CRITICAL(lock) do { csp_bin_sem_wait(&lock, CSP_MAX_DELAY); } while(0) 44 #define CSP_EXIT_CRITICAL(lock) do { csp_bin_sem_post(&lock); } while(0) 45 #elif defined(CSP_FREERTOS) 47 #define CSP_BASE_TYPE portBASE_TYPE 48 #define CSP_MAX_DELAY portMAX_DELAY 49 #define CSP_INFINITY portMAX_DELAY 50 #define CSP_DEFINE_CRITICAL(lock) 51 #define CSP_INIT_CRITICAL(lock) ({CSP_ERR_NONE;}) 52 #define CSP_ENTER_CRITICAL(lock) do { portENTER_CRITICAL(); } while (0) 53 #define CSP_EXIT_CRITICAL(lock) do { portEXIT_CRITICAL(); } while (0) 55 #error "OS must be either CSP_POSIX, CSP_MACOSX, CSP_FREERTOS OR CSP_WINDOWS" 62 #endif // _CSP_PLATFORM_H_