4 /*********************************************************************
\r
5 ae.h headers for AM188ES 6-20-99 7-16-98
\r
6 *********************************************************************/
\r
7 /* Data structure for Serial operation */
\r
10 unsigned char ready; /* TRUE when ready */
\r
13 unsigned char iflag; /* interrupt status */
\r
14 unsigned char* in_buf; /* Input buffer */
\r
15 unsigned int in_tail; /* Input buffer TAIL ptr */
\r
16 unsigned int in_head; /* Input buffer HEAD ptr */
\r
17 unsigned int in_size; /* Input buffer size */
\r
18 unsigned int in_crcnt; /* Input <CR> count */
\r
19 unsigned char in_mt; /* Input buffer FLAG */
\r
20 unsigned char in_full; /* input buffer full */
\r
21 unsigned char* out_buf; /* Output buffer */
\r
22 unsigned int out_tail; /* Output buffer TAIL ptr */
\r
23 unsigned int out_head; /* Output buffer HEAD ptr */
\r
24 unsigned int out_size; /* Output buffer size */
\r
25 unsigned char out_full; /* Output buffer FLAG */
\r
26 unsigned char out_mt; /* Output buffer MT */
\r
27 unsigned char tmso; // transmit macro service operation
\r
30 unsigned char en485;
\r
33 unsigned char cr; /* scc CR register */
\r
34 unsigned char slave;
\r
35 unsigned int in_segm; /* input buffer segment */
\r
36 unsigned int in_offs; /* input buffer offset */
\r
37 unsigned int out_segm; /* output buffer segment */
\r
38 unsigned int out_offs; /* output buffer offset */
\r
39 unsigned char byte_delay; /* V25 macro service byte delay */
\r
45 unsigned char sec10;
\r
47 unsigned char min10;
\r
48 unsigned char hour1;
\r
49 unsigned char hour10;
\r
51 unsigned char day10;
\r
53 unsigned char mon10;
\r
54 unsigned char year1;
\r
55 unsigned char year10;
\r
60 void ae_reset(void);
\r
61 void led(int i); //P12 used for led
\r
62 void delay_ms(int m);
\r
63 void delay0(unsigned int t);
\r
65 unsigned int wVec, /* Interrupt vector number */
\r
66 void far *ih /* Interrupt handler to install */
\r
69 void clka_en(int i);
\r
70 void clkb_en(int i);
\r
71 void pwr_save_en(int i);
\r
75 // reset ee to remain enabled for reads
\r
76 // where s = segment register value pointing to ee starting addr.
\r
77 // for example = 0x8000
\r
79 void amd_ee_read_reset(unsigned int s);
\r
82 // sec=0x00-0x07 for AM29F010, 16K/sector
\r
83 // sec=0 0x00000-0x03fff
\r
84 // sec=1 0x04000-0x07fff
\r
85 // sec=2 0x08000-0x0bfff
\r
86 // sec=3 0x0c000-0x0ffff
\r
87 // sec=4 0x10000-0x13fff
\r
88 // sec=5 0x14000-0x17fff
\r
89 // sec=6 0x18000-0x1bfff
\r
90 // sec=7 0x1c000-0x1ffff
\r
92 // sec=0x10-0x17 for AM29F040
\r
93 // sec=10 0x00000-0x0ffff
\r
94 // sec=11 0x10000-0x1ffff
\r
95 // sec=12 0x20000-0x2ffff
\r
96 // sec=13 0x30000-0x3ffff
\r
97 // sec=14 0x40000-0x4ffff
\r
98 // sec=15 0x50000-0x5ffff
\r
99 // sec=16 0x60000-0x6ffff
\r
100 // sec=17 0x70000-0x7ffff
\r
101 // segm=segment register value pointing to ee address 0
\r
102 // returns: if pass, return(0);
\r
103 // if fail, return(1);
\r
105 int amd_ee_sec_erase(unsigned int segm, unsigned char sec );
\r
108 // write one byte dat to AM29F040, at address of s:o
\r
109 // Approximately 70 us for 0 wait, 80us for 1 wait.
\r
110 // where s=segment register, it is fixed to 0x8000
\r
111 // o=offset register
\r
112 // returns: if pass, return(0);
\r
113 // if fail, return(1);
\r
115 // Be aware of that a data bit "0" can not be programmed back to a "1" !!!
\r
116 // Attempting to do so will hang up the system !!!
\r
117 // you can program the "1"s to "0"s.
\r
118 // Only erase operation can convert "0"s to "1"s
\r
122 int amd_ee_byte_pro_512(unsigned int s, unsigned int o, unsigned char dat);
\r
125 // write one byte dat to AM29F010, at address of s:o, 80us per byte approx.
\r
126 // where s=segment register, you may use s=0x8000-0xe000
\r
127 // o=offset register
\r
128 // returns: if pass, return(0);
\r
129 // if fail, return(1);
\r
131 // Be aware of that a data bit "0" can not be programmed back to a "1" !!!
\r
132 // Attempting to do so will hang up the system !!!
\r
133 // you can program the "1"s to "0"s.
\r
134 // Only erase operation can convert "0"s to "1"s
\r
137 int amd_ee_byte_pro_128(unsigned int s, unsigned int o, unsigned char dat);
\r
140 // unsigned char rtc_rds(char* time_string);
\r
141 // put a time string into time_string, based on the reading of RTC.
\r
142 // At least 15 bytes of buffer must be available for the time_string
\r
143 // returns 0, if RTC OK, or returns 1, if problem
\r
145 unsigned char rtc_rds(char* time_string);
\r
146 int rtc_rd(TIM *r);
\r
147 void rtc_init(unsigned char*);
\r
148 unsigned char r_rd(void);
\r
149 int r_out(unsigned char v);
\r
152 void t2_init(unsigned int tm,unsigned int ta,void interrupt far(*t2_isr)());
\r
153 void t1_init(unsigned int tm,unsigned int ta,unsigned int tb,void interrupt far(*t1_isr)());
\r
154 void t0_init(unsigned int tm,unsigned int ta,unsigned int tb,void interrupt far(*t0_isr)());
\r
155 unsigned int t2_rd(void);
\r
156 unsigned int t1_rd(void);
\r
157 unsigned int t0_rd(void);
\r
159 // Analog to Digital conversion using TLC2543 on the A-Engine-88/86
\r
161 // unsigned char c = input channel
\r
162 // c = 0, input ch = AD0
\r
163 // c = 1, input ch = AD1
\r
164 // c = 2, input ch = AD2
\r
165 // c = 3, input ch = AD3
\r
166 // c = 4, input ch = AD4
\r
167 // c = 5, input ch = AD5
\r
168 // c = 6, input ch = AD6
\r
169 // c = 7, input ch = AD7
\r
170 // c = 8, input ch = AD8
\r
171 // c = 9, input ch = AD9
\r
172 // c = a, input ch = AD10
\r
173 // In order to operate ADC, P11 must be input.
\r
174 // P11 is shared by RTC, EE. It must be high while power on/reset
\r
175 // For AE88, using PPI for ADC, I20,I21,I22 must be output
\r
176 // For AE86, using PAL for ADC, T0=CLK, T1=DIN, T2=ADCS
\r
177 // Enter the ae_ad12(unsigned char c); EE is stopped first.
\r
178 // Enter the ae86_ad12(unsigned char c); EE is stopped first.
\r
180 // Output: 12 bit AD data of the previous channel !
\r
182 // (Vref+ - Vref-)=0x7ff
\r
187 int ae_ad12(unsigned char c);
\r
189 // outportb(0x120,1); // T0=0, CLK
\r
190 // outportb(0x128,1); // T1=0, DIN
\r
191 // outportb(0x130,1); // T2=0, ADCS
\r
192 int ae86_ad12(unsigned char c);
\r
194 void nmi_init(void interrupt far (* nmi_isr)());
\r
195 void int0_init(unsigned char i, void interrupt far (*int0_isr)());
\r
196 void int1_init(unsigned char i, void interrupt far (*int1_isr)());
\r
197 void int2_init(unsigned char i, void interrupt far (*int2_isr)());
\r
198 void int3_init(unsigned char i, void interrupt far (*int3_isr)());
\r
199 void int4_init(unsigned char i, void interrupt far (*int4_isr)());
\r
200 void int5_init(unsigned char i, void interrupt far (*int5_isr)());
\r
201 void int6_init(unsigned char i, void interrupt far (*int6_isr)());
\r
205 // void pio_init(char bit, char mode)
\r
207 // mode=0, Normal operation
\r
208 // mode=1, Input with pullup/down
\r
210 // mode=3, input without pull
\r
212 void pio_init(char bit, char mode);
\r
216 // void pio_wr(char bit, char dat)
\r
220 void pio_wr(char bit, char dat);
\r
223 // unsigned int pio_rd(char port)
\r
224 // return P15-P0, if port=0
\r
225 // return P31-P16, if port=1
\r
227 unsigned int pio_rd(char port);
\r
229 // setup I/O wait states for I/O instructions
\r
230 // where wait = 0-7
\r
231 // wait=0, wait states = 0, I/O enable for 100 ns
\r
232 // wait=1, wait states = 1, I/O enable for 100+25 ns
\r
233 // wait=2, wait states = 2, I/O enable for 100+50 ns
\r
234 // wait=3, wait states = 3, I/O enable for 100+75 ns
\r
235 // wait=4, wait states = 5, I/O enable for 100+125 ns
\r
236 // wait=5, wait states = 7, I/O enable for 100+175 ns
\r
237 // wait=6, wait states = 9, I/O enable for 100+225 ns
\r
238 // wait=7, wait states = 15, I/O enable for 100+375 ns
\r
239 void io_wait(char wait);
\r
241 unsigned int crc16(unsigned char *wptr, unsigned int count);
\r
243 /******************************************************
\r
244 void ae_da(int dat1, int dat2)
\r
245 output dat to U11 DAC of AE88
\r
246 Requires P12=CLK, P26=DI, P29=LD/CS as output pins !
\r
247 where dat1 for channel A, dat2 for channel B; dat1/2 = 0-4095
\r
248 *******************************************************/
\r
249 void ae_da(int dat1, int dat2);
\r
251 /******************************************************
\r
252 void ae86_da(int dat1, int dat2)
\r
253 output dat to U15 DAC of AE86
\r
254 Requires T0=CLK=0x120, T1=DI=0x128, T3=LD/CS=0x138
\r
255 where dat1 for channel A, dat2 for channel B; dat1/2 = 0-4095
\r
256 Output 0-2.5V at VA=J4.16, VB=J4.18
\r
257 *******************************************************/
\r
258 void ae86_da(int dat1, int dat2);
\r
259 void interrupt reset_io_trap();
\r