1 |
5 |
ultra_embe |
#ifndef __USBF_HW_H__
|
2 |
|
|
#define __USBF_HW_H__
|
3 |
|
|
|
4 |
|
|
//-----------------------------------------------------------------
|
5 |
|
|
// Defines
|
6 |
|
|
//-----------------------------------------------------------------
|
7 |
|
|
#define ENDPOINT_CONTROL 0
|
8 |
|
|
|
9 |
|
|
#ifdef USB_SPEED_HS
|
10 |
|
|
#define EP0_MAX_PACKET_SIZE 64
|
11 |
|
|
#else
|
12 |
|
|
#define EP0_MAX_PACKET_SIZE 8
|
13 |
|
|
#endif
|
14 |
|
|
|
15 |
|
|
#define EP1_MAX_PACKET_SIZE 64
|
16 |
|
|
#define EP2_MAX_PACKET_SIZE 64
|
17 |
|
|
#define EP3_MAX_PACKET_SIZE 64
|
18 |
|
|
|
19 |
|
|
//-----------------------------------------------------------------
|
20 |
|
|
// Types
|
21 |
|
|
//-----------------------------------------------------------------
|
22 |
|
|
typedef void (*FUNC_PTR)(void);
|
23 |
|
|
|
24 |
|
|
//-----------------------------------------------------------------
|
25 |
|
|
// Prototypes
|
26 |
|
|
//-----------------------------------------------------------------
|
27 |
|
|
#ifdef __cplusplus
|
28 |
|
|
extern "C" {
|
29 |
|
|
#endif
|
30 |
|
|
|
31 |
|
|
void usbhw_init(unsigned int base, FUNC_PTR bus_reset, FUNC_PTR on_setup, FUNC_PTR on_out);
|
32 |
|
|
void usbhw_service(void);
|
33 |
|
|
void usbhw_attach(int state);
|
34 |
|
|
int usbhw_is_attached(void);
|
35 |
|
|
int usbhw_is_addressed(void);
|
36 |
|
|
int usbhw_is_configured(void);
|
37 |
|
|
void usbhw_set_configured(int configured);
|
38 |
|
|
void usbhw_set_address(unsigned char addr);
|
39 |
|
|
int usbhw_is_endpoint_stalled(unsigned char endpoint);
|
40 |
|
|
void usbhw_clear_endpoint_stall(unsigned char endpoint);
|
41 |
|
|
void usbhw_set_endpoint_stall(unsigned char endpoint);
|
42 |
|
|
int usbhw_is_rx_ready(unsigned char endpoint);
|
43 |
|
|
int usbhw_get_rx_count(unsigned char endpoint);
|
44 |
|
|
int usbhw_get_rx_data(unsigned char endpoint, unsigned char *data, int max_len);
|
45 |
|
|
unsigned char usbhw_get_rx_byte(unsigned char endpoint);
|
46 |
|
|
void usbhw_clear_rx_ready(unsigned char endpoint);
|
47 |
|
|
int usbhw_has_tx_space(unsigned char endpoint);
|
48 |
|
|
int usbhw_load_tx_buffer(unsigned char endpoint, unsigned char *data, int count);
|
49 |
|
|
void usbhw_write_tx_byte(unsigned char endpoint, unsigned char data);
|
50 |
|
|
void usbhw_start_tx(unsigned char endpoint);
|
51 |
|
|
void usbhw_control_endpoint_stall(void);
|
52 |
|
|
void usbhw_control_endpoint_ack(void);
|
53 |
|
|
unsigned short usbhw_get_frame_number(void);
|
54 |
|
|
|
55 |
|
|
typedef unsigned long t_time;
|
56 |
|
|
t_time usbhw_timer_now(void);
|
57 |
|
|
static long usbhw_timer_diff(t_time a, t_time b) { return (long)(a - b); }
|
58 |
|
|
|
59 |
|
|
#ifdef __cplusplus
|
60 |
|
|
}
|
61 |
|
|
#endif
|
62 |
|
|
|
63 |
|
|
#endif
|