설명 없음

adb.inc 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. bank0 equ 00h
  2. bank1 equ 80h
  3. bank2 equ 100h
  4. bank3 equ 180h
  5. ; *** BIT ASSIGNMENTS FOR I/O LINES & TRI-STATING
  6. ADBIOPrtATRIS equ TRISB
  7. ADBIOPrtBTRIS equ TRISA
  8. ADBPin equ RA4 ; Port A Pin used for ADB
  9. ADBAltPin equ RB0 ; Port B Pin used for ADB (currently unused)
  10. ADBIOIDH equ RB1 ; Unit ID high bit (SW1)
  11. ADBIOIDL equ RB2 ; Unit ID high bit (SW2)
  12. ADBIOPortB equ PORTA
  13. ADBIOPinB1 equ RA0
  14. ADBIOPinB2 equ RA1
  15. ADBIOPinB3 equ RA2
  16. ADBIOPinB4 equ RA3
  17. ADBIOPortA equ PORTB
  18. ADBIOPinA1 equ RB7
  19. ADBIOPinA2 equ RB6
  20. ADBIOPinA3 equ RB5
  21. ADBIOPinA4 equ RB4
  22. ;*** MISC. CONSTANTS
  23. DefaultAddr equ 07h ; default device address to start with (Assigned by Apple)
  24. DefaultID equ 7Ah ; default ID (Assigned by Apple)
  25. ; Data storage registers
  26. ;*** DATA HANDLER ID MASKS: MASK DATA REGISTER 3b FOR:
  27. SELFTST equ 0FFh ; Self-Test mode
  28. LISTEN1 equ 0h ; unconditional address change
  29. LISTEN2 equ 0FEh ; address change if no collision detected
  30. DEV_ACT equ 0FDh ; address change if device activator is depressed
  31. ;*** BITS USED IN THE UPPER NIBBLE OF REGISTER 3a FOR SPECIAL ADB STATUS BITS
  32. Resrvd3 equ 04h ; reserved (Always 0)
  33. Srq_Bit equ 05h ; determines if Host will accept Service Requests
  34. ExpEvnt equ 06h ; indicates an Exceptional Event should take place
  35. Always0 equ 07h ; always set to 0
  36. ;*** ADB FLAG BITS IN THE "FLAGS1" REGISTER (F1 indicates 1st Flags register)
  37. F1Attn equ 00h ; set to know if 2nd Task taking place during Attn
  38. F1Talk equ 02h ; indicates to Tlt routine this is a Talk Command
  39. F1Stop equ 03h ; set to indicate the Data Stop Bit is being sent
  40. F1Lstn equ 04h ; indicates to Tlt routine this is a Listen Command
  41. F1Rcvd1 equ 06h ; 1st byte of Data Register has been received
  42. F1Cllsn equ 07h ; set to indicate that a collision occurred
  43. ;*** FLAG BITS IN THE "FLAGS2" REGISTER (F2 indicates 2nd Flags register)
  44. F2Srq equ 00h ; indicate that Srq should be issued
  45. F2STest equ 03h ; set to indicate a device Self Test is to be performed
  46. F2SFail equ 04h ; set to indicate that the Device Self-Test Failed
  47. F2DRcvd equ 05h ; set when data is received for 2nd Application Task
  48. ; Timing Definitions for 8 Mhz clock
  49. ; ------------------------------------------------------------------------------
  50. PrSclr1 equ d'4' ; TMR0 period (microseconds) when prescaler is set to 8
  51. PrSclr2 equ d'1' ; TMR0 period (microseconds) when prescaler is set to 2
  52. ATT_MIN equ d'776'/PrSclr1 ; Attn lower limit: 800 - 3% tolerance = 776 usecs
  53. ATT_MAX equ d'824'/PrSclr1 ; Attn upper limit: 800 + 3% tolerance = 824 usecs
  54. TSK2MIN equ d'500'/PrSclr1 ; time given to 2nd Task during Attn Signal
  55. TSK2MAX equ d'900'/PrSclr1 ; time given to 2nd Task after Data Sent/Received
  56. ADBSYNC equ d'72'/PrSclr2 ; Sync with extra tolerance after Attn is detected
  57. BIT_TST equ d'50'/PrSclr2 ; if time is < 50 = 1 bit, & > 50 = 0 bit
  58. MAX_BIT equ d'72'/PrSclr2 ; Maximum time line can be low for a bit
  59. BITCELL equ d'104'/PrSclr2 ; Maximum time for a bit cell = 104 usecs
  60. TLT_MIN equ d'140'/PrSclr2 ; Stop to Start minimum time = 140 usecs
  61. TLT_MAX equ d'250'/PrSclr2 ; Stop to Start maximum time = 260 usecs
  62. TLT_MID equ d'180'/PrSclr2 ; Stop to Start median time = 208 usecs
  63. SRQ_MAX equ d'296'/PrSclr1 ; amount of time to hold for a Service ReQuest
  64. ; NOTE: for RTCC timing of sending bits, some extra time is allowed for
  65. ; instruction cycles between the end of the bit and the start of the next bit
  66. LOW1BIT equ d'22'/PrSclr2 ; low time for a 1 bit
  67. HI_1BIT equ d'50'/PrSclr2 ; hi time for a 1 bit
  68. LOW0BIT equ d'56'/PrSclr2 ; low time for a 0 bit
  69. HI_0BIT equ d'20'/PrSclr2 ; hi time for a 0 bit
  70. ; bits of ReqCommand
  71. cmdReset equ 0
  72. cmdFlush equ 1
  73. cmdListen equ 2
  74. cmdTalk equ 3
  75. cmdReserved equ 4
  76. reqReg0 equ 0
  77. reqReg1 equ 1
  78. reqReg2 equ 2
  79. reqReg3 equ 3
  80. cblock 20h ; bank0
  81. DeviceAddr
  82. Reg0a
  83. Reg0b
  84. Reg1a
  85. Reg1b
  86. Reg2a
  87. Reg2b
  88. Reg3a
  89. Reg3b
  90. ShiftReg
  91. TmpReg1 ; temporary registers where Data is sent from &
  92. TmpReg2 ; received; NOTE: THESE 2 MUST BE IN THIS ORDER
  93. PortTalkBytes:5
  94. RegNum ; holds current ADB Data Reg.# - NOT a RAM address
  95. RAMaddr ; holds RAM address of ADB Data Reg.#
  96. Flags1 ; two Flags registers used by ADB & 2nd
  97. Flags2 ; Application Task
  98. CmdByte ; holds the Command Byte
  99. BitCounter ; counts down when sending or receiving bits
  100. Random ; stores Random Address sent in Talk routine
  101. TimeVar ; used with RTCC for all ADB timing
  102. Tsk2Var ; used with RTCC for timing during 2nd Task
  103. ByteCounter
  104. CommandNibble
  105. CommandCode
  106. ReqAddress
  107. ReqCommand
  108. ReqReg
  109. TmpCtr1 ; being used for debounce in example code
  110. d1 ; used in ADC delay loop
  111. ADCPort ; used in ADC code
  112. PortACfg ; 7:6 = 00, 5:4 = AD Config (always 11 for port A), 3:0 = Port Directions (1 = in)
  113. PortBCfg ; 7:6 = 00, 5:4 = AD Config (always 11 for port A), 3:0 = Port Directions (1 = in)
  114. PortAShadow
  115. PortBShadow
  116. UnitID ; 7:6 = Unit ID
  117. A1Timer
  118. A2Timer
  119. A3Timer
  120. A4Timer
  121. endc
  122. ADBIOPortAShadow equ PortBShadow
  123. ADBIOPortBShadow equ PortAShadow
  124. cblock 70h ; globals
  125. SaveStatus
  126. SaveW
  127. endc