📄 3100_2interface.lst
字号:
1257 01257 0290 32A3 goto HidSetRequestTaskSend
1258
01259 HidSetIdle:
1260 01260 0291 081B movfw WValueHi
1261 01261 0292 00AC movwf IdlePeriodStatus
1262 01262 0293 00B0 movwf IdlePeriodTemp
1263 01263 0294 32A3 goto HidSetRequestTaskSend
1264
01265 HidSetReport:
1266 01266 0295 08A8 testz ConfigurationStatus ;ConfigurationStatus = UnConfig ?
1267 01267 0296 1483 btfsc 03h,2
1268 01268 0297 32A5 goto HidSetRequestTaskError
1269
01270 CheckInterface2:
1271 01271 0298 1901 movlw Interface2
1272 01272 0299 021C subwf WIndex,W
1273 01273 029A 1683 btfss 03h,2
1274 01274 029B 329E goto CheckInterface1
1275 01275 029C 138F bsf 0fh,6
1276 01276 029D 32A3 goto HidSetRequestTaskSend
1277
01278 CheckInterface1:
1279 01279 029E 1900 movlw Interface1
1280 01280 029F 021C subwf WIndex,W
1281 01281 02A0 1683 btfss 03h,2
1282 01282 02A1 32A5 goto HidSetRequestTaskError
1283 01283 02A2 134F bsf 0fh,5
1284
01285 HidSetRequestTaskSend:
1286 01286 02A3 21D1 call NoDataControl
1287 01287 02A4 0040 ret
1288
01289 HidSetRequestTaskError:
1290 01290 02A5 1355 bsf 15h,5
1291 01291 02A6 0040 ret
1292
01293 ;==============================================================================
01294 ;Function:SetAddressTask(00,05)
01295 ; Set the device address to the wValue in the SETUP packet at
01296 ; the completion of the current transaction.
01297 ;==============================================================================
1298
01299 SetAddressTask:
1300 01300 02A7 13CE bsf 0eh,7
1301 01301 02A8 21D1 call NoDataControl
1302 01302 02A9 0040 ret
1303
01304 ;==============================================================================
01305 ;Function:SetConfigurationTask(00,09)
01306 ; Set the configuration of the device to either unconfigured (0) or
01307 ; configured (1) based on wValue in the SETUP packet. According to
01308 ; the USB spec (page 178), a Set Configuration also clears the endpoint
01309 ; stall condition and re-initializes endpoints using data 0/1 toggle to
01310 ; Data0.
01311 ;==============================================================================
1312
01313 SetConfigurationTask:
1314 01314 02AA 0898 testz BmRequestType ;BmRequestType = HostToDevice ?
1315 01315 02AB 1683 btfss 03h,2
1316 01316 02AC 32C4 goto SetConfigurationTaskError
1317
01318 SetConfigurationType:
1319 01319 02AD 089A testz WValue ;WValue = Config ?
1320 01320 02AE 1683 btfss 03h,2
1321 01321 02AF 32B8 goto ConfigType
1322
01323 UnConfigType:
1324 01324 02B0 081A movfw WValue
1325 01325 02B1 00A8 movwf ConfigurationStatus
1326
1327 01327 02B2 19CC movlw cch
1328 01328 02B3 0011 movwr IntEn0
1329
1330 01330 02B4 1153 bcf 13h,5
1331 01331 02B5 1113 bcf 13h,4
1332
1333 01333 02B6 21D1 call NoDataControl
1334 01334 02B7 0040 ret
1335
01336 ConfigType:
1337 01337 02B8 081A movfw WValue
1338 01338 02B9 00A8 movwf ConfigurationStatus
1339
1340 01340 02BA 197D movlw DefaultIdlePeriod
1341 01341 02BB 00AC movwf IdlePeriodStatus
1342 01342 02BC 00B0 movwf IdlePeriodTemp
1343
1344 01344 02BD 19EC movlw ech ;Only enable EP1
1345 01345 02BE 0011 movwr IntEn0
1346
1347 01347 02BF 1353 bsf 13h,5
01348 ; bsf Ep2Cfg
1349
1350 01350 02C0 1396 bsf 16h,6
01351 ; bsf Tx2Tgl
1352
1353 01353 02C1 120E bsf 0eh,0
1354
1355 01355 02C2 21D1 call NoDataControl
1356 01356 02C3 0040 ret
1357
01358 SetConfigurationTaskError:
1359 01359 02C4 1355 bsf 15h,5
1360 01360 02C5 0040 ret
1361
01362 ;==============================================================================
01363 ;Function:GetDescriptorTask(80,06)(81,06)(82,06)
01364 ; There are five descriptor types. The descriptor type will be in
01365 ; the high byte of wValue. The descriptor index will be in the low
01366 ; byte of wValue. The standard request to a device supports three
01367 ; of these types: device, configuration, and string. The standard
01368 ; request does not support interface or endpoint descriptor types.
01369 ; But keyboard is a HID device, so we have to support HID class and
01370 ; HID report two types.
01371 ;==============================================================================
1372
01373 GetDescriptorTask:
1374 01374 02C6 1980 movlw DeviceToHost
1375 01375 02C7 0218 subwf BmRequestType,W
1376 01376 02C8 1483 btfsc 03h,2
1377 01377 02C9 32D2 goto GetDescriptorType
1378
1379 01379 02CA 1981 movlw InterfaceToHost
1380 01380 02CB 0218 subwf BmRequestType,W
1381 01381 02CC 1483 btfsc 03h,2
1382 01382 02CD 32D2 goto GetDescriptorType
1383
1384 01384 02CE 1982 movlw EndpointToHost
1385 01385 02CF 0218 subwf BmRequestType,W
1386 01386 02D0 1683 btfss 03h,2
1387
1388 01388 02D1 331E goto GetDescriptorTaskError
1389
01390 GetDescriptorType:
1391 01391 02D2 1901 movlw Device
1392 01392 02D3 021B subwf WValueHi,W
1393 01393 02D4 1483 btfsc 03h,2
1394 01394 02D5 32E7 goto DeviceType
1395
1396 01396 02D6 1902 movlw Configuration
1397 01397 02D7 021B subwf WValueHi,W
1398 01398 02D8 1483 btfsc 03h,2
1399 01399 02D9 32EB goto ConfigurationType
1400
1401 01401 02DA 1903 movlw String
1402 01402 02DB 021B subwf WValueHi,W
1403 01403 02DC 1483 btfsc 03h,2
1404 01404 02DD 32F0 goto StringType
1405
1406 01406 02DE 1921 movlw HidClass
1407 01407 02DF 021B subwf WValueHi,W
1408 01408 02E0 1483 btfsc 03h,2
1409 01409 02E1 3303 goto HidClassType
1410
1411 01411 02E2 1922 movlw HidReport
1412 01412 02E3 021B subwf WValueHi,W
1413 01413 02E4 1483 btfsc 03h,2
1414 01414 02E5 3308 goto HidReportType
1415
1416 01416 02E6 331E goto GetDescriptorTaskError
1417
01418 DeviceType:
1419 01419 02E7 01A5 clrf TableCnt
1420 01420 02E8 1912 movlw DeviceLen
1421 01421 02E9 00A6 movwf DataLength
1422 01422 02EA 331B goto GetDescriptorTaskSend
1423
01424 ConfigurationType:
1425 01425 02EB 1912 movlw (ConfigDescTable-DeviceDescTable)
1426 01426 02EC 00A5 movwf TableCnt
1427 01427 02ED 193B movlw (String0Table-ConfigDescTable)
1428 01428 02EE 00A6 movwf DataLength
1429 01429 02EF 331B goto GetDescriptorTaskSend
1430
01431 StringType:
1432 01432 02F0 1900 movlw String0
1433 01433 02F1 021A subwf WValue,W
1434 01434 02F2 1483 btfsc 03h,2
1435 01435 02F3 32F9 goto SendString0
1436 01436 02F4 1902 movlw String2
1437 01437 02F5 021A subwf WValue,W
1438 01438 02F6 1483 btfsc 03h,2
1439 01439 02F7 32FE goto SendString2
1440 01440 02F8 331E goto GetDescriptorTaskError
1441
01442 SendString0:
1443 01443 02F9 194D movlw (String0Table-DeviceDescTable)
1444 01444 02FA 00A5 movwf TableCnt
1445 01445 02FB 1904 movlw String0Len
1446 01446 02FC 00A6 movwf DataLength
1447 01447 02FD 331B goto GetDescriptorTaskSend
1448
01449 SendString2:
1450 01450 02FE 1951 movlw (String2Table-DeviceDescTable)
1451 01451 02FF 00A5 movwf TableCnt
1452 01452 0300 1930 movlw (EndDeviceInfoTable-String2Table)
1453 01453 0301 00A6 movwf DataLength
1454 01454 0302 331B goto GetDescriptorTaskSend
1455
01456 HidClassType:
1457 01457 0303 1924 movlw (Class1DescTable-DeviceDescTable)
1458 01458 0304 00A5 movwf TableCnt
1459 01459 0305 1909 movlw HidClass1Len
1460 01460 0306 00A6 movwf DataLength
1461 01461 0307 331B goto GetDescriptorTaskSend
1462
01463 HidReportType:
1464 01464 0308 1900 movlw Report1
1465 01465 0309 021C subwf WIndex,W
1466 01466 030A 1483 btfsc 03h,2
1467 01467 030B 3311 goto SendReport1
1468 01468 030C 1901 movlw Report2
1469 01469 030D 021C subwf WIndex,W
1470 01470 030E 1483 btfsc 03h,2
1471 01471 030F 3316 goto SendReport2
1472 01472 0310 331E goto GetDescriptorTaskError
1473
01474 SendReport1:
1475 01475 0311 01A5 clrf TableCnt
1476 01476 0312 1929 movlw (Report2DescTable-Report1DescTable)
1477 01477 0313 00A6 movwf DataLength
1478 01478 0314 138E bsf 0eh,6
1479 01479 0315 331B goto GetDescriptorTaskSend
1480
01481 SendReport2:
1482 01482 0316 1929 movlw (Report2DescTable-Report1DescTable)
1483 01483 0317 00A5 movwf TableCnt
1484 01484 0318 1917 movlw (EndDeviceReportTable-Report2DescTable)
1485 01485 0319 00A6 movwf DataLength
1486 01486 031A 138E bsf 0eh,6
1487
01488 GetDescriptorTaskSend:
1489 01489 031B 2152 call CheckLength
1490 01490 031C 215F call Tx0Transfer
1491 01491 031D 0040 ret
1492
01493 GetDescriptorTaskError:
1494 01494 031E 1355 bsf 15h,5
1495 01495 031F 0040 ret
1496
01497 ;==============================================================================
01498 ;Function:GetConfigurationTask(80,08)
01499 ; Return the current device configuration to the host. The possible
01500 ; values are zero (unconfigured) and one (configured).
01501 ;==============================================================================
1502
01503 GetConfigurationTask:
1504 01504 0320 1980 movlw DeviceToHost
1505 01505 0321 0218 subwf BmRequestType,W
1506 01506 0322 1683 btfss 03h,2
1507 01507 0323 332A goto GetConfigurationTaskError
1508
01509 GetConfiguration:
1510 01510 0324 0828 movfw ConfigurationStatus
1511 01511 0325 0018 movwr Tx0Fifo0
1512 01512 0326 19C1 movlw c1h
1513 01513 0327 0095 movwf Tx0Reg
1514 01514 0328 1213 bsf 13h,0
1515 01515 0329 0040 ret
1516
01517 GetConfigurationTaskError:
1518 01518 032A 1355 bsf 15h,5
1519 01519 032B 0040 ret
1520
01521 ;==============================================================================
01522 ;Function:ClearFeatureTask(00,01)(02,01)
01523 ; There are two kinds of situation to be clear:
01524 ; 1.These routines allow the host to disable the ability to request
01525 ; remote wakeup.
01526 ; 2.Clear the endpoint stall feature for the selected endpoint. This
01527 ; should also set the data 0/1 bit to Data0 if endpoint one is selected.
01528 ;==============================================================================
1529
01530 ClearFeatureTask:
1531 01531 032C 1900 movlw HostToDevice
1532 01532 032D 0218 subwf BmRequestType,W
1533 01533 032E 1483 btfsc 03h,2
1534 01534 032F 3345 goto ClearRemoteWakeup
1535
1536 01536 0330 1902 movlw HostToEndpoint
1537 01537 0331 0218 subwf BmRequestType,W
1538 01538 0332 1683 btfss 03h,2
1539 01539 0333 334D goto ClearFeatureTaskError
1540
01541 ClearEndpointStall:
1542 01542 0334 08A8 testz ConfigurationStatus ;ConfigurationStatus = Config ?
1543 01543 0335 1483 btfsc 03h,2
1544 01544 0336 334D goto ClearFeatureTaskError
1545
01546 CheckClrEndpointStall:
1547 01547 0337 1981 movlw Endpoint1
1548 01548 0338 021C subwf WIndex,W
1549 01549 0339 1483 btfsc 03h,2
1550 01550 033A 3342 goto ClrEp1Stall
1551
1552 01552 033B 1982 movlw Endpoint2
1553 01553 033C 021C subwf WIndex,W
1554 01554 033D 1683 btfss 03h,2
1555 01555 033E 334D goto ClearFeatureTaskError
1556
01557 ClrEp2Stall:
1558 01558 033F 01AA clrf Endpoint2Status
1559 01559 0340 1157 bcf 17h,5
1560 01560 0341 334B goto ClearFeatureTaskSend
1561
01562 ClrEp1Stall:
1563 01563 0342 01A9 clrf Endpoint1Status
1564 01564 0343 1156 bcf 16h,5
1565 01565 0344 334B goto ClearFeatureTaskSend
1566
01567 ClearRemoteWakeup:
1568 01568 0345
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -