/******************************************************************************
*
*  System Name : ARM USB Host Driver Library
*  File Name   : usb0_hdrv_rza1.h
*  Contents    : Definitions for USB Host Control Driver
*  Version     : 0.00.01
*  Device      : ARM
*  Tool-Chain  : 
*  OS          : 
*
*  Note        : 
*                
*  Copyright (C) 2014 Renesas Electronics Corporation and 
*  Renesas Solutions Corp. All rights reserved.
*
*  History     : Feb.12,2014 Ver.0.00.01
******************************************************************************/
#ifndef __USB0_HDRV_RZA1_H__
#define __USB0_HDRV_RZA1_H__


/*******************************************************************************
Includes   <System Includes> , "Project Includes"
*******************************************************************************/


/*******************************************************************************
Macro definitions
*******************************************************************************/


/*******************************************************************************
Typedef definitions
*******************************************************************************/


/*******************************************************************************
Variable Externs
*******************************************************************************/


/*******************************************************************************
Functions Prototypes
*******************************************************************************/
/* ==== task ==== */
void        usb0_hmgr_task( void );
void        usb0_hcd_task( void );
void        usb0_ele_task( void );

/* ==== hmgr api ==== */
int32_t     usb0_api_hmgr_open( USB_HCD_CONFIG_t *usb_cfg );
void        usb0_api_hmgr_registration( USB_HMGR_REGIST_t *hmgr_regist );
int32_t     usb0_api_hmgr_bus_reset(void);
int32_t     usb0_api_hmgr_suspend_request(void);
int32_t     usb0_api_hmgr_resume_request(void);

/* ==== hcd api ==== */
int32_t     usb0_api_hcd_request( USB_HCD_REQUEST_t *utr_table );
int32_t     usb0_api_hcd_force_end( uint16_t pipe_number );
void        usb0_api_hcd_clear_eptype( USB_HOST_CFG_PIPETBL_t *ptr );
uint16_t    usb0_api_hcd_set_pipe_info( uint16_t device_address, 
                                        USB_HOST_CFG_PIPETBL_t *user_table, uint8_t *Table );
int32_t     usb0_api_hcd_change_endpoint( USB_HOST_CFG_PIPETBL_t *table, uint16_t pipe_number );
int32_t     usb0_api_hcd_request_iso( USB_HCD_REQUEST_ISO_t *request );
int32_t     usb0_api_hcd_request_iso_link( USB_HCD_REQUEST_ISO_t *request );
int32_t     usb0_api_hcd_request_reload( uint16_t device_address,
                                         uint16_t pipe,
                                         uint32_t size,
                                         uint8_t  *buffer );
int32_t    usb0_api_hcd_bulk_transfer( USB_HCD_BULK_TRANSFER_t *utr_table );
int32_t    usb0_api_hcd_iso_transfer( USB_HCD_ISO_TRANSFER_t *utr_table );
int32_t    usb0_api_hcd_int_transfer( USB_HCD_INT_TRANSFER_t *utr_table );
int32_t    usb0_api_hcd_ctrl_transfer( USB_HCD_CTRL_TRANSFER_t *utr_table );
int32_t    usb0_api_hcd_re_transfer( uint16_t device_address,
                                     uint16_t pipe,
                                     uint32_t size,
                                     uint8_t  *buffer );

/* ==== hclass api ==== */
int32_t     usb0_api_class_GetDescriptor( uint16_t device_address, uint16_t type,
                                          uint8_t *buffer, uint16_t size );
int32_t     usb0_api_class_SetConfiguration( uint16_t device_address, uint8_t config );
int32_t     usb0_api_class_ClearFeature( uint16_t device_address, 
                                         uint16_t type, uint16_t endp );
int32_t     usb0_api_class_GetConfiguration( uint16_t device_address, uint8_t *buffer );
int32_t     usb0_api_class_GetInterface( uint16_t device_address, 
                                         uint16_t interface, uint8_t *buffer );
int32_t     usb0_api_class_GetStatus( uint16_t device_address, 
                                      uint16_t type, uint16_t endp, uint8_t *buffer );
int32_t     usb0_api_class_SetFeature( uint16_t device_address, 
                                       uint16_t type, uint16_t CntValue );
int32_t     usb0_api_class_SetInterface( uint16_t device_address, 
                                         uint16_t value, uint16_t interface );
int32_t     usb0_api_class_GetString( uint16_t device_address, 
                                      uint16_t index, uint16_t ecode,
                                      uint8_t *buffer, uint16_t size );
int32_t     usb0_api_class_request( uint16_t device_address, 
                                    uint16_t *ReqTable, uint8_t *buffer );

/* ==== interrupt api ==== */
void        usb0_dma_interrupt_d0fifo(uint32_t int_sense);
void        usb0_dma_interrupt_d1fifo(uint32_t int_sense);
void        usb0_host_interrupt(uint32_t int_sense);

