4 ; Originally by Bastian Schick
5 ; http://www.geocities.com/SiliconValley/Byte/4242/lynx/
7 ; Ported to cc65 (http://www.cc65.org) by
8 ; Shawn Jefferson, June 2004
11 ; Ullrich von Bassewitz, 1004-10-14
16 ;* for 93C46 (1024bit => 64 16-bit words)
21 ;* 16.02.96 leaner (thanks to Harry)
22 ;* 12.03.96 test for busy after write and erase (well, Harry ;)) )
23 ;* 22.08.97 ported to ra65 for use with cc65
24 ;* 02.12.97 added xref for the new ra65
27 ;* (c) 1995..97 Bastian Schick
32 ;* And now how to contact the EEPROM :
35 ;* PORT ----\/---- 93C46(SMD too)
36 ;* (18) A7 --------| CS |- +5V
37 ;* (11) A1 --------| CLK |- NC
39 ;* (32) AUDIN ----+---| DO |- GND
45 .export _lynx_eeprom_read
46 .export _lynx_eeprom_write
47 .export _lynx_eeprom_erase
54 ; ------------------------------------------------------------------------
64 ; ------------------------------------------------------------------------
65 ; unsigned __fastcall__ lynx_eeprom_read (unsigned char cell);
66 ; /* Read a 16 bit word from the given address */
75 sta IODIR ; set AUDIN to Input
79 stz ptr1+1 ; Clear result
80 ldy #16-1 ; Initialize bit counter
91 adc #$f0 ; C=1 if A=$10
93 rol ptr1+1 ; shifts 0 to Carry
98 stx IODIR ; set AUDIN for output
107 ldy ptr1+1 ; Load result
112 ; ------------------------------------------------------------------------
113 ; unsigned __fastcall__ lynx_eeprom_erase (unsigned char cell);
114 ; /* Clear the word at the given address */
119 lda #EE_C_EWEN ; EWEN
123 ora #EE_C_ERASE ; clear cell A
128 ; ------------------------------------------------------------------------
129 ; unsigned __fastcall__ lynx_eeprom_write (unsigned char cell, unsigned val);
130 ; /* Write the word at the given address */
135 stx ptr1+1 ; Save val into ptr1
136 lda #EE_C_EWEN ; EWEN
139 and #$3f ; Make valid range 0..63
140 ora #EE_C_WRITE ; WRITE
142 jsr EE_Send16Bit ; Send value in ptr1
155 sta IODIR ; AUDIN to input
158 bit IODAT ; 'til ready :D0-read is /D0-written
160 lda #$1a ; AUDIN to output
163 lda #EE_C_EWDS ; EWDS
165 ; bra EE_Send9Bit ; fall into
168 ; ------------------------------------------------------------------------
169 ; Send 8 bit value in A to eeprom
191 ror A ; bit 8 at pos. 4
208 lda #$b ; fnr neue EEPROMs
213 ; ------------------------------------------------------------------------
214 ; Send 16 bit value in ptr1 to eeprom
250 lda #$b ; fnr neue EEPROMs