summaryrefslogtreecommitdiff
path: root/tool/mbed/mbed-sdk/libraries/USBHost/USBHost/TARGET_RENESAS/TARGET_RZ_A1H/usb0/inc/usb0_host.h
blob: 70e5c2115154f5db5b9ba474a7f53cbdff4d0f4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*******************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only
* intended for use with Renesas products. No other uses are authorized. This
* software is owned by Renesas Electronics Corporation and is protected under
* all applicable laws, including copyright laws.
* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* Renesas reserves the right, without notice, to make changes to this software
* and to discontinue the availability of this software. By using this software,
* you agree to the additional terms and conditions found by accessing the
* following link:
* http://www.renesas.com/disclaimer
* Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved.
*******************************************************************************/
/*******************************************************************************
* File Name    : usb0_host.h
* $Rev: 1116 $
* $Date:: 2014-07-09 16:29:19 +0900#$
* Description  : RZ/A1H R7S72100 USB Sample Program
*******************************************************************************/
#ifndef USB0_HOST_H
#define USB0_HOST_H

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

/*******************************************************************************
Imported global variables and functions (from other files)
*******************************************************************************/
extern const uint16_t   g_usb0_host_bit_set[];
extern uint32_t         g_usb0_host_data_count[USB_HOST_MAX_PIPE_NO + 1];
extern uint8_t          *g_usb0_host_data_pointer[USB_HOST_MAX_PIPE_NO + 1];

extern uint16_t         g_usb0_host_PipeIgnore[];
extern uint16_t         g_usb0_host_PipeTbl[];
extern uint16_t         g_usb0_host_pipe_status[];
extern uint32_t         g_usb0_host_PipeDataSize[];

extern USB_HOST_DMA_t   g_usb0_host_DmaInfo[];
extern uint16_t         g_usb0_host_DmaPipe[];
extern uint16_t         g_usb0_host_DmaBval[];
extern uint16_t         g_usb0_host_DmaStatus[];

extern uint16_t         g_usb0_host_driver_state;
extern uint16_t         g_usb0_host_ConfigNum;
extern uint16_t         g_usb0_host_CmdStage;
extern uint16_t         g_usb0_host_bchg_flag;
extern uint16_t         g_usb0_host_detach_flag;
extern uint16_t         g_usb0_host_attach_flag;

extern uint16_t         g_usb0_host_UsbAddress;
extern uint16_t         g_usb0_host_setUsbAddress;
extern uint16_t         g_usb0_host_default_max_packet[USB_HOST_MAX_DEVICE + 1];
extern uint16_t         g_usb0_host_UsbDeviceSpeed;
extern uint16_t         g_usb0_host_SupportUsbDeviceSpeed;

extern uint16_t         g_usb0_host_SavReq;
extern uint16_t         g_usb0_host_SavVal;
extern uint16_t         g_usb0_host_SavIndx;
extern uint16_t         g_usb0_host_SavLen;

extern uint16_t  g_usb0_host_pipecfg[USB_HOST_MAX_PIPE_NO + 1];
extern uint16_t  g_usb0_host_pipebuf[USB_HOST_MAX_PIPE_NO + 1];
extern uint16_t  g_usb0_host_pipemaxp[USB_HOST_MAX_PIPE_NO + 1];
extern uint16_t  g_usb0_host_pipeperi[USB_HOST_MAX_PIPE_NO + 1];

