/******************************************************************************
*
*  System Name : ARM USB HUB Class Library
*  File Name   : usb_hub_rza1.h
*  Contents    : Definitions for USB Hub Library
*  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 __USB_HUB_RZA1_H__
#define __USB_HUB_RZA1_H__


/*******************************************************************************
Includes   <System Includes> , "Project Includes"
*******************************************************************************/
#include "usb_hdrv_rza1.h"


/*******************************************************************************
Macro definitions
*******************************************************************************/
#define        USB_HUB_SUCCESS                  USB_SUCCESS
#define        USB_HUB_ERROR                    USB_ERROR
#define        USB_HUB_STALL                    USB_STALL
#define        USB_HUB_TIMEOUT                  USB_TIMEOUT
#define        USB_HUB_NAK_TIMEOUT              USB_NAK_TIMEOUT
#define        USB_HUB_DETACH_ERR               USB_DETACH_ERR
#define        USB_HUB_ENUMERATION_RETRY_ERR    USB_ENUMERATION_RETRY_ERR

#define        USB_HUB_PORT_POWER_OFF           0
#define        USB_HUB_PORT_POWER_ON            1

#define        USB_HUB_PROCESS_SUCCESS          USB_PROCESS_SUCCESS
#define        USB_HUB_PROCESS_ERROR            USB_PROCESS_ERROR

#define        USB_HUB_INFO_HUB_POWER_LOST      0
#define        USB_HUB_INFO_HUB_OVER_CURRENT    1
#define        USB_HUB_INFO_PORT_OVER_CURRENT   2
#define        USB_HUB_INFO_PORT_ERROR          3
#define        USB_HUB_INFO_HUB_INTERRUPT       4

#define        USB_HUB_OPEN_POLLING_PERIOD          10
#define        USB_HUB_OPEN_TIMEOUT                 6000

#define        USB_HUB_CLOSE_POLLING_PERIOD         10
#define        USB_HUB_CLOSE_TIMEOUT                6000

#define        USB_HUB_RESUME_POLLING_PERIOD        10
#define        USB_HUB_RESUME_TIMEOUT               6000

#define        USB_HUB_PORT_RESET_DELAY_0           20
#define        USB_HUB_PORT_RESET_DELAY_1           50
#define        USB_HUB_PORT_RESET_POLLING_PERIOD    10
#define        USB_HUB_PORT_RESET_TIMEOUT           6000


/*******************************************************************************
Typedef definitions
*******************************************************************************/
#define        USB_CALLBACK_HUB                 USB_CALLBACK_HMGR

typedef struct
{
    uint32_t    control_timeout;
    uint32_t    enu_retry;
    uint32_t    bus_reset_wait_time;
    uint16_t    detect_time;
} USB_HUB_CONFIG_t;

typedef struct
{
    USB_CALLBACK_HUB    device_powered_proc;
    USB_CALLBACK_HUB    device_default_proc;
    USB_CALLBACK_HUB    device_address_proc;
    USB_CALLBACK_HUB    device_config_proc;
    USB_CALLBACK_HUB    device_detach_proc;
    USB_CALLBACK_HUB    device_attach_proc;
    USB_CALLBACK_HUB    device_suspend_proc;
    USB_CALLBACK_HUB    device_resume_proc;
    USB_CALLBACK_HUB    device_error_proc;
} USB_HUB_REGIST_t;

typedef struct
{
    uint16_t    hub_address;
    uint16_t    port;
    uint16_t    info;
} USB_HUB_ERROR_INFO_t;

typedef struct
{
    uint16_t    hub_address;
    uint16_t    port_num;
    uint16_t    pw_switch;
    uint16_t    compound;
    uint16_t    protect;
    uint16_t    think;
    uint16_t    indicators;
    uint16_t    pw_wait;
    uint16_t    over_current;
    uint16_t    local_power;
} USB_HUB_HUB_INFO_t;

typedef struct
{
    uint16_t    hub_address;
    uint16_t    port;
    uint16_t    port_power;
    uint16_t    port_connection;
    uint16_t    port_speed;
    uint16_t    port_enable;
    uint16_t    port_suspend;
    uint16_t    port_over_current;
    uint16_t    port_indicator;
    uint16_t    port_test;
} USB_HUB_PORT_INFO_t;

typedef struct
{
    uint32_t    msg_header;
    uint16_t    msg_info;
    uint16_t    hub_address;
    uint16_t    device_address;
    int32_t     result;
} USB_HUB_MESSAGE_t;


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


/*******************************************************************************
Functions Prototypes
*******************************************************************************/


#include "usb0_hub_rza1.h"


#endif /* __USB_HUB_RZA1_H__ */

/* End of file */
