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