📄 subp.lst
字号:
135 4 break;
136 4 case 0x80 :key[8]=0x00;key[9]=0x00;
137 4 break;
138 4 default:break;
139 4 }
140 3
141 3 }
142 2 }
143 1
144 1 //SL811Write(EP1A_Slave_Buf,Audio_Keys); // send bitmap back to host
145 1 SL811BufWrite(EP1A_Slave_Buf,(unsigned char*)key,0x31);
146 1 EP1A_IN_Arm(EP1A_Slave_Buf,0x31,ep1_toggle); // Arm Ep1 and toggle data
147 1 key[2]=0x00;key[3]=key[4]=0;
148 1 key[6]=key[7]=key[8]=key[9]=0x80;
149 1 // }
150 1 // Prev_Audio_Keys = Audio_Keys; // update previous key states
151 1 }
152
153 //*****************************************************************************************
154 // Internet Control Key Scanning Routine
155 //*****************************************************************************************
156 /*void internet_key_scan(void)
157 {
158 return;
159 }
160 */
161 //*****************************************************************************************
162 // EP1 interrupt service routine
163 //*****************************************************************************************
164 void ep1_isr(void)
165 //int ep1_isr(void)
166 {
167 1 SL811Write(IntStatus,EP1_DONE); // clear EP1 interrupt
168 1 if(SL811Read(EP1AStatus) & EP_ACK) // check for ACK bit set
169 1 ep1_toggle = (((SL811Read(EP1AControl)&DATAX)==0) ? 1:0);
170 1 // toggle DATA sequence
171 1 audio_key_scan();
172 1 // return;
173 1 }
174
175 //*****************************************************************************************
176 // EP1's IN Token Arming (using Set A)
177 //*****************************************************************************************
178 void EP1A_IN_Arm( unsigned char buf_adr, unsigned char len, unsigned char seq)
179 {
C51 COMPILER V7.20 SUBP 01/30/2007 16:37:15 PAGE 4
180 1 SL811Write(EP1AAddress,buf_adr); // ep1 address buffer start adress
181 1 SL811Write(EP1AXferLen,len); // max length of transfer allowed
182 1 if(seq)
183 1 SL811Write(EP1AControl,DATA1_IN); // armed to transmit to host, DATA1
184 1 else
185 1 SL811Write(EP1AControl,DATA0_IN); // armed to transmit to host, DATA0
186 1 }
187
188 //*****************************************************************************************
189 // SOF interrupt service routine (act as 1ms timer)
190 //*****************************************************************************************
191 //int sof_isr(void)
192 /*int sof_isr(void)
193 {
194 SL811Write(IntStatus,SOF_DONE); // clear SOF interrupt
195 sof_cnt++; // track msec timing
196
197 if(sof_cnt==TIME_OUT) //5 reset counter on specify
198 { // time out.
199 sof_cnt = 0;
200 timeout = 1; // set timeout flag
201 }
202
203 return;
204 }
205 */
206 //*****************************************************************************************
207 // EP0 interrupt service routine
208 //*****************************************************************************************
209 //int ep0_isr(void)
210 void ep0_isr(void)
211 {
212 1 unsigned char status, byte_rx, len_xfr;
213 1 unsigned char req_type,data_seq;
214 1
215 1 SL811Write(IntStatus,EP0_DONE); // clear EP0 interrupt
216 1 status = SL811Read(EP0AStatus); // get packet status
217 1 byte_rx = SL811Read(EP0AXferLen) - SL811Read(EP0ACounter); // get no. of unsigned chars received
218 1 // for OUT data from host
219 1 //----------------------------------------------------------------------------------------
220 1 // ACK received
221 1 //----------------------------------------------------------------------------------------
222 1 if(status & EP_ACK)
223 1 {
224 2 //----------------------------------------------------------------
225 2 // Set newly assigned USB address
226 2 //----------------------------------------------------------------
227 2 if(Slave_USBaddr)
228 2 { // if new USB address was assigned,
229 3 SL811Write(USBAddress,Slave_USBaddr); // communicate all USB transaction
230 3 Slave_USBaddr = 0; // using this new address.
231 3 }
232 2
233 2 //================================================================
234 2 // SETUP's ACKed
235 2 //================================================================
236 2 //status = SL811Read(EP0AStatus);
237 2 if(status & EP_SETUP)
238 2 {
239 3
240 3 SL811BufRead(EP0A_Slave_Buf, ( unsigned char*)&dReq, byte_rx); // capture SETUP data request
241 3 len_req = WordSwap(dReq.wLength); // len_req = actual requested length
C51 COMPILER V7.20 SUBP 01/30/2007 16:37:15 PAGE 5
242 3 in_buffer_idx = 0; // reset buffer locatio indexing
243 3 IN_NULL = FALSE; // these are for IN-NULL packet
244 3 IN_EXACT = FALSE; // transfer condition
245 3 req_type = (dReq.bmRequest&0x60)>>5; // decode for Std,Class,Vendor type
246 3
247 3 switch (req_type) // Parse bmRequest Type
248 3 {
249 4 //---------------------------------------------------------------------
250 4 // Standard USB Requests
251 4 //---------------------------------------------------------------------
252 4 case STD_REQUEST:
253 4 switch (dReq.bRequest) // Parse bRequest
254 4 {
255 5 case GET_DESCRIPTOR:
256 5 switch (( unsigned char)dReq.wValue) // Parse wValue
257 5 {
258 6 case DEVICE:
259 6 SL811BufWrite(EP0A_Slave_Buf,( unsigned char*)Dev_Descp,DEV_LEN); // load Device Descp
260 6 len_req = (len_req>=DEV_LEN) ? DEV_LEN:len_req; // get exact data length
261 6
262 6 break;
263 6
264 6 case CONFIGURATION:
265 6 SL811BufWrite(EP0A_Slave_Buf,( unsigned char*)Cfg_Descp,CFG_LEN); // load Config Descp
266 6 len_req = (len_req>=CFG_LEN) ? CFG_LEN:len_req; // get exact data length
267 6
268 6 break;
269 6
270 6 case HID_DEV:
271 6 SL811BufWrite(EP0A_Slave_Buf,( unsigned char*)Cfg_Descp+18,HID_LEN);// load HID Class Descp
272 6 len_req = (len_req>=HID_LEN) ? HID_LEN:len_req; // get exact data length
273 6 break;
274 6
275 6 case HID_REPORT:
276 6 SL811BufWrite(EP0A_Slave_Buf,( unsigned char*)Rep_Descp,REP_LEN); // load Report Descp
277 6 len_req = (len_req>=REP_LEN) ? REP_LEN:len_req; // get exact data length
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -