#ifndef _API_USB_H
#define _API_USB_H

enum {
    USBCHK_ONLY_HOST,
    USBCHK_ONLY_DEVICE,
    USBCHK_OTG,
};

enum {
    USB_DISCONNECT,
    USB_UDISK_CONNECTED,
    USB_PC_CONNECTED,
};

void usb_init(void);
void usb_disable(void);
u8 usbchk_connect(u8 mode);
void udisk_remove(void);
void udisk_insert(void);
void udisk_invalid(void);

void udisk_suspend(void);
void udisk_resume(void);

void usb_device_enter(u8 enum_type);
void usb_device_exit(void);
void ude_tmr_isr(void);
void pc_remove(void);
bool usb_device_hid_send(u16 hid_val);

/**
  * @brief  send data to USB host in bulk mode.
  * @param  buf: data that need to send.
  * @param  len: lenght of data that need to send.
  * @param  timeout: max time of waiting for sending completion.
  * @retval the result of transmission, it will return false when
            timeout or error.
  */
bool usb_bulk_send(u8 *buf, uint len, u32 timeout);

/**
  * @brief  Config bulk transfer endpoint.
  * @param  out_ep: bulk out endpoint.
  *         this parameter can be one of the following values:
  *             @arg EP_NUM_1: endpoint 1.
  *             @arg EP_NUM_2: endpoint 2.
  *             @arg EP_NUM_3: endpoint 3.
  * @param  in_ep: bulk in endpoint.
  *         The optional value of this parameter is the same as the optional value
  *         of parameter "out_ep".
  * @retval None
  */
void usb_ep_config(u8 out_ep, u8 in_ep);

/**
  * @brief  Configure the descriptor of USB slave mode.
  * @param  desc_str: Structure pointer containing descriptor
  *         information. You should provide a "ude_desc_str_t"
  *         struct to this function when you called it. The
  *         info of the struct see file usb_desc.h
  * @retval None
  */
void ude_desc_config(void *desc_str);

/**
  * @brief  send the ack signal to host, notify the host
  *         that can receive new data.
  * @param  void
  * @retval None
  */
void ude_rx_ack(void);

/**
  * @brief  The usb bulk tx interrupt callback function. When
  *         one transmit is finish, the function will be call.
  *         you can rewrite this function to run something you want.
  * @param  void
  * @retval None
  */
void bulk_tx_handler(void);

/**
  * @brief  The usb bulk rx interrupt callback function. When
  *         USB receive one unit data, this function will be call.
  *         you can rewrite this function to process the data.
  * @param  buf: receive data.
  * @param  len: the length of receive data.
  * @retval None
  */
void bulk_rx_handler(u8 *buf, u8 len);


























/*!**************************************************************************************************
\brief          Bulk_EP_Tx
\param[in]      *buf:	Tx Buf Pointer
\param[in]      len:	Tx Buf len(can't be 0)
\param[in]      expire_val: Bulk EP send expire time,unit is "ms"/ Set "0" is not use expire function
\return         true:send data success
****************************************************************************************************/
bool ude_bulk_ep1_tx(u8 *buf, uint len, u32 expire_val);
#endif // _API_USB_H
