codeseg segment para public 'code'
dataseg segment para public 'data'
dataseg ends
	assume cs:codeseg,ds:dataseg,es:dataseg,ss:dataseg
	extrn $cswt:near
	extrn $begin:near
;/*     Title   All-Pro Diagnostics*/
;/**************************************************************
;****************/
;/*                                   Diagalog                  
;               */
;/*                             All-pro Diagnostic Analog contro
;l test         */
;/*                                                             
;               */
;/* Module ...................... DIAGALOG                      
;               */
;/* Title ....................... All-pro Diagnostic Analog cont
;rol test       */
;/* Developing Engineer ......... Steven T. Harr                
;               */
;/* Company ..................... Logical Devices               
;               */
;/* Revision Level .............. 1.00                          
;               */
;/* Date of Last Revision ....... 16-FEB-86                     
;               */
;/* Last Revision by ............ STH                           
;               */
;/*                                                             
;               */
;/*                                                             
;               */
;/**************************************************************
;****************/
;/*     Subttl  Includes*/
;#include <stdio.h>
;#include <ctype.h>
;#include "pindrivr.h"
;#include "diag2.h"
;
;/*      Subttl  defines */
;#define SUPPLY1DAC              0x302
;#define THRESHOLDDAC            0x301
;#define SLEWRATEDAC             0x300
;#define PUCONTROLDAC            0x305
;#define CURRENTDAC              0x303
;
;/*     Subttl  Externals */
;extern unsigned char analog_id;
;int func_null ();
;int func_help ();
;
;
;
;/*     Subttl Analog Calibration */
;
;struct menu_struc cal_vr2 [] =
dataseg segment para public 'data'
	public	cal_vr2_
