Add full automotive RTOS project
Add kernel (Cortex-M0/M3/M4, Tricore, S32K, RISC-V ports), drivers, middleware (CAN stack, diagnostics, safety), applications, board support, build/test tooling, and documentation.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @file semaphore.h
|
||||
* @brief Semaphore synchronization primitive
|
||||
*/
|
||||
|
||||
#ifndef SEMAPHORE_H
|
||||
#define SEMAPHORE_H
|
||||
|
||||
#include "kernel.h"
|
||||
|
||||
/* Semaphore Types */
|
||||
typedef enum {
|
||||
SEMAPHORE_BINARY = 0,
|
||||
SEMAPHORE_COUNTING = 1,
|
||||
SEMAPHORE_MUTEX = 2
|
||||
} SemaphoreType_t;
|
||||
|
||||
/* Semaphore Control Block */
|
||||
typedef struct {
|
||||
SemaphoreType_t type;
|
||||
uint32_t count;
|
||||
uint32_t max_count;
|
||||
TaskHandle_t owner; /* For mutex */
|
||||
uint8_t priority_ceiling;
|
||||
TaskHandle_t* waiting_tasks;
|
||||
uint32_t waiting_count;
|
||||
} Semaphore_t;
|
||||
|
||||
/* Semaphore Functions */
|
||||
KernelStatus_t semaphore_create(Semaphore_t* sem, SemaphoreType_t type,
|
||||
uint32_t initial_count, uint32_t max_count);
|
||||
KernelStatus_t semaphore_take(Semaphore_t* sem, TimeOut_t timeout);
|
||||
KernelStatus_t semaphore_give(Semaphore_t* sem);
|
||||
KernelStatus_t semaphore_delete(Semaphore_t* sem);
|
||||
uint32_t semaphore_get_count(Semaphore_t* sem);
|
||||
|
||||
#endif /* SEMAPHORE_H */
|
||||
Reference in New Issue
Block a user