/*******************************************************************************
 *
 *
 * File:        tau_device_datatype.h
 * Description  device datatype
 * Version      V0.1
 * Date         2020-12-04
 * Author       kevin
 *******************************************************************************/

#ifndef _TAU_DEVICE_DATATYPE_H_
#define _TAU_DEVICE_DATATYPE_H_


/*******************************************************************************
* 1.Included files
*******************************************************************************/

#include "stdint.h"
#include "tau_common.h"

/*******************************************************************************
* 2.Global constant and macro definitions using #define
*******************************************************************************/

/*******************************************************************************
* 3.Global structures, unions and enumerations using typedef
*******************************************************************************/
/*! @brief 计算组状态码 */
#define MAKE_STATUS(group, code) ((((group)*100) + (code)))

/*******************************************************************************
* 3.Global structures, unions and enumerations using typedef
*******************************************************************************/
/*! @brief 分组状态值 */
enum _status_groups
{
    STATUS_GROUP_GENERIC    = 0,
    STATUS_GROUP_I2C        = 1,
    STATUS_GROUP_UART       = 2,
    STATUS_GROUP_SPI        = 3,
    kStatusGroup_Timer      = 4,
};

/*! @brief 常用状态码 */
enum _generic_status
{
    STATUS_SUCCESS                     = MAKE_STATUS(STATUS_GROUP_GENERIC, 0),
    STATUS_FAIL                        = MAKE_STATUS(STATUS_GROUP_GENERIC, 1),
    STATUS_READ_ONLY                   = MAKE_STATUS(STATUS_GROUP_GENERIC, 2),
    STATUS_OUT_OF_RANGE                = MAKE_STATUS(STATUS_GROUP_GENERIC, 3),
    STATUS_INVALID_ARGUMENT            = MAKE_STATUS(STATUS_GROUP_GENERIC, 4),
    STATUS_TIME_OUT                    = MAKE_STATUS(STATUS_GROUP_GENERIC, 5),
    STATUS_NO_TRANSFER_IN_PROGRESS     = MAKE_STATUS(STATUS_GROUP_GENERIC, 6),
};

/*!
 * @brief timer状态
 */
typedef enum
{
    TIMER_STATUS_IDLE            = MAKE_STATUS(kStatusGroup_Timer, 0),    /*!< 空闲 */
    TIMER_STATUS_RUNNING         = MAKE_STATUS(kStatusGroup_Timer, 1),    /*!< 运行中 */
    TIMER_STATUS_TIMEOUT         = MAKE_STATUS(kStatusGroup_Timer, 2),    /*!< 超时 */
} timer_status_e;

/*!
 * @brief system触发事件(中断/复位)模式
 */
typedef enum
{
    DETECT_HIGH_LVL = 0,
    DETECT_LOW_LVL,
    DETECT_RISING_EDGE,
    DETECT_FALLING_EDGE
} sys_cfg_trigger_e;

/**
* @brief  GPIO interrupt type
*/
typedef enum
{
    TIMER_NUM0 = 0,
    TIMER_NUM1,
    TIMER_NUM2,
    TIMER_NUM3,
    TIMER_NUM_MAX
} timer_num_e;

/**
* @brief  GPIO interrupt type
*/
typedef enum
{
    GPIO_INT_EXTI_INT0 = 0,
    GPIO_INT_EXTI_INT1,
    GPIO_INT_EXTI_INT2,
    GPIO_INT_EXTI_INT3,
    GPIO_INT_EXTI_INT4,
    GPIO_INT_EXTI_INT5,
    GPIO_INT_EXTI_INT6,
    GPIO_INT_EXTI_INT7,
    GPIO_INT_MAX
} gpio_int_e;

/*! @brief PWMI中断类型 */
typedef enum _pwm_int_type
{
    PWM_INT_HIGH_OVERFLOW = 0,
    PWM_INT_LOW_OVERFLOW,
    PWM_INT_TOTAL_OVERFLOW,
    PWM_INT_HIGH_DONE,
    PWM_INT_LOW_DONE,
    PWM_INT_TOTAL_DONE,
    PWM_INT_MAX
} pwm_int_type_e;

/**
* @brief  I2C chose
*/
typedef enum
{
    I2C_SELECT_0 = 0,    //常用slave
    I2C_SELECT_1,        //常用master
} i2c_select_e;

/*!
 * @brief 传输速度
 * @note
 */
typedef enum _i2c_rate
{
    I2C_RATE_STANDARD = 1, //100kHz
    I2C_RATE_FAST,         //400kHz
    I2C_RATE_HIGH,         //1MHz
} i2c_rate_e;

/*! @brief DMA channel type */
typedef enum
{
    DMA_CH0 = 0,           /*!< SPIM */
    DMA_CH1 = 1,           /*!< IIC0 */
    DMA_CH2 = 2,           /*!< SPIS */
    DMA_CH3 = 3,           /*!< IIC1 */
    DMA_CH4 = 4,           /*!< SPI FLASH */
    DMA_CH5 = 5,           /*!< UART */
} dma_channel_e;


/*! @brief Type used for all status and error return values. */

typedef enum
{
    DISABLE = 0,
    ENABLE = !DISABLE
} function_state_e;
/*!< @brief 用于返回状态和错误 */
typedef int32_t status_t;



/*******************************************************************************
* 4.Global variable extern declarations
*******************************************************************************/

#endif

