arc.c
4.56 KB
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/*HEADER******************************************************************
**************************************************************************
***
*** Copyright (c) 2001-2002 ARC International.
*** All rights reserved
***
*** This software embodies materials and concepts which are
*** confidential to ARC International and is made
*** available solely pursuant to the terms of a written license
*** agreement with ARC International
***
*** $Workfile:arc.c$
*** $Revision: 1.1 $
*** $Date: 2003/02/17 20:49:00 $
***
*** Description:
*** This file contains the USB functions specific to ARC processor.
***
**************************************************************************
*END*********************************************************************/
#ifdef __USB_OS_MQX__
#include "mqx.h"
#include "bsp.h"
#else
#include "arc.h"
#endif
#ifndef __USB_OS_MQX__
static uint_8 disable_count = 0;
volatile boolean IN_ISR = FALSE;
#endif
/*FUNCTION*-------------------------------------------------------------
*
* Function Name : USB_int_install_isr
* Returned Value : None
* Comments :
* Installs the USB interrupt service routine
*
*END*-----------------------------------------------------------------*/
void USB_int_install_isr
(
/* [IN] vector number */
uint_8 vector_number,
/* [IN] interrupt service routine address */
INTERRUPT_ROUTINE_KEYWORD void (_CODE_PTR_ isr_ptr)(void),
/* [IN] parameter for ISR - unused for standalone version */
pointer handle
)
{ /* Body */
#ifdef __OTG_ARC5__
uint_16_ptr loc_ptr;
uint_32 loc;
loc = (uint_32)isr_ptr;
loc_ptr = (uint_16_ptr)_lr(0x25);
/* Offset into the vector table */
loc_ptr += (4 * vector_number);
*loc_ptr++ = 0x2020; /* Hi word of JL */
*loc_ptr++ = 0x0F80; /* Lo word of JL */
*loc_ptr++ = loc >> 16;
*loc_ptr = (uint_16)loc;
#else
uint_32_ptr loc_ptr = (uint_32_ptr)0;
/* Offset into the vector table */
loc_ptr += (2 * vector_number);
*loc_ptr++ = ARC_JMP_TO_ADDR_INSTRN; /* OpCode for Jump to addr */
*loc_ptr++ = (uint_32)isr_ptr; /* Address of the ISR */
#endif
} /* EndBody */
/*FUNCTION*-------------------------------------------------------------
*
* Function Name : _bsp_get_usb_vector
* Returned Value : interrupt vector number
* Comments :
* Get the vector number for the specified device number
*END*-----------------------------------------------------------------*/
uint_8 _bsp_get_usb_vector
(
uint_8 device_number
)
{ /* Body */
#ifdef __USB_HOST__
if (device_number == 0) {
return BSP_VUSB11_HOST_VECTOR0;
} /* Endif */
#endif
#ifdef __USB_DEVICE__
if (device_number == 0) {
return BSP_VUSB11_DEVICE_VECTOR0;
} /* Endif */
#endif
#ifdef __USB_OTG__
if (device_number == 0) {
return BSP_VUSB11_OTG_VECTOR0;
} /* Endif */
#endif
} /* EndBody */
/*FUNCTION*-------------------------------------------------------------
*
* Function Name : _bsp_get_usb_base
* Returned Value : Address of the VUSB1.1 register base
* Comments :
* Get the USB register base address
*END*-----------------------------------------------------------------*/
pointer _bsp_get_usb_base
(
uint_8 device_number
)
{ /* Body */
#ifdef __USB_HOST__
if (device_number == 0) {
return (pointer)BSP_VUSB11_HOST_BASE_ADDRESS0;
} /* Endif */
#endif
#ifdef __USB_DEVICE__
if (device_number == 0) {
return (pointer)BSP_VUSB11_DEVICE_BASE_ADDRESS0;
} /* Endif */
#endif
#ifdef __USB_OTG__
if (device_number == 0) {
return (pointer)BSP_VUSB11_OTG_BASE_ADDRESS0;
} /* Endif */
#endif
} /* EndBody */
#ifndef __USB_OS_MQX__
void _disable_interrupts
(
void
)
{ /* Body */
if ((!disable_count) && (!IN_ISR)) {
DISABLE_INTERRUPTS();
} /* Endif */
if (!IN_ISR) {
disable_count++;
} /* Endif */
} /* EndBody */
void _enable_interrupts
(
void
)
{ /* Body */
if (!IN_ISR) {
disable_count--;
} /* Endif */
if ((!disable_count) && (!IN_ISR)) {
ENABLE_INTERRUPTS();
} /* Endif */
} /* EndBody */
#endif /* __MQX__ */
/* EOF */