cal_vr2_ equ this word
;{
;    { '0',*func_null,  4, 'C', "ALLPRO DIAGNOSTIC CALIBRATION" 
	db 48
	dw func_null_
	dw 4
	db 67
;},
 dw $1+0
;    { '0',*func_null,  5, 'C', "ANALOG CONTROL U3 DAC REFERENCE
	db 48
	dw func_null_
	dw 5
	db 67
; VR2" },
 dw $1+30
;    { '0',*func_null,  10, 'L', "Place volt meter from U3 pin 4
	db 48
	dw func_null_
	dw 10
	db 76
; to ground." },
 dw $1+66
;    { '0',*func_null,  11, 'L', "Adjust analog control R4 to me
	db 48
	dw func_null_
	dw 11
	db 76
;asure 5.00 volts." },
 dw $1+108
;    { '\0',*func_null, 0,  0, "" }
	db 0
	dw func_null_
	dw 0
	db 0
 dw $1+156
;};
dataseg ends
dataseg segment para public 'data'
$1	db 65,76,76,80,82,79
	db 32,68,73,65,71,78
	db 79,83,84,73,67,32
	db 67,65,76,73,66,82
	db 65,84,73,79,78,0
	db 65,78,65,76,79,71
	db 32,67,79,78,84,82
	db 79,76,32,85,51,32
	db 68,65,67,32,82,69
	db 70,69,82,69,78,67
	db 69,32,86,82,50,0
	db 80,108,97,99,101,32
	db 118,111,108,116,32,109
	db 101,116,101,114,32,102
	db 114,111,109,32,85,51
	db 32,112,105,110,32,52
	db 32,116,111,32,103,114
	db 111,117,110,100,46,0
	db 65,100,106,117,115,116
	db 32,97,110,97,108,111
	db 103,32,99,111,110,116
	db 114,111,108,32,82,52
	db 32,116,111,32,109,101
	db 97,115,117,114,101,32
	db 53,46,48,48,32,118
	db 111,108,116,115,46,0
	db 0
dataseg ends
;
;
;struct menu_struc cal_vth [] =
dataseg segment para public 'data'
	public	cal_vth_
cal_vth_ equ this word
;{
;    { '0',*func_null,  4, 'C', "ALLPRO DIAGNOSTIC CALIBRATION" 
	db 48
	dw func_null_
	dw 4
	db 67
;},
 dw $2+0
;    { '0',*func_null,  5, 'C', "SYSTEM READ THRESHOLD VOLTAGE" 
	db 48
	dw func_null_
	dw 5
	db 67
;},
 dw $2+30
;    { '0',*func_null,  10, 'L', "Place volt meter from U7 pin 1
	db 48
	dw func_null_
	dw 10
	db 76
;6 to ground." },
 dw $2+60
;    { '0',*func_null,  11, 'L', "Adjust analog control R8 to me
	db 48
	dw func_null_
	dw 11
	db 76
;asure 19.20 volts." },
 dw $2+103
;    { '\0',*func_null, 0,  0, "" }
	db 0
	dw func_null_
	dw 0
	db 0
 dw $2+152
;};
dataseg ends
dataseg segment para public 'data'
$2	db 65,76,76,80,82,79
	db 32,68,73,65,71,78
	db 79,83,84,73,67,32
	db 67,65,76,73,66,82
	db 65,84,73,79,78,0
	db 83,89,83,84,69,77
	db 32,82,69,65,68,32
	db 84,72,82,69,83,72
	db 79,76,68,32,86,79
	db 76,84,65,71,69,0
	db 80,108,97,99,101,32
	db 118,111,108,116,32,109
	db 101,116,101,114,32,102
	db 114,111,109,32,85,55
	db 32,112,105,110,32,49
	db 54,32,116,111,32,103
	db 114,111,117,110,100,46
	db 0,65,100,106,117,115
	db 116,32,97,110,97,108
	db 111,103,32,99,111,110
	db 116,114,111,108,32,82
	db 56,32,116,111,32,109
	db 101,97,115,117,114,101
	db 32,49,57,46,50,48
	db 32,118,111,108,116,115
	db 46,0,0
dataseg ends
;
;
;struct menu_struc cal_vref [] =
dataseg segment para public 'data'
	public	cal_vref_
cal_vref_ equ this word
;{
;    { '0',*func_null,  4, 'C', "ALLPRO DIAGNOSTIC CALIBRATION" 
	db 48
	dw func_null_
	dw 4
	db 67
;},
 dw $3+0
;    { '0',*func_null,  5, 'C', "NEGATIVE DAC REFERENCE VOLTAGE"
	db 48
	dw func_null_
	dw 5
	db 67
; },
 dw $3+30
;    { '0',*func_null,  10, 'L', "Place volt meter from U5 pin 8
	db 48
	dw func_null_
	dw 10
	db 76
; to ground." },
 dw $3+61
;    { '0',*func_null,  11, 'L', "Adjust analog control R19 to m
	db 48
	dw func_null_
	dw 11
	db 76
;easure -5.00 volts." },
 dw $3+103
;    { '\0',*func_null, 0,  0, "" }
	db 0
	dw func_null_
	dw 0
	db 0
 dw $3+153
;};
dataseg ends
dataseg segment para public 'data'
$3	db 65,76,76,80,82,79
	db 32,68,73,65,71,78
	db 79,83,84,73,67,32
	db 67,65,76,73,66,82
	db 65,84,73,79,78,0
	db 78,69,71,65,84,73
	db 86,69,32,68,65,67
	db 32,82,69,70,69,82
	db 69,78,67,69,32,86
	db 79,76,84,65,71,69
	db 0,80,108,97,99,101
	db 32,118,111,108,116,32
	db 109,101,116,101,114,32
	db 102,114,111,109,32,85
	db 53,32,112,105,110,32
	db 56,32,116,111,32,103
	db 114,111,117,110,100,46
	db 0,65,100,106,117,115
	db 116,32,97,110,97,108
	db 111,103,32,99,111,110
	db 116,114,111,108,32,82
	db 49,57,32,116,111,32
	db 109,101,97,115,117,114
	db 101,32,45,53,46,48
	db 48,32,118,111,108,116
	db 115,46,0,0
dataseg ends
;
;
;/*     Subttl Analog Calibration */
;calibrate_vth ()
;{
	public calibrate_vth_
calibrate_vth_ proc	near
	push bp
	mov bp,sp
ifdef $5
	add sp,$5
endif
ifdef	$6
	push	di
endif
ifdef $7
	push	si
endif
;    print_menu ( cal_vth );
	mov	ax, offset cal_vth_
	push	ax
	call	print_menu_
	pop	cx
;    reset_allpro();
	call	reset_allpro_
;    udi_write_bit (DAC_REFERENCE_BIT, ON);                     
	mov	ax,1
	push	ax
	push	ax
	call	udi_write_bit_
	add sp,4
; /* make sure dac reference on                   */
;    udi_write_dac (SUPPLY1_POWER_DAC, 2500);
	mov	ax,2500
	push	ax
	mov	ax,770
	push	ax
	call	udi_write_dac_
	add sp,4
;    while (keyboard_status () == -1)
$8:
	call	keyboard_status_
	cmp	ax,-1
	bne 	$9
;    {
;        udi_write_dac (THRESH_HOLD_DAC, 1920);                 
	mov	ax,1920
	push	ax
	mov	ax,769
	push	ax
	call	udi_write_dac_
	add sp,4
;     /* set threshold to 19.2 volts                  */
;    }
	jmp $8
$9:
;    keybrd_getc ();
	call	keybrd_getc_
;    reset_allpro();
	call	reset_allpro_
;}
$10:
ifdef $7
	pop si
endif
ifdef	$6
	pop	di
endif
	mov	sp,bp
	pop	bp
	ret
calibrate_vth_ endp
;
;
;calibrate_vref ()
;{
	public calibrate_vref_
calibrate_vref_ proc	near
	push bp
	mov bp,sp
ifdef $11
	add sp,$11
endif
ifdef	$12
	push	di
endif
ifdef $13
	push	si
endif
;    print_menu ( cal_vref );
	mov	ax, offset cal_vref_
	push	ax
	call	print_menu_
	pop	cx
;    reset_allpro();
	call	reset_allpro_
;    udi_write_bit (DAC_REFERENCE_BIT, ON);
	mov	ax,1
	push	ax
	push	ax
	call	udi_write_bit_
	add sp,4
;    while (keyboard_status () == -1)
$14:
	call	keyboard_status_
	cmp	ax,-1
	bne 	$15
;    {
;        udi_write_dac (SUPPLY1_POWER_DAC, 500);
	mov	ax,500
	push	ax
	mov	ax,770
	push	ax
	call	udi_write_dac_
	add sp,4
;    }
	jmp $14
$15:
;    reset_allpro();
	call	reset_allpro_
;}
$16:
ifdef $13
	pop si
endif
ifdef	$12
	pop	di
endif
	mov	sp,bp
	pop	bp
	ret
calibrate_vref_ endp
;
;
;calibrate_vr2 ()
;{
	public calibrate_vr2_
calibrate_vr2_ proc	near
	push bp
	mov bp,sp
ifdef $17
	add sp,$17
endif
ifdef	$18
	push	di
endif
ifdef $19
	push	si
endif
;    print_menu ( cal_vr2 );
	mov	ax, offset cal_vr2_
	push	ax
	call	print_menu_
	pop	cx
;    reset_allpro();
	call	reset_allpro_
;    while (keyboard_status () == -1)
$20:
	call	keyboard_status_
	cmp	ax,-1
	bne 	$21
;    {
;        udi_write_bit (DAC_REFERENCE_BIT, ON);
	mov	ax,1
	push	ax
	push	ax
	call	udi_write_bit_
	add sp,4
;    }
	jmp $20
$21:
;    reset_allpro();
	call	reset_allpro_
;}
$22:
ifdef $19
	pop si
endif
ifdef	$18
	pop	di
endif
	mov	sp,bp
	pop	bp
	ret
calibrate_vr2_ endp
;
;
;
;
;struct menu_struc menu_calibrate [] =
dataseg segment para public 'data'
	public	menu_calibrate_
menu_calibrate_ equ this word
;{
;    { '?',*func_help,  4, 'C', "ALLPRO CALIBRATION PROCEDURES" 
	db 63
	dw func_help_
	dw 4
	db 67
;},
 dw $4+0
;    { '1',*calibrate_vr2,  7,  'L', "1. Adjust VR2 for +5 volts
	db 49
	dw calibrate_vr2_
	dw 7
	db 76
;." },
 dw $4+30
;    { '2',*calibrate_vref,  9,  'L', "2. Adjust VREF to -5 volt
	db 50
	dw calibrate_vref_
	dw 9
	db 76
;s." },
 dw $4+58
;    { '3',*calibrate_vth, 11,  'L', "3. Adjust VTH to 19.20 vol
	db 51
	dw calibrate_vth_
	dw 11
	db 76
;ts." },
 dw $4+86
;    { '\0',*func_null, 0,  0, "" }
	db 0
	dw func_null_
	dw 0
	db 0
 dw $4+116
;};
dataseg ends
dataseg segment para public 'data'
$4	db 65,76,76,80,82,79
	db 32,67,65,76,73,66
	db 82,65,84,73,79,78
	db 32,80,82,79,67,69
	db 68,85,82,69,83,0
	db 49,46,32,65,100,106
	db 117,115,116,32,86,82
	db 50,32,102,111,114,32
	db 43,53,32,118,111,108
	db 116,115,46,0,50,46
	db 32,65,100,106,117,115
	db 116,32,86,82,69,70
	db 32,116,111,32,45,53
	db 32,118,111,108,116,115
	db 46,0,51,46,32,65
	db 100,106,117,115,116,32
	db 86,84,72,32,116,111
	db 32,49,57,46,50,48
	db 32,118,111,108,116,115
	db 46,0,0
dataseg ends
;
;
;
;calibrate ()
;{
	public calibrate_
calibrate_ proc	near
	push bp
	mov bp,sp
ifdef $24
	add sp,$24
endif
ifdef	$25
	push	di
endif
ifdef $26
	push	si
endif
;    select_command ( menu_calibrate );
	mov	ax, offset menu_calibrate_
	push	ax
	call	select_command_
	pop	cx
;}
$27:
ifdef $26
	pop si
endif
ifdef	$25
	pop	di
endif
	mov	sp,bp
	pop	bp
	ret
calibrate_ endp
;
;
;/*     Subttl  Dac linearity tests */
;
;ramp_dac (dac)
;int dac;
	public ramp_dac_
ramp_dac_ proc	near
	push bp
	mov bp,sp
ifdef $28
	add sp,$28
endif
ifdef	$29
	push	di
endif
ifdef $30
	push	si
endif
;{
;    int i;
;
;    write_dac (SUPPLY1DAC, 255);
	mov	ax,255
	push	ax
	mov	ax,770
	push	ax
	call	write_dac_
	add sp,4
;/*    udi_write_dac (SUPPLY1_POWER_DAC, 2500);*/
;    udi_write_bit (DAC_REFERENCE_BIT, ON);                     
	mov	ax,1
	push	ax
	push	ax
	call	udi_write_bit_
	add sp,4
; /* make sure dac reference on                   */
;    udi_write_bit (GREEN_LED_OFF_BIT, ON);                     
	mov	ax,1
	push	ax
	mov	ax,4
	push	ax
	call	udi_write_bit_
	add sp,4
; /* make sure green led bit is off               */
;
;    while (keyboard_status () == -1)
$31:
	call	keyboard_status_
	cmp	ax,-1
	bne 	$32
;    {
;        if (dac == SLEW_RATE_DAC)
;        {
	mov	ax,word ptr 4[bp]
	cmp	ax,768
	bne 	$33
;            for (i = 0; i <= 247; i++)
	mov	word ptr -2[bp],0
$36:
	mov	ax,word ptr -2[bp]
	cmp	ax,247
	bgt 	$35
;            {
;                write_dac (SLEWRATEDAC, i);
	push	ax
	mov	ax,768
	push	ax
	call	write_dac_
	add sp,4
;                delay_us (80);
	mov	ax,80
	push	ax
	call	delay_us_
	pop	cx
;/*                udi_write_dac (dac, i);*/
;            }
$34:
	inc	word ptr -2[bp]
	jmp $36
$35:
;
;            for (i = 247; i >= 0; i--)
	mov	word ptr -2[bp],247
$39:
	mov	ax,word ptr -2[bp]
	cmp	ax,0
	blt 	$38
;            {
;                write_dac (SLEWRATEDAC, i);
	push	ax
	mov	ax,768
	push	ax
	call	write_dac_
	add sp,4
;                delay_us (80);
	mov	ax,80
	push	ax
	call	delay_us_
	pop	cx
;/*                udi_write_dac (dac, i);*/
;            }
$37:
	dec	word ptr -2[bp]
	jmp $39
$38:
;        }
;        else
	jmp $40
$33:
;        {
;            for (i = 0; i <= 2470; i += 10)
	mov	word ptr -2[bp],0
$43:
	mov	ax,word ptr -2[bp]
	cmp	ax,2470
	bgt 	$42
;            {
;                udi_write_dac (dac, i);
	push	ax
	push	word ptr 4[bp]
	call	udi_write_dac_
	add sp,4
;            }
$41:
	add	word ptr -2[bp],10
	jmp $43
$42:
;
;            for (i = 2470; i >= 0; i -= 10)
	mov	word ptr -2[bp],2470
$46:
	mov	ax,word ptr -2[bp]
	cmp	ax,0
	blt 	$45
;            {
;                udi_write_dac (dac, i);
	push	ax
	push	word ptr 4[bp]
	call	udi_write_dac_
	add sp,4
;            }
$44:
	sub	word ptr -2[bp],10
	jmp $46
$45:
;        }
$40:
;        delay_ms (200);
	mov	ax,200
	push	ax
	call	delay_ms_
	pop	cx
;    }
	jmp $31
$32:
;    reset_allpro ();
	call	reset_allpro_
;}
$47:
ifdef $30
	pop si
endif
ifdef	$29
	pop	di
endif
	mov	sp,bp
	pop	bp
	ret
$28 = -2
ramp_dac_ endp
;
;
;
;struct menu_struc menu_thresh_dac [] =
dataseg segment para public 'data'
	public	menu_thresh_dac_
menu_thresh_dac_ equ this word
;{
;    { '?',*func_help,          4, 'C', "ANALOG CONTROL DAC LINE
	db 63
	dw func_help_
	dw 4
	db 67
;ARITY TEST" },
 dw $23+0
;    { '?',*func_help,          5, 'C', "READ THRESHOLD CONTROL 
	db 63
	dw func_help_
	dw 5
	db 67
;DAC" },
 dw $23+34
;    { '?',*func_help,          7, 'L', "Place scope probe on U7
	db 63
	dw func_help_
	dw 7
	db 76
; pin 16, observe triangle waveform." },
 dw $23+61
;    { '?',*func_help,          8, 'L', "Type and key to stop te
	db 63
	dw func_help_
	dw 8
	db 76
;st." },
 dw $23+120
;    { '\0',*func_null, 0,  0, "" }
	db 0
	dw func_null_
	dw 0
	db 0
 dw $23+147
;};
dataseg ends
dataseg segment para public 'data'
$23	db 65,78,65,76,79,71
	db 32,67,79,78,84,82
	db 79,76,32,68,65,67
	db 32,76,73,78,69,65
	db 82,73,84,89,32,84
	db 69,83,84,0,82,69
	db 65,68,32,84,72,82
	db 69,83,72,79,76,68
	db 32,67,79,78,84,82
	db 79,76,32,68,65,67
	db 0,80,108,97,99,101
	db 32,115,99,111,112,101
	db 32,112,114,111,98,101
	db 32,111,110,32,85,55
	db 32,112,105,110,32,49
	db 54,44,32,111,98,115
	db 101,114,118,101,32,116
	db 114,105,97,110,103,108
	db 101,32,119,97,118,101
	db 102,111,114,109,46,0
	db 84,121,112,101,32,97
	db 110,100,32,107,101,121
	db 32,116,111,32,115,116
	db 111,112,32,116,101,115
	db 116,46,0,0
dataseg ends
;
;
;
;ramp_thresh_dac ()
;{
	public ramp_thresh_dac_
ramp_thresh_dac_ proc	near
	push bp
	mov bp,sp
ifdef $49
	add sp,$49
endif
ifdef	$50
	push	di
endif
ifdef $51
	push	si
endif
;    print_menu (menu_thresh_dac);
	mov	ax, offset menu_thresh_dac_
	push	ax
	call	print_menu_
	pop	cx
;    ramp_dac (THRESH_HOLD_DAC);
	mov	ax,769
	push	ax
	call	ramp_dac_
	pop	cx
;}
$52:
ifdef $51
	pop si
endif
ifdef	$50
	pop	di
endif
	mov	sp,bp
	pop	bp
	ret
ramp_thresh_dac_ endp
;
;
;
;struct menu_struc menu_slew_rate_dac [] =
dataseg segment para public 'data'
	public	menu_slew_rate_dac_
menu_slew_rate_dac_ equ this word
;{
;    { '?',*func_help,          4, 'C', "ANALOG CONTROL DAC LINE
	db 63
	dw func_help_
	dw 4
	db 67
;ARITY TEST" },
 dw $48+0
;    { '?',*func_help,          5, 'C', "SLEW RATE CONTROL DAC" 
	db 63
	dw func_help_
	dw 5
	db 67
;},
 dw $48+34
;    { '?',*func_help,          7, 'L', "Place scope probe on U7
	db 63
	dw func_help_
	dw 7
	db 76
; pin 1, observe triangle waveform." },
 dw $48+56
;    { '?',*func_help,          8, 'L', "Type and key to stop te
	db 63
	dw func_help_
	dw 8
	db 76
;st." },
 dw $48+114
;    { '\0',*func_null, 0,  0, "" }
	db 0
	dw func_null_
	dw 0
	db 0
 dw $48+141
;};
dataseg ends
dataseg segment para public 'data'
$48	db 65,78,65,76,79,71
	db 32,67,79,78,84,82
	db 79,76,32,68,65,67
	db 32,76,73,78,69,65
	db 82,73,84,89,32,84
	db 69,83,84,0,83,76
	db 69,87,32,82,65,84
	db 69,32,67,79,78,84
	db 82,79,76,32,68,65
	db 67,0,80,108,97,99
	db 101,32,115,99,111,112
	db 101,32,112,114,111,98
	db 101,32,111,110,32,85
	db 55,32,112,105,110,32
	db 49,44,32,111,98,115
	db 101,114,118,101,32,116
	db 114,105,97,110,103,108
	db 101,32,119,97,118,101
	db 102,111,114,109,46,0
	db 84,121,112,101,32,97
	db 110,100,32,107,101,121
	db 32,116,111,32,115,116
	db 111,112,32,116,101,115
	db 116,46,0,0
dataseg ends
;
;
;
;ramp_slew_rate_dac ()
;{
	public ramp_slew_rate_dac_
ramp_slew_rate_dac_ proc	near
	push bp
	mov bp,sp
ifdef $54
	add sp,$54
endif
ifdef	$55
	push	di
endif
ifdef $56
	push	si
endif
;    print_menu (menu_slew_rate_dac);
	mov	ax, offset menu_slew_rate_dac_
	push	ax
	call	print_menu_
	pop	cx
;    ramp_dac (SLEW_RATE_DAC);
	mov	ax,768
	push	ax
	call	ramp_dac_
	pop	cx
;}
$57:
ifdef $56
	pop si
endif
ifdef	$55
	pop	di
endif
	mov	sp,bp
	pop	bp
	ret
ramp_slew_rate_dac_ endp
;
;
;
;struct menu_struc menu_power_dac [] =
dataseg segment para public 'data'
	public	menu_power_dac_
menu_power_dac_ equ this word
;{
;    { '?',*func_help,          4, 'C', "ANALOG CONTROL DAC LINE
	db 63
	dw func_help_
	dw 4
	db 67
;ARITY TEST" },
 dw $53+0
;    { '?',*func_help,          5, 'C', "SUPPLY1 POWER DAC" },
	db 63
	dw func_help_
	dw 5
	db 67
 dw $53+34
;    { '?',*func_help,          7, 'L', "Place scope probe on U3
	db 63
	dw func_help_
	dw 7
	db 76
; pin 20, observe triangle waveform." },
 dw $53+52
;    { '?',*func_help,          8, 'L', "Type and key to stop te
	db 63
	dw func_help_
	dw 8
	db 76
;st." },
 dw $53+111
;    { '\0',*func_null, 0,  0, "" }
	db 0
	dw func_null_
	dw 0
	db 0
 dw $53+138
;};
dataseg ends
dataseg segment para public 'data'
$53	db 65,78,65,76,79,71
	db 32,67,79,78,84,82
	db 79,76,32,68,65,67
	db 32,76,73,78,69,65
	db 82,73,84,89,32,84
	db 69,83,84,0,83,85
	db 80,80,76,89,49,32
	db 80,79,87,69,82,32
	db 68,65,67,0,80,108
	db 97,99,101,32,115,99
	db 111,112,101,32,112,114
	db 111,98,101,32,111,110
	db 32,85,51,32,112,105
	db 110,32,50,48,44,32
	db 111,98,115,101,114,118
	db 101,32,116,114,105,97
	db 110,103,108,101,32,119
	db 97,118,101,102,111,114
	db 109,46,0,84,121,112
	db 101,32,97,110,100,32
	db 107,101,121,32,116,111
	db 32,115,116,111,112,32
	db 116,101,115,116,46,0
	db 0
dataseg ends
;
;
;ramp_power_dac ()
;{
	public ramp_power_dac_
ramp_power_dac_ proc	near
	push bp
	mov bp,sp
ifdef $59
	add sp,$59
endif
ifdef	$60
	push	di
endif
ifdef $61
	push	si
endif
;    print_menu (menu_power_dac);
	mov	ax, offset menu_power_dac_
	push	ax
	call	print_menu_
	pop	cx
;    ramp_dac (SUPPLY1_POWER_DAC);
	mov	ax,770
	push	ax
	call	ramp_dac_
	pop	cx
;}
$62:
ifdef $61
	pop si
endif
ifdef	$60
	pop	di
endif
	mov	sp,bp
	pop	bp
	ret
ramp_power_dac_ endp
;
;
;
;struct menu_struc menu_pullup_dac [] =
dataseg segment para public 'data'
	public	menu_pullup_dac_
menu_pullup_dac_ equ this word
;{
;    { '?',*func_help,          4, 'C', "ANALOG CONTROL DAC LINE
	db 63
	dw func_help_
	dw 4
	db 67
;ARITY TEST" },
 dw $58+0
;    { '?',*func_help,          5, 'C', "PULL-UP CONTROL DAC" },
	db 63
	dw func_help_
	dw 5
	db 67
 dw $58+34
;
;    { '?',*func_help,          7, 'L', "Place scope probe on VR
	db 63
	dw func_help_
	dw 7
	db 76
;3 emitter, observe triangle waveform." },
 dw $58+54
;    { '?',*func_help,          8, 'L', "Type and key to stop te
	db 63
	dw func_help_
	dw 8
	db 76
;st." },
 dw $58+115
;    { '\0',*func_null, 0,  0, "" }
	db 0
	dw func_null_
	dw 0
	db 0
 dw $58+142
;};
dataseg ends
dataseg segment para public 'data'
$58	db 65,78,65,76,79,71
	db 32,67,79,78,84,82
	db 79,76,32,68,65,67
	db 32,76,73,78,69,65
	db 82,73,84,89,32,84
	db 69,83,84,0,80,85
	db 76,76,45,85,80,32
	db 67,79,78,84,82,79
	db 76,32,68,65,67,0
	db 80,108,97,99,101,32
	db 115,99,111,112,101,32
	db 112,114,111,98,101,32
	db 111,110,32,86,82,51
	db 32,101,109,105,116,116
	db 101,114,44,32,111,98
	db 115,101,114,118,101,32
	db 116,114,105,97,110,103
	db 108,101,32,119,97,118
	db 101,102,111,114,109,46
	db 0,84,121,112,101,32
	db 97,110,100,32,107,101
	db 121,32,116,111,32,115
	db 116,111,112,32,116,101
	db 115,116,46,0,0
dataseg ends
;
;
;
;ramp_pu_dac ()
;{
	public ramp_pu_dac_
ramp_pu_dac_ proc	near
	push bp
	mov bp,sp
ifdef $64
	add sp,$64
endif
ifdef	$65
	push	di
endif
ifdef $66
	push	si
endif
;    print_menu (menu_pullup_dac);
	mov	ax, offset menu_pullup_dac_
	push	ax
	call	print_menu_
	pop	cx
;    ramp_dac (PU_CONTROL_DAC);
	mov	ax,773
	push	ax
	call	ramp_dac_
	pop	cx
;}
$67:
ifdef $66
	pop si
endif
ifdef	$65
	pop	di
endif
	mov	sp,bp
	pop	bp
	ret
ramp_pu_dac_ endp
;
;
;
;
;
;
;
;
;struct menu_struc menu_current_dac [] =
dataseg segment para public 'data'
	public	menu_current_dac_
menu_current_dac_ equ this word
;{
;    { '?',*func_help,          4, 'C', "ANALOG CONTROL DAC LINE
	db 63
	dw func_help_
	dw 4
	db 67
;ARITY TEST" },
 dw $63+0
;    { '?',*func_help,          5, 'C', "CURRENT CONTROL DAC" },
	db 63
	dw func_help_
	dw 5
	db 67
 dw $63+34
;
;    { '?',*func_help,          7, 'L', "Place scope probe on U3
	db 63
	dw func_help_
	dw 7
	db 76
; pin 19, observe triangle waveform." },
 dw $63+54
;    { '?',*func_help,          8, 'L', "Type and key to stop te
	db 63
	dw func_help_
	dw 8
	db 76
;st." },
 dw $63+113
;    { '\0',*func_null, 0,  0, "" }
	db 0
	dw func_null_
	dw 0
	db 0
 dw $63+140
;};
dataseg ends
dataseg segment para public 'data'
$63	db 65,78,65,76,79,71
	db 32,67,79,78,84,82
	db 79,76,32,68,65,67
	db 32,76,73,78,69,65
	db 82,73,84,89,32,84
	db 69,83,84,0,67,85
	db 82,82,69,78,84,32
	db 67,79,78,84,82,79
	db 76,32,68,65,67,0
	db 80,108,97,99,101,32
	db 115,99,111,112,101,32
	db 112,114,111,98,101,32
	db 111,110,32,85,51,32
	db 112,105,110,32,49,57
	db 44,32,111,98,115,101
	db 114,118,101,32,116,114
	db 105,97,110,103,108,101
	db 32,119,97,118,101,102
	db 111,114,109,46,0,84
	db 121,112,101,32,97,110
	db 100,32,107,101,121,32
	db 116,111,32,115,116,111
	db 112,32,116,101,115,116
	db 46,0,0
dataseg ends
;
;
;ramp_current_dac ()
;{
	public ramp_current_dac_
ramp_current_dac_ proc	near
	push bp
	mov bp,sp
ifdef $69
	add sp,$69
endif
ifdef	$70
	push	di
endif
ifdef $71
	push	si
endif
;    print_menu (menu_current_dac);
	mov	ax, offset menu_current_dac_
	push	ax
	call	print_menu_
	pop	cx
;    ramp_dac (CURRENT_DAC);
	mov	ax,771
	push	ax
	call	ramp_dac_
	pop	cx
;}
$72:
ifdef $71
	pop si
endif
ifdef	$70
	pop	di
endif
	mov	sp,bp
	pop	bp
	ret
ramp_current_dac_ endp
;
;
;
;struct menu_struc menu_ramp_dacs [] =
dataseg segment para public 'data'
	public	menu_ramp_dacs_
menu_ramp_dacs_ equ this word
;{
;    { '?',*func_help,          4, 'C', "ANALOG CONTROL DAC LINE
	db 63
	dw func_help_
	dw 4
	db 67
;ARITY TEST" },
 dw $68+0
;    { '1',*ramp_thresh_dac,    7,  'L', "1. Ramp Threshold DAC.
	db 49
	dw ramp_thresh_dac_
	dw 7
	db 76
;" },
 dw $68+34
;    { '2',*ramp_slew_rate_dac, 8,  'L', "2. Ramp Slew-rate DAC.
	db 50
	dw ramp_slew_rate_dac_
	dw 8
	db 76
;" },
 dw $68+57
;    { '3',*ramp_power_dac,     9,  'L', "3. Ramp Supply1 power 
	db 51
	dw ramp_power_dac_
	dw 9
	db 76
;DAC." },
 dw $68+80
;    { '4',*ramp_current_dac,  10,  'L', "4. Ramp Current DAC." 
	db 52
	dw ramp_current_dac_
	dw 10
	db 76
;},
 dw $68+107
;    { '5',*ramp_pu_dac,       11,  'L', "5. Ramp Pull-up DAC." 
	db 53
	dw ramp_pu_dac_
	dw 11
	db 76
;},
 dw $68+128
;    { '\0',*func_null, 0,  0, "" }
	db 0
	dw func_null_
	dw 0
	db 0
 dw $68+149
;};
dataseg ends
dataseg segment para public 'data'
$68	db 65,78,65,76,79,71
	db 32,67,79,78,84,82
	db 79,76,32,68,65,67
	db 32,76,73,78,69,65
	db 82,73,84,89,32,84
	db 69,83,84,0,49,46
	db 32,82,97,109,112,32
	db 84,104,114,101,115,104
	db 111,108,100,32,68,65
	db 67,46,0,50,46,32
	db 82,97,109,112,32,83
	db 108,101,119,45,114,97
	db 116,101,32,68,65,67
	db 46,0,51,46,32,82
	db 97,109,112,32,83,117
	db 112,112,108,121,49,32
	db 112,111,119,101,114,32
	db 68,65,67,46,0,52
	db 46,32,82,97,109,112
	db 32,67,117,114,114,101
	db 110,116,32,68,65,67
	db 46,0,53,46,32,82
	db 97,109,112,32,80,117
	db 108,108,45,117,112,32
	db 68,65,67,46,0,0
dataseg ends
;
;
;
;func_linearity ()
;{
	public func_linearity_
func_linearity_ proc	near
	push bp
	mov bp,sp
ifdef $74
	add sp,$74
endif
ifdef	$75
	push	di
endif
ifdef $76
	push	si
endif
;    select_command ( menu_ramp_dacs );
	mov	ax, offset menu_ramp_dacs_
	push	ax
	call	select_command_
	pop	cx
;}
$77:
ifdef $76
	pop si
endif
ifdef	$75
	pop	di
endif
	mov	sp,bp
	pop	bp
	ret
func_linearity_ endp
;
;
;/*     Subttl Analog Control Tests */
;
;func_analog_id ()
;{
	public func_analog_id_
func_analog_id_ proc	near
	push bp
	mov bp,sp
ifdef $78
	add sp,$78
endif
ifdef	$79
	push	di
endif
ifdef $80
	push	si
endif
;    get_analog_id ();
	call	get_analog_id_
;    crt_pos_cursor (7, 40, 0);
	xor ax,ax
	push	ax
	mov	ax,40
	push	ax
	mov	ax,7
	push	ax
	call	crt_pos_cursor_
	add sp,6
;    printf ("Analog ID code = %2x.", analog_id);
	mov	al, byte ptr analog_id_
	sub ah,ah
	push	ax
	mov	ax, offset $73+0
	push	ax
	call	printf_
	add sp,4
;    keybrd_getc ();
	call	keybrd_getc_
;}
$81:
ifdef $80
	pop si
endif
ifdef	$79
	pop	di
endif
	mov	sp,bp
	pop	bp
	ret
func_analog_id_ endp
dataseg segment para public 'data'
$73	db 65,110,97,108,111,103
	db 32,73,68,32,99,111
	db 100,101,32,61,32,37
	db 50,120,46,0
dataseg ends
;
;struct menu_struc menu_analog_cont [] =
dataseg segment para public 'data'
	public	menu_analog_cont_
menu_analog_cont_ equ this word
;{
;    { '?',*func_help,  4, 'C', "ANALOG CONTROL TEST and CALIBRA
	db 63
	dw func_help_
	dw 4
	db 67
;TION" },
 dw $82+0
;    { '1',*func_analog_id,  7,  'L', "1. Read analog ID." },
	db 49
	dw func_analog_id_
	dw 7
	db 76
 dw $82+36
;    { '2',*calibrate,  9,  'L', "2. Calibrate DACs" },
	db 50
	dw calibrate_
	dw 9
	db 76
 dw $82+55
;    { '3',*func_linearity, 11,  'L', "3. DAC Linearity" },
	db 51
	dw func_linearity_
	dw 11
	db 76
 dw $82+73
;    { '\0',*func_null, 0,  0, "" }
	db 0
	dw func_null_
	dw 0
	db 0
 dw $82+90
;};
dataseg ends
dataseg segment para public 'data'
$82	db 65,78,65,76,79,71
	db 32,67,79,78,84,82
	db 79,76,32,84,69,83
	db 84,32,97,110,100,32
	db 67,65,76,73,66,82
	db 65,84,73,79,78,0
	db 49,46,32,82,101,97
	db 100,32,97,110,97,108
	db 111,103,32,73,68,46
	db 0,50,46,32,67,97
	db 108,105,98,114,97,116
	db 101,32,68,65,67,115
	db 0,51,46,32,68,65
	db 67,32,76,105,110,101
	db 97,114,105,116,121,0
	db 0
dataseg ends
;
;
;
;/*     Subttl  Analog Control Tests main entry */
;
;func_analog_cont ()
;{
	public func_analog_cont_
func_analog_cont_ proc	near
	push bp
	mov bp,sp
ifdef $84
	add sp,$84
endif
ifdef	$85
	push	di
endif
ifdef $86
	push	si
endif
;    select_command ( menu_analog_cont );
	mov	ax, offset menu_analog_cont_
	push	ax
	call	select_command_
	pop	cx
;}
$87:
ifdef $86
	pop si
endif
ifdef	$85
	pop	di
endif
	mov	sp,bp
	pop	bp
	ret
func_analog_cont_ endp
;
;
;write_dac (dac, val)
;int dac;
	public write_dac_
write_dac_ proc	near
	push bp
	mov bp,sp
ifdef $88
	add sp,$88
endif
ifdef	$89
	push	di
endif
ifdef $90
	push	si
endif
;int val;
;{
;#asm
                Extrn   UdiSegment_:word                  ;Udi memory map area

                Mov     BX,word ptr 4[BP]       ;get dac address
                Mov     AX,word ptr 6[bp]       ;get dac value
                Push    ES                      ;write data to device address
                Mov     DX,[UdiSegment_]
                Mov     ES,DX
                Mov     byte ptr ES:[BX],AL
                Mov     byte ptr ES:[308H],AL    ;Xfer
                Pop     ES
;}
$91:
ifdef $90
	pop si
endif
ifdef	$89
	pop	di
endif
	mov	sp,bp
	pop	bp
	ret
write_dac_ endp
;
	extrn	printf_:near
	extrn	crt_pos_cursor_:near
	extrn	get_analog_id_:near
	extrn	delay_ms_:near
	extrn	delay_us_:near
	extrn	select_command_:near
	extrn	keybrd_getc_:near
	extrn	keyboard_status_:near
	extrn	udi_write_dac_:near
	extrn	udi_write_bit_:near
	extrn	reset_allpro_:near
	extrn	print_menu_:near
	extrn	func_help_:near
	extrn	func_null_:near
codeseg	ends
dataseg segment para public 'data'
	extrn	analog_id_:word
dataseg ends
	end
