/**
 * \file    drv_gpio_capture.h
 * \brief   Driver GPIO interface capture mode definition
 *
 * \details All GPIO pins are defined as input by default, except UART
 *
 * \par     Copyright (c) 2017 UWE Technologies Corp., Ltd. All Rights Reserved.
 * \author  James
 * \date    2017-04-05
 * \version 
 * 
 * \history 
 *  Date        Note
 *  2017-04-05  Original Creation
 * 
 */
 
#ifndef __DRV_GPIO_CAPTURE_H_
#define __DRV_GPIO_CAPTURE_H_


#include "types.h"
#include "drv_gpio.h"


/** GPIO capture index */
typedef enum DRV_CAPTURE_INDEX_e
{
    DRV_CAPTURE_ID_0,  ///< ID 0
    DRV_CAPTURE_ID_1,  ///< ID 1
    DRV_CAPTURE_ID_MAX
} DRV_CAPTURE_ID_t;

/** GPIO capture mode */
typedef enum DRV_CAPTURE_MODE_e
{
    DRV_CAPTURE_MODE_0,  ///< 0:  Capture the width between rising edges of input signal
    DRV_CAPTURE_MODE_1,  ///< 1:  Capture the width between falling edges of input signal
    DRV_CAPTURE_MODE_2,  ///< 2:  Capture the width from rising edge to falling edge of input signal
    DRV_CAPTURE_MODE_3,  ///< 3:  Capture the width from falling edge to rising edge of input signal
    DRV_CAPTURE_MODE_MAX
} DRV_CAPTURE_MODE_t;


/**
 * Get capture enable GPIO index
 *
 * \param id        Hardware capture index
 * \return          GPIO index, DRV_GPIO_MAX means invalid or without enable
 *
 * \see
 */
u32_t drv_cap_en_gpio_get(DRV_CAPTURE_ID_t id);


/**
 * Get gpio capture enable state function
 *
 * \param id        Hardware capture index
 * \return          1: Enabled, 0: disabled
 *
 * \see
 */
bool_t drv_gpio_cap_en_get(DRV_CAPTURE_ID_t id);

/**
 * Enable/disable gpio capture function
 *
 * \param id        Hardware capture index
 * \param gpio_id   GPIO index
 * \param flg       Enable(1) or disable(0)
 *
 * \see
 */
void drv_gpio_cap_en_set(DRV_CAPTURE_ID_t id, u32_t gpio_id, bool_t flg);

/**
 * Configure gpio capture mode
 *
 * \param id        Hardware capture index
 * \param mode      0:  Capture the width between rising edges of input signal
 *                  1:  Capture the width between falling edges of input signal 
 *                  2:  Capture the width from rising edge to falling edge of input signal 
 *                  3:  Capture the width from falling edge to rising edge of input signal
 *
 * \see
 */
void drv_gpio_cap_mode_set(DRV_CAPTURE_ID_t id, int mode);

/**
 * Get gpio capture mode
 *
 * \param id        Hardware capture index
 * \return          0:  Capture the width between rising edges of input signal
 *                  1:  Capture the width between falling edges of input signal 
 *                  2:  Capture the width from rising edge to falling edge of input signal 
 *                  3:  Capture the width from falling edge to rising edge of input signal
 *
 * \see
 */
int drv_gpio_cap_mode_get(DRV_CAPTURE_ID_t id);

/**
 * Get gpio output function
 *
 * \param id        Hardware capture index
 * \return          Capture counter
 *
 * \see
 */
u32_t drv_gpio_cap_count_get(DRV_CAPTURE_ID_t id);


#endif /* #ifndef __DRV_GPIO_CAPTURE_H_ */