/*******************************************************************************
Functions Prototypes
*******************************************************************************/
/* ==== common ==== */
void        usb0_host_dma_stop_d0(uint16_t pipe, uint32_t remain);
void        usb0_host_dma_stop_d1(uint16_t pipe, uint32_t remain);
uint16_t    usb0_host_is_hispeed(void);
uint16_t    usb0_host_is_hispeed_enable(void);
uint16_t    usb0_host_start_send_transfer(uint16_t pipe, uint32_t size, uint8_t *data);
uint16_t    usb0_host_write_buffer(uint16_t pipe);
uint16_t    usb0_host_write_buffer_c(uint16_t pipe);
uint16_t    usb0_host_write_buffer_d0(uint16_t pipe);
uint16_t    usb0_host_write_buffer_d1(uint16_t pipe);
void        usb0_host_start_receive_transfer(uint16_t pipe, uint32_t size, uint8_t *data);
uint16_t    usb0_host_read_buffer(uint16_t pipe);
uint16_t    usb0_host_read_buffer_c(uint16_t pipe);
uint16_t    usb0_host_read_buffer_d0(uint16_t pipe);
uint16_t    usb0_host_read_buffer_d1(uint16_t pipe);
uint16_t    usb0_host_change_fifo_port(uint16_t pipe, uint16_t fifosel, uint16_t isel, uint16_t mbw);
void        usb0_host_set_curpipe(uint16_t pipe, uint16_t fifosel, uint16_t isel, uint16_t mbw);
void        usb0_host_set_curpipe2(uint16_t pipe, uint16_t fifosel, uint16_t isel, uint16_t mbw, uint16_t dfacc);
uint16_t    usb0_host_get_mbw(uint32_t trncount, uint32_t dtptr);
uint16_t    usb0_host_read_dma(uint16_t pipe);
void        usb0_host_stop_transfer(uint16_t pipe);
void        usb0_host_brdy_int(uint16_t status, uint16_t int_enb);
void        usb0_host_nrdy_int(uint16_t status, uint16_t int_enb);
void        usb0_host_bemp_int(uint16_t status, uint16_t int_enb);
void        usb0_host_setting_interrupt(uint8_t level);
void        usb0_host_reset_module(uint16_t clockmode);
uint16_t    usb0_host_get_buf_size(uint16_t pipe);
uint16_t    usb0_host_get_mxps(uint16_t pipe);
void        usb0_host_enable_brdy_int(uint16_t pipe);
void        usb0_host_disable_brdy_int(uint16_t pipe);
void        usb0_host_clear_brdy_sts(uint16_t pipe);
void        usb0_host_enable_bemp_int(uint16_t pipe);
void        usb0_host_disable_bemp_int(uint16_t pipe);
void        usb0_host_clear_bemp_sts(uint16_t pipe);
void        usb0_host_enable_nrdy_int(uint16_t pipe);
void        usb0_host_disable_nrdy_int(uint16_t pipe);
void        usb0_host_clear_nrdy_sts(uint16_t pipe);
void        usb0_host_set_pid_buf(uint16_t pipe);
void        usb0_host_set_pid_nak(uint16_t pipe);
void        usb0_host_set_pid_stall(uint16_t pipe);
void        usb0_host_clear_pid_stall(uint16_t pipe);
uint16_t    usb0_host_get_pid(uint16_t pipe);
void        usb0_host_set_sqclr(uint16_t pipe);
void        usb0_host_set_sqset(uint16_t pipe);
void        usb0_host_set_csclr(uint16_t pipe);
void        usb0_host_aclrm(uint16_t pipe);
void        usb0_host_set_aclrm(uint16_t pipe);
void        usb0_host_clr_aclrm(uint16_t pipe);
uint16_t    usb0_host_get_sqmon(uint16_t pipe);
uint16_t    usb0_host_get_inbuf(uint16_t pipe);

/* ==== host ==== */
void        usb0_host_init_pipe_status(void);
int32_t     usb0_host_CtrlTransStart(uint16_t devadr, uint16_t Req, uint16_t Val, uint16_t Indx, uint16_t Len, uint8_t *Buf);
void        usb0_host_SetupStage(uint16_t Req, uint16_t Val, uint16_t Indx, uint16_t Len);
void        usb0_host_CtrlReadStart(uint32_t Bsize, uint8_t *Table);
uint16_t    usb0_host_CtrlWriteStart(uint32_t Bsize, uint8_t *Table);
void        usb0_host_StatusStage(void);
void        usb0_host_get_devadd(uint16_t addr, uint16_t *devadd);
void        usb0_host_set_devadd(uint16_t addr, uint16_t *devadd);
void        usb0_host_InitModule(void);
uint16_t    usb0_host_CheckAttach(void);
void        usb0_host_UsbDetach(void);
void        usb0_host_UsbDetach2(void);
void        usb0_host_UsbAttach(void);
uint16_t    usb0_host_UsbBusReset(void);
int32_t     usb0_host_UsbResume(void);
int32_t     usb0_host_UsbSuspend(void);
void        usb0_host_Enable_DetachINT(void);
void        usb0_host_Disable_DetachINT(void);
void        usb0_host_UsbStateManager(void);


#endif /* USB0_HOST_H */

/* End of File */