/* ==== hostel api ==== */
int32_t     usb0_api_el_hostele_open( void );
int32_t     usb0_api_el_hostele_close( void );
int32_t     usb0_api_el_testpacket( void );
int32_t     usb0_api_el_hostpacket( void );
int32_t     usb0_api_el_hostpacket_a( void );
int32_t     usb0_api_el_hostchirp( void );
int32_t     usb0_api_el_suspend_resume( void );
int32_t     usb0_api_el_jk_se0_nak( void );
int32_t     usb0_api_el_get_descriptor( void );
int32_t     usb0_api_el_attach( USB_CALLBACK_HCD complete );
int32_t     usb0_api_el_busreset( USB_CALLBACK_HCD complete );
int32_t     usb0_api_el_init_module( USB_CALLBACK_HCD complete );
void        usb0_api_el_test_ctrl( uint16_t command );
void        usb0_api_el_test_signal( uint16_t command );
void        usb0_api_el_single_step( uint16_t command );
void        usb0_api_el_set_detach_mode(uint16_t mode);
void        usb0_api_el_single_step2( uint16_t command );
int32_t     usb0_api_el_enumerate( void  );
int32_t     usb0_api_el_test_suspend( void );
int32_t     usb0_api_el_test_resume( void );
uint16_t    usb0_api_el_get_hmgr_status( void );

/* ==== user defined function ==== */
void        usb0_userdef_set_usbclk( void ) ;
void        usb0_userdef_set_usbacswr1( void ) ;
void        usb0_userdef_start_dma(USB_HOST_DMA_t *dma, uint16_t dfacc);
void        usb0_userdef_start_dma_link(USB_HOST_DMA_t *dma);
uint32_t    usb0_userdef_stop_dma( uint16_t fifo );
void        usb0_userdef_reload_dma(USB_HOST_DMA_t *dma, uint16_t dfacc);
void        usb0_userdef_dma_interrupt_d0fifo_link(uint16_t dir);
void        usb0_userdef_dma_interrupt_d1fifo_link(uint16_t dir);
void        usb0_userdef_wait_1us( uint32_t time );
void        usb0_userdef_wait_xms( uint32_t time );
void        usb0_userdef_wait_100ns( uint32_t time );

/* ==== OS user defined function ==== */
void        usb0_userdef_os_init_id(void);
int32_t     usb0_userdef_os_interrupt_regist( void );

int32_t     usb0_userdef_os_set_signal_tskid(uint16_t fifo, int32_t *task_ofst);
int32_t     usb0_userdef_os_clear_signal_tskid(uint16_t fifo, int32_t task_ofst);
int32_t     usb0_userdef_os_wait_signal(uint16_t fifo, uint32_t timeout);
int32_t     usb0_userdef_os_set_signal(uint16_t fifo);

int32_t     usb0_userdef_os_sta_tsk( uint32_t usbid, int32_t stacd );
int32_t     usb0_userdef_os_ter_tsk( uint32_t usbid );
int32_t     usb0_userdef_os_dly_tsk( uint32_t tm );

int32_t     usb0_userdef_os_create_mbx( uint32_t usbid );
int32_t     usb0_userdef_os_delete_mbx( uint32_t usbid );
int32_t     usb0_userdef_os_prcv_mbx( uint32_t usbid, void **msg );
int32_t     usb0_userdef_os_trcv_mbx( uint32_t usbid, void **msg, uint32_t timeout );
int32_t     usb0_userdef_os_rcv_mbx( uint32_t usbid, void **msg );
int32_t     usb0_userdef_os_snd_mbx( uint32_t usbid, void *msg );
int32_t     usb0_userdef_os_isnd_mbx( uint32_t usbid, void *msg );

int32_t     usb0_userdef_os_create_sem( uint32_t usbid );
int32_t     usb0_userdef_os_wai_sem( uint32_t usbid );
int32_t     usb0_userdef_os_twai_sem( uint32_t usbid, uint32_t timeout );
int32_t     usb0_userdef_os_sig_sem( uint32_t usbid );

int32_t     usb0_userdef_os_create_mpf( uint32_t usbid );
int32_t     usb0_userdef_os_pget_mpf( uint32_t usbid, void **mpf );
int32_t     usb0_userdef_os_ipget_mpf( uint32_t usbid, void **mpf );
int32_t     usb0_userdef_os_rel_mpf( uint32_t usbid, void *mpf );
int32_t     usb0_userdef_os_irel_mpf( uint32_t usbid, void *mpf );

/* ====  hostel user defined fucntion ==== */
void        usb0_userdef_ele_key_wait( uint32_t disp );


#endif /* __USB0_HDRV_RZA1_H__ */

/* End of file */
