#ifndef __OS_TYPE_H_
#define __OS_TYPE_H_

#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include <stdbool.h>

#define TASK_STACK_MINIMAL          (128U)
#define TASK_STACK_NORMAL           (512U)
#define OS_WAIT_INFINITE            (0xFFFFFFFF)

typedef enum OS_Error
{
     OS_ERROR_OK              /* Successful           */
    ,OS_ERROR_NG              /* Failing              */
    ,OS_ERROR_TIMEOUT         /* Mission timeouts     */
    ,OS_ERROR_MEMORY          /* Out of memory        */
    ,OS_ERROR_FULL            /* The queue is full    */
    ,OS_ERROR_QUEUE           /* Queue does not exist */
    ,OS_ERROR_UNKNOWN         /* Unknown error        */
} OS_Error;

/* Task Priority */
enum
{
    TASK_PRIORITY_IDLE = 0
   ,TASK_PRIORITY_LOWEST
   ,TASK_PRIORITY_BELOW_NORMAL
   ,TASK_PRIORITY_NORMAL
   ,TASK_PRIORITY_ABOVE_NORMAL
   ,TASK_PRIORITY_HIGHEST
};

/* Queue Length */
enum
{
    QUEUE_LENGTH_1   = 1
   ,QUEUE_LENGTH_2   = 2
   ,QUEUE_LENGTH_3   = 3
   ,QUEUE_LENGTH_4   = 4
   ,QUEUE_LENGTH_5   = 5
   ,QUEUE_LENGTH_6   = 6
   ,QUEUE_LENGTH_7   = 7
   ,QUEUE_LENGTH_8   = 8
   ,QUEUE_LENGTH_9   = 9
   ,QUEUE_LENGTH_16  = 16
   ,QUEUE_LENGTH_20  = 20
   ,QUEUE_LENGTH_32  = 32
   ,QUEUE_LENGTH_50  = 50
   ,QUEUE_LENGTH_64  = 64
   ,QUEUE_LENGTH_128 = 128
   ,QUEUE_LENGTH_256 = 256
};

typedef void  (*INITPROC)();
typedef void  (*RECVPROC)(uint16_t, void *, uint32_t);
typedef void  (*TIMEOUTPROC)();
typedef void  (*LOOPPROC)();
typedef void* (*GETPARAMPROC)();
typedef void  (*TIMERPROC)();

typedef struct
{
    uint8_t         task_id;
    uint16_t        stack_depth;
    uint32_t        priority;
    const char *    name;
    GETPARAMPROC   	get_param;
} OS_TaskConfig;

typedef struct
{
    uint8_t         queue_id;
    uint32_t        wait_time;
    INITPROC        task_init;
    RECVPROC        recv_msg;
    TIMEOUTPROC     time_out;
    LOOPPROC        loop;
} OS_TaskParam;

typedef struct
{
    uint8_t         id;
    uint32_t        length;
} OS_QueueConfig;

#endif
