49 lines
1.7 KiB
C
49 lines
1.7 KiB
C
#ifndef NH_COMMON_H
|
|
#define NH_COMMON_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
typedef enum {
|
|
NH_RET_SUCCESS = 0,
|
|
NH_RET_FAIL = 1,
|
|
NH_RET_TIMEOUT = 2,
|
|
} nh_ret_t;
|
|
|
|
/* OSA */
|
|
typedef void *nh_osa_semaphore_t;
|
|
typedef nh_ret_t (*nh_osa_semaphore_create_t)(void *handle, nh_osa_semaphore_t *sem);
|
|
typedef nh_ret_t (*nh_osa_semaphore_take_t)(void *handle, nh_osa_semaphore_t sem, uint32_t timeout_msec);
|
|
typedef nh_ret_t (*nh_osa_semaphore_give_t)(void *handle, nh_osa_semaphore_t sem);
|
|
typedef nh_ret_t (*nh_osa_semaphore_destroy_t)(void *handle, nh_osa_semaphore_t sem);
|
|
|
|
typedef void *nh_osa_queue_t;
|
|
typedef nh_ret_t (*nh_osa_queue_create_t)(void *handle, nh_osa_queue_t *queue, uint32_t item_size, uint32_t max_length);
|
|
typedef nh_ret_t (*nh_osa_queue_enqueue_t)(void *handle, nh_osa_queue_t queue, void *item, uint32_t timeout_msec);
|
|
typedef nh_ret_t (*nh_osa_queue_dequeue_t)(void *handle, nh_osa_queue_t queue, void *item, uint32_t timeout_msec);
|
|
typedef nh_ret_t (*nh_osa_queue_destroy_t)(void *handle, nh_osa_queue_t queue);
|
|
|
|
typedef nh_ret_t (*nh_osa_buf_allocate_t)(void *handle, uint8_t **buf, uint32_t buf_size);
|
|
typedef nh_ret_t (*nh_osa_buf_free_t)(void *handle, uint8_t *buf);
|
|
|
|
typedef struct {
|
|
nh_osa_buf_allocate_t buf_allocate;
|
|
nh_osa_buf_free_t buf_free;
|
|
|
|
/* Semaphore operations */
|
|
nh_osa_semaphore_create_t sem_create;
|
|
nh_osa_semaphore_take_t sem_take;
|
|
nh_osa_semaphore_give_t sem_give;
|
|
nh_osa_semaphore_destroy_t sem_destroy;
|
|
|
|
/* Queue operations */
|
|
nh_osa_queue_create_t queue_create;
|
|
nh_osa_queue_enqueue_t queue_enqueue;
|
|
nh_osa_queue_dequeue_t queue_dequeue;
|
|
nh_osa_queue_destroy_t queue_destroy;
|
|
|
|
void *user_data;
|
|
} nh_osa_t;
|
|
|
|
#endif // NH_COMMON_H
|