Robobo
USB_host.h
1 /* ----------------------------------------------------------------------------
2  * SAM Software Package License
3  * ----------------------------------------------------------------------------
4  * Copyright (c) 2011-2012, Atmel Corporation
5  *
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following condition is met:
10  *
11  * - Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the disclaimer below.
13  *
14  * Atmel's name may not be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
20  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  * ----------------------------------------------------------------------------
28  */
29 
30 #ifndef USB_HOST_H_INCLUDED
31 #define USB_HOST_H_INCLUDED
32 
33 #include <stdint.h>
34 
35 #define tokSETUP UOTGHS_HSTPIPCFG_PTOKEN_SETUP
36 #define tokIN UOTGHS_HSTPIPCFG_PTOKEN_IN
37 #define tokOUT UOTGHS_HSTPIPCFG_PTOKEN_OUT
38 #define tokINHS UOTGHS_HSTPIPCFG_PTOKEN_IN
39 #define tokOUTHS UOTGHS_HSTPIPCFG_PTOKEN_OUT
40 
42 /*typedef enum {
43  UHD_SPEED_LOW = 0,
44  UHD_SPEED_FULL = 1,
45  UHD_SPEED_HIGH = 2,
46 } uhd_speed_t;*/
47 
49 typedef enum {
50  UHD_STATE_NO_VBUS = 0,
51  UHD_STATE_DISCONNECTED = 1,
52  UHD_STATE_CONNECTED = 2,
53  UHD_STATE_ERROR = 3,
54 } uhd_vbus_state_t;
55 
56 //extern uhd_speed_t uhd_get_speed(void);
57 
58 extern void UHD_SetStack(void (*pf_isr)(void));
59 extern void UHD_Init(void);
60 extern void UHD_BusReset(void);
61 extern uhd_vbus_state_t UHD_GetVBUSState(void);
62 extern uint32_t UHD_Pipe0_Alloc(uint32_t ul_add, uint32_t ul_ep_size);
63 extern uint32_t UHD_Pipe_Alloc(uint32_t ul_dev_addr, uint32_t ul_dev_ep, uint32_t ul_type, uint32_t ul_dir, uint32_t ul_maxsize, uint32_t ul_interval, uint32_t ul_nb_bank);
64 extern void UHD_Pipe_Free(uint32_t ul_pipe);
65 extern uint32_t UHD_Pipe_Read(uint32_t ul_pipe, uint32_t ul_size, uint8_t* data);
66 extern void UHD_Pipe_Write(uint32_t ul_pipe, uint32_t ul_size, uint8_t* data);
67 extern void UHD_Pipe_Send(uint32_t ul_pipe, uint32_t ul_token_type);
68 extern uint32_t UHD_Pipe_Is_Transfer_Complete(uint32_t ul_pipe, uint32_t ul_token_type);
69 
70 #endif /* USB_HOST_H_INCLUDED */