初始化版本
This commit is contained in:
80
osal/include/osal_def.h
Normal file
80
osal/include/osal_def.h
Normal file
@ -0,0 +1,80 @@
|
||||
#ifndef __OSAL_DEF_H__
|
||||
#define __OSAL_DEF_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Error codes */
|
||||
typedef int osal_err_t;
|
||||
|
||||
#define OSAL_OK 0 /* Operation successful */
|
||||
#define OSAL_ERROR (-1) /* Operation failed */
|
||||
#define OSAL_ETIMEOUT (-2) /* Timeout */
|
||||
#define OSAL_EFULL (-3) /* Resource full */
|
||||
#define OSAL_EEMPTY (-4) /* Resource empty */
|
||||
#define OSAL_ENOMEM (-5) /* No memory */
|
||||
#define OSAL_ENOSYS (-6) /* No system */
|
||||
#define OSAL_EBUSY (-7) /* Busy */
|
||||
#define OSAL_EIO (-8) /* IO error */
|
||||
#define OSAL_EINTR (-9) /* Interrupted */
|
||||
#define OSAL_INVAL (-10) /* Invalid argument */
|
||||
|
||||
/* Backward compatibility */
|
||||
#define OSAL_TIMEOUT OSAL_ETIMEOUT
|
||||
#define OSAL_NO_MEMORY OSAL_ENOMEM
|
||||
|
||||
/* Wait Forever */
|
||||
#define OSAL_WAIT_FOREVER ((osal_tick_t)-1)
|
||||
|
||||
/* Assert */
|
||||
#ifndef OSAL_ASSERT
|
||||
#ifdef OSAL_DEBUG
|
||||
#define OSAL_ASSERT(EX) \
|
||||
if (!(EX)) \
|
||||
{ \
|
||||
extern void osal_kprintf(const char *fmt, ...); \
|
||||
osal_kprintf("(%s) has assert failed at %s:%d.\n", #EX, __FUNCTION__, __LINE__); \
|
||||
while (1); \
|
||||
}
|
||||
#else
|
||||
#define OSAL_ASSERT(EX)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Priority */
|
||||
typedef unsigned char osal_priority_t;
|
||||
|
||||
#define OSAL_PRIORITY_LOWEST 255 /* Lowest priority */
|
||||
#define OSAL_PRIORITY_HIGHEST 0 /* Highest priority */
|
||||
|
||||
/* Basic Types */
|
||||
typedef unsigned int osal_tick_t;
|
||||
typedef unsigned int osal_size_t;
|
||||
typedef int osal_int32_t;
|
||||
typedef unsigned int osal_uint32_t;
|
||||
typedef unsigned char osal_uint8_t;
|
||||
typedef unsigned short osal_uint16_t;
|
||||
typedef void* osal_handle_t;
|
||||
|
||||
/* IPC Flags */
|
||||
#define OSAL_FLAG_FIFO 0x00 /* FIFO scheduling */
|
||||
#define OSAL_FLAG_PRIO 0x01 /* Priority scheduling */
|
||||
|
||||
/* Event Flags */
|
||||
#define OSAL_EVENT_AND 0x01 /* Logic AND */
|
||||
#define OSAL_EVENT_OR 0x02 /* Logic OR */
|
||||
#define OSAL_EVENT_CLEAR 0x04 /* Clear event */
|
||||
|
||||
/* Timer Flags */
|
||||
#define OSAL_TIMER_FLAG_ONE_SHOT 0x00 /* One shot */
|
||||
#define OSAL_TIMER_FLAG_PERIODIC 0x01 /* Periodic */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __OSAL_DEF_H__ */
|
||||
Reference in New Issue
Block a user