home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 1 / Meeting Pearls Vol 1 (1994).iso / installed_progs / hard / galer / source / src.lha / Source / GALerTest / Port.asm < prev    next >
Encoding:
Assembly Source File  |  1993-11-14  |  20.9 KB  |  979 lines

  1.  
  2. *
  3. * This file is the interface between the software
  4. * and the hardware of GALer. The routines of this file
  5. * control the hardware.
  6. * register parameter, 32 bit integer
  7. *
  8. * assemble: asm Port.asm
  9. *
  10. * assumed scratch registers of the compiler: D0, D1, A0, A1
  11.  
  12.  
  13. GAL16V8        EQU    1        ; type of GAL
  14. GAL20V8        EQU    2
  15. GAL22V10    EQU    3
  16. GAL20RA10    EQU    4
  17.  
  18.  
  19. IC1        EQU    3        ; number of IC
  20. IC3        EQU    0        ; IC1-4       : write only
  21. IC4        EQU    1
  22. IC5        EQU    2
  23. IC6a        EQU    0        ; IC6, IC7: read only
  24. IC6c        EQU    4
  25. IC7        EQU    1
  26.  
  27.  
  28. HW_GALER_1_0    EQU    1        ; Hardware-Version
  29. HW_GALER_1_2    EQU    2
  30. HW_GALER_1_3    EQU    3
  31.  
  32.  
  33. ON        EQU    1        ; for control of the LED
  34. OFF        EQU    0
  35.  
  36. PROG        EQU    1        ; Edit-Mode of GAL
  37. VERIFY        EQU    0
  38.  
  39. LOW        EQU    0        ; level
  40. HIGH        EQU    1
  41.  
  42.  
  43. ciaaprb        EQU    $BFE101
  44. ciaaddrb    EQU    $BFE301
  45. ciabpra        EQU    $BFD000
  46. ciabddra    EQU    $BFD200
  47.  
  48.  
  49.  
  50.     SECTION    code,CODE
  51.  
  52.  
  53.     XDEF    @InitParPort        ; initialize parallel port
  54.     XDEF    @RestoreParPort        ; restore parallel-port
  55.     XDEF    @InitGALer        ; initialize GALer
  56.     XDEF    @WriteByte        ; write byte in shift register
  57.     XDEF    @ReadByte        ; read byte out of shift register
  58.     XDEF    @SetGAL            ; set type of GAL
  59.     XDEF    @VeditOn        ; edit voltage on
  60.     XDEF    @VeditOff        ; disable edit off
  61.     XDEF    @LED            ; control LED
  62.     XDEF    @EnableVcc        ; switch +5V on
  63.     XDEF    @DisableVcc        ; switch +5V off
  64.     XDEF    @EnableVEdit        ; enable edit voltage
  65.     XDEF    @DisableVEdit        ; disable edit voltage
  66.     XDEF    @EnableOutput        ; Ausgangs-Treiber aktivieren
  67.     XDEF    @DisableOutput        ; Ausgangs-Treiber deaktiviern
  68.     XDEF    @SetRow            ; set address at RAG0-RAG5
  69.     XDEF    @SDIn            ; set level of SDIn input
  70.     XDEF    @SDOut            ; get level at SDOut output
  71.     XDEF    @Clock            ; clock impuls at SCLK input
  72.     XDEF    @STRImpuls        ; make STR impuls
  73.     XDEF    @EditMode        ; set bits for edit mode
  74.     XDEF    @ExitEditMode        ; exit edit mode and switch off +5V
  75.     XDEF    @SetPV            ; set PV (VERIFY or PROG)
  76.     XDEF    @SetVolt        ; set voltage for edit mode
  77.     XDEF    @SetPESSAVE        ; set level of PESSAVE pin
  78.     XDEF    @SetERASE        ; set level of ERASE pin
  79.     XDEF    @SetCLR            ; set level of CLR pin
  80.     XDEF    @SetARCH        ; set level of ARCH pin
  81.     XDEF    @SetBE            ; set level of BE pin
  82.     XDEF    @SetANDBE        ; set level of ANDBE pin
  83.  
  84.  
  85.     XDEF    _hw_version
  86.  
  87.     XREF    _GALType
  88.     XREF    _outIC1
  89.     XREF    _outIC3
  90.     XREF    _outIC4
  91.     XREF    _outIC5
  92.  
  93.     XREF    @WaitForTimer
  94.  
  95.     XREF    _LVOForbid
  96.     XREF    _LVOPermit
  97.  
  98.     XREF    _prog_volt
  99.  
  100.  
  101.  
  102. * initzialize parallel port
  103. @InitParPort:
  104.     move.b    ciaaddrb,cia_addrb    ; save direction of CIAs
  105.     move.b    ciabddra,cia_bddra
  106.  
  107.     move.b    #%11111111,ciaaddrb    ; data as output
  108.     and.b    #%11111110,ciabddra    ; use BUSY as input
  109.     rts
  110.  
  111.  
  112. * restore state of parallel port
  113. @RestoreParPort:
  114.     move.b    cia_addrb,ciaaddrb    ; Restore data direction of CIAs
  115.                     ; but don't restore the state of
  116.     move.b    cia_bddra,d0        ; the outputs. Otherwise GALer could
  117.     and.b    #%11111110,ciabddra    ; get a command like Vcc or VEdit on).
  118.     and.b    #%00000001,d0
  119.     or.b    d0,ciabddra
  120.     rts
  121.  
  122.  
  123. * GALer initialisieren: alle Ausgänge von IC1 auf LOW (kein OutputEnable
  124. * für IC3,4,5 aber Register-Inhalt von IC3,4,5 auf LOW stellen)
  125. * Parameter: keine
  126. @InitGALer:
  127.     or.b    #%00001000,ciaaprb    ; PD3=H: Decoder deaktivieren!
  128.     and.b    #%00001000,ciaaprb    ; alle anderen Datenleitungen auf LOW
  129.             ; ACHTUNG!!!: PD3 darf nur auf LOW-Pegel gehen
  130.             ; (Decoder aktiviert werden), wenn durch PD0 und
  131.             ; PD1 das IC, das angesprochen werden soll, bereits
  132.             ; selektiert ist. Ansonsten bekommt ein IC einen Takt-
  133.             ; impuls und beim nächsten Strobe liegen dann die
  134.             ; falschen Daten an.
  135.     move.l    #IC1,d1
  136.     moveq    #0,d0
  137.     bsr    @WriteByte        ; Ausgänge von IC1 auf LOW    
  138.  
  139.     move.l    #IC3,d1
  140.     moveq    #0,d0
  141.     bsr    @WriteByte        ; Ausgänge von IC3 auf LOW    
  142.  
  143.     move.l    #IC4,d1
  144.     moveq    #0,d0
  145.     bsr    @WriteByte        ; Ausgänge von IC4 auf LOW    
  146.  
  147.     move.l    #IC5,d1
  148.     moveq    #0,d0
  149.     bsr    @WriteByte        ; Ausgänge von IC5 auf LOW    
  150.     rts
  151.  
  152.  
  153.  
  154. * SetGAL:
  155. * Setze GAL-Type fest (GAL16V8, GAL20V8, GAL22V10, GAL20RA10)
  156. * Aufruf: SetGAL(type);
  157. *
  158. @SetGAL:
  159.     move.l    d0,_GALType
  160.     rts
  161.  
  162.  
  163.  
  164. * VeditOn:
  165. * schaltet den Sperrwandler an (IC9); siehe auch VeditOff
  166. * Auruf: VeditOn();
  167. @VeditOn:
  168.     move.l    #IC1,d1
  169.     or.l    #%00001,_outIC1        ; Q1 von IC1 auf HIGH => VeditOn
  170.     move.l    _outIC1,d0
  171.     bsr    @WriteByte        ; IC1 setzen
  172.     rts
  173.  
  174.  
  175. * VeditOff:
  176. * schaltet den Sperrwandler aus (IC9); siehe auch VeditOn
  177. * Auruf: VeditOff();
  178. @VeditOff:
  179.     move.l    #IC1,d1
  180.     and.l    #%11111110,_outIC1    ; Q1 von IC1 auf LOW => VeditOff
  181.     move.l    _outIC1,d0
  182.     bsr    @WriteByte        ; IC1 setzen
  183.     rts
  184.  
  185.  
  186. * EnableVEdit:
  187. * schaltet die Edit-Spannung auf Pin 2 oder Pin 4 vom Textool
  188. * (abhänging vom eingestellten GAL-Typ)
  189. * Aufruf: EnableVEdit();
  190. @EnableVEdit:
  191.     moveq    #IC1,d1            ; IC1 einstellen
  192.     cmp.l    #GAL16V8,_GALType    ; 16V8 eingestellt?
  193.     bne.s    1$            ; nein, dann 20V8, 22V10, 20RA10
  194.  
  195.                 ;*** GAL16V8 ***
  196.     moveq    #%00000100,d0        ; Q3 von IC1 auf HIGH
  197.     bra.s    2$
  198.                 ;*** 20V8, 22V10, 20RA10 ***
  199. 1$    moveq    #%00000010,d0        ; Q2 von IC1 auf HIGH
  200.  
  201. 2$    or.l    d0,_outIC1
  202.     move.l    _outIC1,d0
  203.     bsr    @WriteByte
  204.     rts
  205.  
  206.  
  207.  
  208. * DisableVEdit:
  209. * schaltet die Edit-Spannung an Pin 2 oder Pin 4 aus
  210. * (abhänging vom eingestellten GAL-Typ)
  211. * Aufruf: DisableVEdit();
  212. @DisableVEdit:
  213.     moveq    #IC1,d1            ; IC1 einstellen
  214.     cmp.l    #GAL16V8,_GALType    ; 16V8 eingestellt?
  215.     bne.s    1$            ; nein, dann wird 20V8 angenommen!
  216.                 ;*** GAL16V8 ***
  217.     move.l    #%11111011,d0        ; Q3 von IC1 auf LOW
  218.     bra.s    2$
  219.                 ;*** 20V8, 22V10, 20RA10 ***
  220. 1$    move.l    #%11111101,d0        ; Q2 von IC1 auf low
  221.  
  222. 2$    and.l    d0,_outIC1
  223.     move.l    _outIC1,d0
  224.     bsr    @WriteByte
  225.     rts
  226.  
  227.  
  228.  
  229.  
  230. * LED:
  231. * schaltet die LED aus bzw. an
  232. * Aufruf: LED(ON/OFF);
  233. @LED:
  234.     cmp.l    #ON,d0
  235.     bne.s    2$
  236.     or.l    #%01000000,_outIC1
  237.     bra.s    1$
  238. 2$    and.l    #%10111111,_outIC1
  239. 1$    move.l    #IC1,d1
  240.     move.l    _outIC1,d0
  241.     bsr    @WriteByte        ; IC1 setzen
  242.     rts
  243.  
  244.  
  245.  
  246. * EnableVcc:
  247. * schaltet die Spannungsversorgung ein; siehe auch DisableVcc
  248. * bei GAL16V8: Pin22 vom Textool-Sockel
  249. * bei GAL20V8, 20RA10, 22V10: Pin24 vom Textool-Sockel
  250. * Aufruf: EnableVcc();
  251. @EnableVcc:
  252.     movem.l    d0-d7/a0-a6,-(sp)    ; Register retten
  253.     move.l    #300000,d0        ; 300 ms warten
  254.     jsr    @WaitForTimer
  255.     movem.l    (sp)+,d0-d7/a0-a6
  256.  
  257.     move.l    #IC1,d1            ; IC1 selektieren
  258.     cmp.l    #GAL16V8,_GALType    ; 16V8 eingestellt?
  259.     bne.s    1$            ; nein, dann wird 20V8 angenommen!!!
  260.     moveq    #%00011000,d0        ; Q4,5 von IC1 auf HIGH=>+5V an Pin22
  261.     bra.s    2$
  262. 1$    moveq    #%00010000,d0        ; Q5 auf HIGH => +5V an Pin 24    
  263. 2$    or.l    d0,_outIC1
  264.     move.l    _outIC1,d0
  265.     bsr    @WriteByte        ; IC1 setzen
  266.     rts
  267.  
  268.  
  269. * DisableVcc:
  270. * schaltet die Spannungsversorgung aus; siehe auch EnableVcc
  271. * Aufruf: DisableVcc();
  272. @DisableVcc:
  273.     movem.l    d0-d7/a0-a6,-(sp)    ; Register retten
  274.     move.l    #50000,d0        ; sicherheitshalber 50mS warten, bis
  275.     jsr    @WaitForTimer        ; das GAL die letzte Aktion richtig
  276.     movem.l    (sp)+,d0-d7/a0-a6
  277.  
  278.     move.l    #IC1,d1            ; IC1 selektieren
  279.     cmp.l    #GAL16V8,_GALType    ; 16V8 eingestellt?
  280.     bne.s    1$            ; nein, dann wird 20V8 angenommen!!!
  281.     move.l    #%11100111,d0        ; Q4,5 von IC1 auf LOW
  282.     bra.s    2$
  283. 1$    move.l    #%11101111,d0        ; Q5 auf HIGH
  284. 2$    and.l    d0,_outIC1
  285.     move.l    _outIC1,d0
  286.     bsr    @WriteByte        ; IC1 setzen
  287.     rts
  288.  
  289.  
  290.  
  291. * EnableOutput:
  292. * OutputEnable-Eingang (OE) von IC3, IC4, IC5 auf HIGH
  293. * Aufruf: EnableOutput();
  294. @EnableOutput:
  295.     move.l    #IC1,d1
  296.     or.l    #%00100000,_outIC1
  297.     move.l    _outIC1,d0
  298.     bsr    @WriteByte
  299.     rts
  300.  
  301. * DisableOutput:
  302. * OutputEnable-Eingang (OE) von IC3, IC4, IC5 auf LOW
  303. * Aufruf: DisableOutput();
  304. @DisableOutput:
  305.     move.l    #IC1,d1
  306.     and.l    #%11011111,_outIC1
  307.     move.l    _outIC1,d0
  308.     bsr    @WriteByte
  309.     rts
  310.  
  311.  
  312.  
  313. * ReadByte:
  314. * read bit from IC6a, IC6c or byte from IC7
  315. * Call:   byte=ReadByte(source);
  316. *         source: IC6a, IC6b, IC7
  317. * PD3 is already HIGH, so reading is possible
  318. @ReadByte:
  319.     and.b    #%11111100,ciaaprb    ; set PD0 and PD1 LOW
  320.  
  321.     cmp.l    #HW_GALER_1_3,_hw_version
  322.     beq.s    rb_version1_3        ; hardware version 1.3
  323.  
  324. ; *** this is for the hardware versions 1.0, 1.1, 1.2 ***
  325.  
  326.     cmp.l    #IC6a,d0        ; read from IC6a?
  327.     bne.s    rb_IC7            ; no, then IC7
  328.     or.b    #%00000001,ciaaprb    ; PD0 HIGH=>HIGH at Clk of IC7
  329.                     ; set PD0 HIGH =>IC6a is selected
  330.     moveq    #0,d0
  331.     move.b    ciabpra,d0
  332.     not.b    d0            ; invert
  333.     and.b    #%00000001,d0        ; get BUSY bit
  334.     bra    rb_end            ; now we have the state of pin 22
  335. rb_IC7
  336.     moveq    #0,d0            ; PD3 is HIGH=>reading is possible
  337.  
  338.     or.b    #%00000100,ciaaprb    ; set PD2 (Strobe) HIGH => put data
  339.     and.b    #%11111011,ciaaprb    ; from input register into shift register
  340.                     ; then set PD2 LOW again
  341.                     ; PD3 is HIGH => reading is possible
  342.     move.l    d2,-(sp)
  343.     moveq    #7,d2            ; loop counter
  344. rb_l1    rol.b    #1,d0
  345.     move.b    ciabpra,d1        ; get BUSY bit
  346.     and.b    #%00000001,d1        ; AND BUSY bit
  347.     or.b    d1,d0            ; move BUSY bit in D0
  348.     and.b    #%11111100,ciaaprb    ; set PD0 LOW => LOW at Clk of IC7
  349.     or.b    #%00000001,ciaaprb    ; set PD0 HIGH => HIGH at Clk of IC7
  350.                     ; ==> next bit is available
  351.     nop
  352.     nop
  353.     and.b    #%11111100,ciaaprb    ; set PD0 LOW=>IC6b is selected
  354.     dbf    d2,rb_l1        ; read 8 bits
  355.     not.b    d0            ; invert them
  356.     move.l    (sp)+,d2
  357.     bra.s    rb_end
  358.  
  359.  
  360. ; *** this is for hardware version 1.3  ***
  361.  
  362. rb_version1_3:
  363.  
  364.     cmp.l    #IC6a,d0        ; read from IC6a?
  365.     bne.s    rb_c1
  366.                     ; read IC6a
  367.                     ; PD0 and PD1 is LOW=>IC6a is selected
  368.     moveq    #0,d0
  369.     move.b    ciabpra,d0        ; read parallel port
  370.     not.b    d0            ; invert
  371.     and.b    #%00000001,d0        ; get BUSY bit
  372.     bra.s    rb_end            ; now we have the state of pin 22
  373.  
  374.  
  375. rb_c1    cmp.l    #IC6c,d0        ; read from IC6b?
  376.     bne.s    rb_c2            ; no, then IC7
  377.                     ; Read IC6c
  378.  
  379.     or.b    #%00000010,ciaaprb    ; PD0 LOW, PD1 HIGH => IC6c is selected
  380.     moveq    #0,d0
  381.     move.b    ciabpra,d0        ; read parallel port
  382.     not.b    d0            ; invert
  383.     and.b    #%00000001,d0        ; get BUSY bit
  384.     bra.s    rb_end            ; now we have the state of pin 23
  385.  
  386.  
  387. rb_c2                    ; read IC7
  388.     moveq    #0,d0            ; PD3 is HIGH=>reading is possible
  389.  
  390.     or.b    #%00000101,ciaaprb    ; set PD2 (Strobe) HIGH => put data
  391.     and.b    #%11111011,ciaaprb    ; from input register into shift register
  392.                     ; then set PD2 LOW again
  393.                     ; PD3 is HIGH => reading is possible
  394.  
  395.     move.l    d2,-(sp)
  396.     moveq    #7,d2            ; loop counter
  397. rb_l2    rol.b    #1,d0
  398.     move.b    ciabpra,d1        ; get BUSY bit
  399.     and.b    #%00000001,d1        ; AND BUSY bit
  400.     or.b    d1,d0            ; move BUSY bit in D0
  401.     and.b    #%11111100,ciaaprb    ; set PD0 LOW => LOW at Clk of IC7
  402.     or.b    #%00000001,ciaaprb    ; set PD0 HIGH => HIGH at Clk of IC7
  403.                     ; ==> next bit is available
  404.     dbf    d2,rb_l2        ; read 8 bits
  405.     not.b    d0            ; invert them
  406.     move.l    (sp)+,d2
  407.  
  408. rb_end
  409.     rts                ; D0 is result
  410.  
  411.  
  412.  
  413.  
  414. * WriteByte:
  415. * schreibt das Byte "byte" in das IC "IC", wobei IC=IC1, IC3, IC4 oder IC5
  416. * sein kann
  417. * zuerst wird das MSB übertragen!!!
  418. * Aufruf: WriteByte(byte,IC)
  419. @WriteByte:
  420.     movem.l    d2/d3,-(sp)        ; Register retten
  421.                     ; Datenbyte in D0
  422.                     ; IC in D1
  423.                 ; geschriebenes Byte mitprotokolieren
  424.     cmp.l    #IC1,d1
  425.     bne.s    1$
  426.     move.l    d0,_outIC1
  427.     bra.s    cont$
  428. 1$    cmp.l    #IC3,d1
  429.     bne.s    2$
  430.     move.l    d0,_outIC3
  431.     bra.s    cont$
  432. 2$    cmp.l    #IC4,d1
  433.     bne.s    3$
  434.     move.l    d0,_outIC4
  435.     bra.s    cont$
  436. 3$    move.l    d0,_outIC5
  437. cont$
  438.  
  439.     and.b    #%11111100,ciaaprb    ; PD0 und PD1 setzen (IC aus-
  440.     or.b    d1,ciaaprb        ; wählen)
  441.     and.b    #%11110111,ciaaprb    ; Decoder aktivieren
  442.  
  443.     moveq    #7,d3            ; Schleifenzähler
  444.     ror.b    #3,d0            ; MSB nach D4 (Datenleitung)
  445.  
  446. loop$    move.b    d0,d2            ; Datenbyte sichern
  447.     and.b    #%00010000,d2        ; Datenbit ausmaskieren
  448.     or.b    d2,ciaaprb        ; Datenbit (PD4) vom Par.-Port setzen
  449.  
  450.     or.b    #%00001000,ciaaprb    ; Clock-Impuls durch PD3 geben
  451.     and.b    #%11110111,ciaaprb    ; LOW-HIGH Übergang
  452.  
  453.     and.b    #%11101111,ciaaprb    ; Datenbit (PD4) auf LOW
  454.  
  455.     rol.b    #1,d0            ; nächstniedrigeres Bit senden
  456.     dbf    d3,loop$
  457.  
  458.     or.b    #%00001000,ciaaprb    ; Decoder wieder deaktivieren!!!
  459.                     ; (sehr WICHTIG, siehe InitGAL:)
  460.     or.b    #%00000100,ciaaprb    ; PD2 (Strobe) auf HIGH-> Daten werden
  461.     and.b    #%11111011,ciaaprb    ; vom Schieberegister in das Datenreg.
  462.                     ; übernommen. Dann PD2 wieder auf LOW.
  463.     movem.l    (sp)+,d2/d3
  464.     rts
  465.  
  466.  
  467.  
  468.  
  469. * SetRow:
  470. * Adresse an RAG0-RAG5 anlegen
  471. * Aufruf: SetRow(row);
  472. * row:      zu adressierende Zeile (0-63)
  473. @SetRow:
  474.  
  475.     move.l    d0,-(sp)        ; Row (D0) auf Stack
  476.  
  477.     cmp.l    #GAL22V10,_GALType
  478.     beq    setrow22V10
  479.     cmp.l    #GAL20RA10,_GALType
  480.     beq    setrow20RA10
  481.  
  482.             ; ***  GAL16V8 und GAL20V8  ***
  483.                     ; RAG5 setzen (bei 16 und 20V8 gleich)
  484.     and.l    #$fe,_outIC5        ; Bit0(=RAG5) löschen
  485.     asr.b    #5,d0            ; Bit0 von D0=RAG5
  486.     or.l    d0,_outIC5        ; RAG5=Bit von D0=> RAG5 gesetzt
  487.  
  488.     cmp.l    #GAL16V8,_GALType    ; GAL16V8?
  489.     bne.s    setrow20V8        ; nein, dann GAL20V8 annehmen
  490.  
  491.                 ;*** GAL16V8 ***
  492.                     ; RAG0 setzen
  493.     move.l    (sp),d0            ; row holen
  494.     and.l    #$ef,_outIC3        ; Bit4(=RAG0) löschen
  495.     and.l    #1,d0            ; Bit0 von "row" ausmaskieren
  496.     asl.b    #4,d0
  497.     or.l    d0,_outIC3        ; Bit4(=RAG0) setzen
  498.                     ; RAG1-RAG4 setzen
  499.     move.l    (sp),d0            ; row holen
  500.     and.l    #$0f,_outIC4        ; Bit4-7(=RAG1-RAG4) löschen
  501.     and.l    #%00011110,d0        ; Bit1-4 von "row" ausmaskieren
  502.     asl.l    #3,d0            ; an Bit4-7 schieben
  503.     or.l    d0,_outIC4        ; RAG1-RAG4 setzen
  504.     bra.s    write
  505.                 ;*** GAL20V8 ***
  506. setrow20V8                ; RAG0 für GAL20V8 setzen
  507.      move.l    (sp),d0            ; row holen
  508.     and.l    #%11011111,_outIC3    ; Bit5(=RAG0) löschen
  509.     and.l    #1,d0            ; Bit0 von "row" ausmaskieren
  510.     asl.b    #5,d0
  511.     or.l    d0,_outIC3        ; Bit5(=RAG0) setzen
  512.                     ; RAG4 setzen
  513.     move.l    (sp),d0            ; row holen
  514.     and.l    #%01111111,_outIC4    ; Bit7(=RAG4) löschen
  515.     and.l    #%00010000,d0        ; Bit4 von "row" ausmaskieren
  516.     asl.l    #3,d0
  517.     or.l    d0,_outIC4        ; Bit7(=RAG4) setzen
  518.                     ; RAG1-RAG3 setzen
  519.     move.l    (sp),d0            ; row holen
  520.     and.l    #%11100011,_outIC4    ; Bit2-4(=RAG1-RAG3) löschen
  521.     and.l    #%00001110,d0        ; Bit1-3 aus "row" ausmaskieren
  522.     asl.l    #1,d0
  523.     or.l    d0,_outIC4        ; RAG1-RAG3 setzen
  524.  
  525. write                    ; errechnete Werte in ICs schreiben
  526.     move.l    #IC3,d1
  527.     move.l    _outIC3,d0
  528.     bsr    @WriteByte
  529.  
  530.     move.l    #IC4,d1
  531.     move.l    _outIC4,d0
  532.     bsr    @WriteByte
  533.  
  534.     move.l    #IC5,d1
  535.     move.l    _outIC5,d0
  536.     bsr    @WriteByte
  537.  
  538.     bra.s    setrowend
  539.  
  540.  
  541.             ; ***  GAL22V10 und GAL20RA10  ***
  542. setrow22V10            ; bei 22V10 und 20RA10 GALs wird RAG0-5 in
  543. setrow20RA10            ; das interne Schiebereg. des GALs getaktet,
  544.                 ; da diese GALs keine RAG-Pins haben
  545.     moveq    #5,d1            ; D0 = Row
  546. setrow1
  547.     movem.l    d0/d1,-(sp)
  548.     and.l    #%0000001,d0        ; LSB ausmaskieren
  549.     bsr.s    @SDIn            ; RAGx ins Schieberegister des
  550.     bsr.s    @Clock            ; GALs takten
  551.     movem.l    (sp)+,d0/d1
  552.     asr.b    #1,d0
  553.     dbf    d1,setrow1
  554.  
  555. setrowend
  556.     addq.l    #4,sp            ; Stack korrigieren
  557.     rts
  558.  
  559.  
  560.  
  561.  
  562. * SDIn:
  563. * lege ein Bit an den SDIn-Eingang (Pin 11 vom Textool-Sockel)
  564. * Aufruf: SDIn(bit);    bit: 0=LOW; 1=HIGH
  565. @SDIn:
  566.                     ; Bit steht in d0
  567.     asl.b    #2,d0            ; an die richtige Stelle schieben
  568.     and.l    #%11111011,_outIC5    ; SDIn-Bit löschen
  569.     or.l    d0,_outIC5        ; Bit auf LOW oder HIGH setzen
  570.     move.l    #IC5,d1
  571.     move.l    _outIC5,d0
  572.     bsr    @WriteByte
  573.     rts
  574.  
  575.  
  576. * SDOut:
  577. * ein Bit aus dem SDOut-Ausgang lesen
  578. * Pin 14 (GAL16V8, 22V10, 20RA10), Pin 15 (GAL20V8) am Textool-Sockel
  579. * Aufruf: bit=SDOut();
  580. * bit: 0: SDOut-Pin ist LOW; 1: SDOut-Pin ist HIGH
  581. @SDOut:
  582.     move.l    #IC7,d0            ; ein Byte aus IC7 holen
  583.     bsr    @ReadByte        ; Bit0=Pin14, Bit1=Pin15
  584.  
  585.     cmp.l    #GAL20V8,_GALType    ; GAL20V8 eingestellt?
  586.     beq.s    sdout1            ; nein, dann 16V8, 22V10, 20RA10
  587.     and.l    #1,d0            ; Bit0 ausmaskieren
  588.     bra.s    sdoutend        ; D0=Bit
  589.                     ; GAL20V8
  590. sdout1    asr.l    #1,d0            ; SDOut-Bit an Bit-Pos. 0
  591.     and.l    #1,d0
  592. sdoutend                ; 32-Bit-Ergebnis in D0
  593.     rts
  594.  
  595.  
  596.  
  597.  
  598. * Clock:
  599. * erzeuge Clock-Impuls (Low-High-Low-Übergang) am SCLK-Eingang (Pin 10
  600. * vom Textool-Sockel
  601. * Aufruf: Clock();
  602. @Clock:
  603.     or.l    #%00000010,_outIC5    ; SCLK-Bit auf HIGH
  604.     move.l    #IC5,d1
  605.     move.l    _outIC5,d0
  606.     bsr    @WriteByte
  607.  
  608.     and.l    #%11111101,_outIC5    ; SCLK-Bit auf LOW
  609.     move.l    #IC5,d1
  610.     move.l    _outIC5,d0
  611.     bsr    @WriteByte
  612.  
  613.     rts
  614.  
  615.  
  616.  
  617. * STRImpuls:
  618. * setzt /STR-Eingang (Pin 13 am Textool-Socker) für die Dauer von "STRLength"
  619. * auf LOW
  620. * Aufruf: STRImpuls(long STRLength);
  621. * STRLength: Dauer des Low-Impulses in Mikrosekunden (Langwort!)
  622. @STRImpuls:
  623.     movem.l    d0-d7/a0-a6,-(sp)    ; Register retten
  624.  
  625.     move.l    4,a6
  626.     jsr    _LVOForbid(a6)
  627.  
  628.     and.l    #%11110111,_outIC5    ; STR-Pin auf LOW
  629.     move.l    #IC5,d1
  630.     move.l    _outIC5,d0
  631.     bsr    @WriteByte
  632.  
  633.     cmp.l    #100,(sp)        ; bis ein Wert in ein IC getaktet wird
  634.     bls.s    1$            ; vergehen ca. 100us => keinen Timer
  635.     move.l    (sp),d0            ; Dauer des Impulses in Mikrosekunden
  636.     jsr    @WaitForTimer        ; Low-Impuls
  637. 1$
  638.     or.l    #%00001000,_outIC5    ; STR-Pin wieder auf HIGH
  639.     move.l    #IC5,d1
  640.     move.l    _outIC5,d0
  641.     bsr    @WriteByte
  642.  
  643.     jsr    _LVOPermit(a6)
  644.  
  645.     movem.l    (sp)+,d0-d7/a0-a6    ; Registerinhalte zurückholen
  646.     rts
  647.  
  648.  
  649.  
  650. * SetPV:
  651. * Legt am P/V-Pin den entsprechenden Pegel für "Programmieren" bzw.
  652. * "Verify" an.
  653. * Aufruf:  SetPV(mode);
  654. * mode :   VERIFY (lesen, P/V low), PROG (schreiben, P/V high)
  655. @SetPV:
  656.                     ; Mode steht in D0
  657.  
  658.     cmp.l    #GAL16V8,_GALType    ; GAL16V8?
  659.     bne.s    setpv1            ; nein, dann 1
  660.  
  661.                 ;***  GAL16V8  ***
  662.     move.l    _outIC3,d1
  663.     and.l    #%11011111,d1
  664.     asl.b    #5,d0            ; Mode-Bit zu Bit 5 schieben
  665.     or.l    d0,d1
  666.     move.l    d1,d0            ; P/V setzen
  667.     move.l    #IC3,d1            ; IC3 setzen
  668.     bsr    @WriteByte
  669.     bra.s    setpvend
  670.  
  671. setpv1
  672.     cmp.l    #GAL20V8,_GALType
  673.     bne.s    setpv2
  674.                 ;***  GAL20V8  ***
  675.  
  676.     move.l    _outIC3,d1
  677.     and.l    #%10111111,d1
  678.     asl.b    #6,d0            ; Mode-Bit zu Bit 6 schieben
  679.     or.l    d0,d1
  680.     move.l    d1,d0            ; P,/V-Bit setzen
  681.     move.l    #IC3,d1            ; IC3 setzen
  682.     bsr    @WriteByte
  683.     bra.s    setpvend
  684.  
  685. setpv2
  686.                 ;***  22V10, 20RA10  ***
  687.  
  688.     move.l    _outIC4,d1
  689.     and.l    #%11111011,d1
  690.     asl.b    #2,d0
  691.     or.l    d0,d1
  692.     move.l    d1,d0            ; P,/V-Bit setzen
  693.     move.l    #IC4,d1            ; IC4 setzen
  694.     bsr    @WriteByte
  695.  
  696. setpvend
  697.     rts
  698.  
  699.  
  700.  
  701.  
  702.  
  703. * Edit-Mode:
  704. * schaltet das GAL in den Edit-Mode; /STR auf HIGH; P/V auf LOW
  705. * und SDOUT über einen 10kOhm-Widerstand auf VIH
  706. * Aufruf: EditMode(mode);
  707. * mode: PROG oder VERIFY (für Spannungseinstellung)
  708. @EditMode:
  709.     movem.l    d0-d7/a0-a6,-(sp)    ; Register sichern
  710.  
  711.     cmp.l    #GAL16V8,_GALType       ; GAL16V8?
  712.     bne.s    em1            ; nein, dann em1
  713.  
  714.                 ;*** GAL16V8 ***
  715.     moveq    #IC3,d1            ; IC3, P/V auf LOW
  716.     moveq    #%00000000,d0
  717.     bsr    @WriteByte
  718.  
  719.     moveq    #IC4,d1
  720.     moveq    #%00000000,d0        ; IC4 initialisieren
  721.     bsr    @WriteByte
  722.  
  723.     moveq    #IC5,d1            ; /STR auf HIGH
  724.     moveq    #%00011000,d0        ; IC5 initialisieren
  725.     bsr    @WriteByte
  726.     bra.s    em2
  727.  
  728.  
  729. em1    cmp.l    #GAL20V8,_GALType
  730.     bne.s    em5
  731.  
  732.                 ;*** GAL20V8 ***
  733.     moveq    #IC3,d1            ; IC3, P/V auf LOW
  734.     moveq    #%00000000,d0
  735.     bsr    @WriteByte
  736.  
  737.     moveq    #IC4,d1
  738.     moveq    #%00000000,d0        ; IC4 initialisieren
  739.     bsr    @WriteByte
  740.  
  741.     moveq    #IC5,d1            ; /STR auf HIGH
  742.     moveq    #%00101000,d0        ; IC5 initialisieren
  743.     bsr    @WriteByte
  744.     bra.s    em2
  745.  
  746.  
  747. em5
  748.                 ;*** GAL20RA10 ***
  749.                 ;*** GAL22V10  ***
  750.  
  751.     moveq    #IC3,d1            ; IC3, OPs auf VIL
  752.     moveq    #%00000000,d0
  753.     bsr    @WriteByte
  754.  
  755.     moveq    #IC4,d1
  756.     moveq    #%00000000,d0        ; IC4, P/V auf LOW
  757.     bsr    @WriteByte
  758.  
  759.     moveq    #IC5,d1            ; /STR, SDOUT auf HIGH
  760.     moveq    #%00011000,d0        ; IC5 initialisieren
  761.     bsr    @WriteByte
  762.  
  763.  
  764. em2
  765.                     ; richtige Spannung auswählen
  766.     cmp.l    #VERIFY,(sp)        ; Lesen?
  767.     bne.s    em3            ; nein, dann Programmieren!
  768.  
  769.     moveq    #4,d0            ; 12 Volt einstellen
  770.     cmp.l    #GAL22V10,_GALType    ; wenn 22V10, dann 16.5 Volt
  771.     bne.s    em6
  772.     moveq    #0,d0
  773. em6    bsr    @SetVolt
  774.     bra.s    em4
  775.  
  776. em3    move.l    _prog_volt,d0        ; Programmierspannung einstellen
  777.     bsr    @SetVolt
  778.  
  779. em4    bsr    @VeditOn        ; Edit-Spannung aufbauen
  780.  
  781.     move.l    #50000,d0        ; 50 ms warten, bis sich die
  782.     jsr    @WaitForTimer        ; Edit-Spannung aufgebaut hat
  783.  
  784.     bsr    @EnableOutput        ; Bits anlegen
  785.     bsr    @EnableVcc        ; Vcc anlegen
  786.  
  787.     move.l    #100000,d0        ; Prellzeit der Relais überbrücken
  788.     jsr    @WaitForTimer
  789.  
  790.     bsr    @EnableVEdit        ; Edit-Spannung anlegen
  791.                     ; GAL befindet sich jetzt im Edit-Mode
  792.     moveq    #5,d0            ; 5 us warten bevor nächste Aktion
  793.     jsr    @WaitForTimer        ; erlaubt ist
  794.  
  795.     movem.l    (sp)+,d0-d7/a0-a6    ; Registerinhalte zurückholen
  796.     rts
  797.  
  798.  
  799.  
  800. * ExitEditMode:
  801. * Schaltet zuerst VEdit und VCC ab, dann wird der Inhalt der ICs
  802. * zurückgesetzt.
  803. * Aufruf: ExitEditMode();
  804. @ExitEditMode:
  805.     movem.l    d0-d7/a0-a6,-(sp)    ; Register sichern
  806.  
  807.     bsr    @DisableVEdit
  808.  
  809.     bsr    @DisableVcc
  810.  
  811.     bsr    @InitGALer
  812.  
  813.     bsr    @EnableOutput
  814.  
  815.     movem.l    (sp)+,d0-d7/a0-a6
  816.     rts
  817.  
  818.  
  819.  
  820. * SetVolt:
  821. * selektiert durch IC 10 und IC11 die gewünschte Spannung
  822. * Aufruf: SetVolt(value);
  823. * value:  0=16.50 Volt; 1=15.75 Volt; 2=14.5 Volt; 3=14.00 Volt; 4=12.00 Volt
  824. *
  825. @SetVolt:
  826.                     ; Parameter in D0
  827.     move.l    d0,-(sp)        ; Wert sichern
  828.  
  829.     and.l    #%00000001,d0
  830.     rol.l    #7,d0
  831.     and.l    #%01111111,_outIC1
  832.     or.l    d0,_outIC1        ; Q8 (Pin 11) von IC1 setzen
  833.     move.l    _outIC1,d0
  834.     move.l    #IC1,d1
  835.     bsr    @WriteByte
  836.  
  837.     move.l    (sp)+,d0
  838.     and.l    #%00000110,d0
  839.     rol.l    #5,d0
  840.     and.l    #%00111111,_outIC5
  841.     or.l    d0,_outIC5        ; Q7 und Q8 von IC5 setzen
  842.     move.l    _outIC5,d0
  843.     move.l    #IC5,d1
  844.     bsr    @WriteByte
  845.  
  846.     rts
  847.  
  848.  
  849.  
  850.  
  851. ** Die nachfolgenden Routinen sind ausschließlich für 22V10 und/oder 20RA10
  852. ** GALs bestimmt.
  853.  
  854.  
  855.  
  856. * SetPESSAVE:
  857. * setzt den PESSAVE-Pin (Pin 4) von GAL20RA10
  858. * Bemerkung: diese Routine ist auschließlich für 20RA10 GALs bestimmt
  859. * Aufruf: SetPESSAVE(pegel)
  860. * Parameter: pegel = HIGH oder LOW
  861.  
  862. * SetERASE:
  863. * setzt den ERASE-Pin (Pin 4) von GAL22V10
  864. * Bemerkung: diese Routine ist auschließlich für 22V10 GALs bestimmt
  865. * Aufruf: SetERASE(pegel)
  866. * Parameter: pegel = HIGH oder LOW
  867.  
  868. @SetPESSAVE:
  869. @SetERASE:
  870.  
  871.     and.l    #%11110111,_outIC4
  872.     cmp.l    LOW,d0
  873.     beq.s    1$
  874.  
  875.     or.l    #%00001000,_outIC4
  876.  
  877. 1$    move.l    #IC4,d1
  878.     move.l    _outIC4,d0
  879.     bsr    @WriteByte
  880.  
  881.     rts
  882.  
  883.  
  884.  
  885. * SetCLR:
  886. * setzt den CLR-Pin (Pin 6) von GAL22V10 und GAL20RA10
  887. * Aufruf: SetCLR(pegel)
  888. * Parameter: pegel = HIGH oder LOW
  889.  
  890. @SetCLR:
  891.  
  892.     and.l    #%11011111,_outIC4
  893.     cmp.l    LOW,d0
  894.     beq.s    1$
  895.  
  896.     or.l    #%00100000,_outIC4
  897.  
  898. 1$    move.l    #IC4,d1
  899.     move.l    _outIC4,d0
  900.     bsr    @WriteByte
  901.  
  902.     rts
  903.  
  904.  
  905. * SetBE:
  906. * setzt den BE-Pin (Pin 7) von GAL22V10 und GAL20RA10
  907. * Aufruf: SetBE(pegel)
  908. * Parameter: pegel = HIGH oder LOW
  909.  
  910. @SetBE:
  911.  
  912.     and.l    #%10111111,_outIC4
  913.     cmp.l    LOW,d0
  914.     beq.s    1$
  915.  
  916.     or.l    #%01000000,_outIC4
  917.  
  918. 1$    move.l    #IC4,d1
  919.     move.l    _outIC4,d0
  920.     bsr    @WriteByte
  921.  
  922.     rts
  923.  
  924.  
  925.  
  926. * SetARCH:
  927. * setzt den ARCH-Pin (Pin 8) von GAL22V10 und GAL20RA10
  928. * Aufruf: SetARCH(pegel)
  929. * Parameter: pegel = HIGH oder LOW
  930.  
  931. @SetARCH:
  932.  
  933.     and.l    #%01111111,_outIC4
  934.     cmp.l    LOW,d0
  935.     beq.s    1$
  936.  
  937.     or.l    #%10000000,_outIC4
  938.  
  939. 1$    move.l    #IC4,d1
  940.     move.l    _outIC4,d0
  941.     bsr    @WriteByte
  942.  
  943.     rts
  944.  
  945.  
  946. * SetANDBE:
  947. * setzt den ANDBE-Pin (Pin 9) von GAL20RA10
  948. * Bemerkung: diese Routine ist auschließlich für 22V10 GALs bestimmt
  949. * Aufruf: SetCLR(pegel)
  950. * Parameter: pegel = HIGH oder LOW
  951.  
  952. @SetANDBE:
  953.  
  954.     and.l    #%11111110,_outIC5
  955.     cmp.l    LOW,d0
  956.     beq.s    1$
  957.  
  958.     or.l    #%00000001,_outIC5
  959.  
  960. 1$    move.l    #IC5,d1
  961.     move.l    _outIC5,d0
  962.     bsr    @WriteByte
  963.  
  964.     rts
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.     SECTION    data,DATA
  972.  
  973. _hw_version:    dc.l    0
  974.  
  975. cia_addrb:    dc.b    0
  976. cia_bddra:    dc.b    0
  977.  
  978.     END
  979.