;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Copyright (c) 2000-2002 TIMEX Corporation.
; 
; This document is the property of, and contains information proprietary to
; TIMEX Corporation.  It is to be returned upon request.  Reproduction by any
; means, disclosure, or use of its contents for other than the expressed
; purpose for which it is loaned, without the written consent of TIMEX
; Corporation, is strictly prohibited.
;
; File Name:    qc.h
;
; Module Names: none
;                   
; Purpose:      Equates used by the QC test routines.
;
; File Change History:
;
;               07/17/2000 LBC - Created for Epson 88348 Test Code.
;
; M851 Development:
;
;               01/08/2002 RBR - Reused for Epson 88349 Test Code.
;               07/02/2002 NLS - ECR# 851-20020702-397
;                                Reserved memory area starts at 0x26 not 0x24 for 88349
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



  

QCTOPOFROMADDRESS       equ     0BFFFh
QCSTARTRAMADDRESS       equ     0F000h
QCRAMSIZETOTEST         equ     00800h


;;;;;;;;;;;;;;;;;;;;;
;
; QC Build Options
;
;;;;;;;;;;;;;;;;;;;;;

;Include ROM test
QC_INCLUDE_ROM_TEST             equ     1      ;build option to include ROM test in QC test sequence

;Set a timeout for memory fail test
QC_MEM_FAIL_TIMEOUT_ENABLED     equ     1      ;use a timeout for failed memory test instead of halting it

;Include LCD Contrast Adjustment
QC_INCLUDE_CONTRAST_ADJUST      equ     1      ;include LCD contrast adjustment on the QC test sequence 

;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



QCENDDATALINKTEST       equ     0ffh            ;character sent by datalink circuit to indicate
                                                ;that the datalink test is finished

QCROMSTARTADDR          equ     00000h          ;starting ROM address 
QCROMENDADDR            equ     0bfffh          ;last ROM address
QCRAMSTARTADDR          equ     0f000h          ;starting RAM address
QCRAMENDADDR            equ     0f7ffh          ;last RAM address

QCODDADDRDATA           equ     0a5h            ;data to be written to RAM during odd address 
QCEVENADDRDATA          equ     05ah            ;data to be written to RAM during even address 
QCRAMNUM256BYTEPAGE     equ     8               ;no. of 256 byte pages in the RAM

QCEEPROMSIZE            equ     2000h           ;8kb EEPROM
QCEEPROMENDADDR         equ     1fffh           ;last address in an 8kb EEPROM
QCEEPROMSTARTADDR       equ     0000h           ;starting address of the EEPROM
QCEEPROM32BYTES         equ     32              ;no. of bytes written per WRITE instruction    
QCEEPROMSTARTPAGECOUNT  equ     0               ;first page of the 32-byte/page EEPROM

QC_RX_INIT_DATA         equ     bOER|bPER|bFER  ;data written to clear the SPI error flags 

QCRINGFREE              equ     bCW|bCCW        ;data on the ring port if ring is free
               
QCRINGCCWDIR            equ     bCW             ;data on the ring port if ring is in 
                                                ;counter-clockwise direction
QCRINGCWDIR             equ     bCCW            ;data on the ring port if ring is in 
                                                ;clockwise direction

QCRINGDEBOUNCECOUNT     equ     HWRINGDEBOUNCEREADS ;debounce count for reading the ring port

QCMASKLCDCONTRAST       equ     bLC3|bLC2|bLC1|bLC0 ;mask bits for the LCD contrast

;;;;;;;;;;;;;;;;;;
; QC variables
;;;;;;;;;;;;;;;;;;

;QCstatus flags
QCFlags                 equ     COREForegroundCommonBuffer
bQCCrownTestActive      equ     00000001b       ;1 = crown test is in progress
bQCRingTestActive       equ     00000010b       ;1 = ring test is in progress
bQCDoNotTransmitData    equ     10000000b       ; Set when data transmission is not allowed

;Old crown or switch data
QCOldCrownAndSwitchData equ     COREForegroundCommonBuffer + 1

;No. of ring pulses counted (modulo 100)
QCRingPulseCount        equ     COREForegroundCommonBuffer + 2    

;Counter for no. of times the ENTER key has been depressed
;during the switch test
QCEnterDepressCount     equ     COREForegroundCommonBuffer + 3    

;Contrast level of the LCD
QCContrastLevel         equ     COREForegroundCommonBuffer + 4  


QCOldCrownRotationData  equ     COREForegroundCommonBuffer + 5   
QCTimeoutCount          equ     COREForegroundCommonBuffer + 6 
QCTimeoutSetValue       equ     COREForegroundCommonBuffer + 7 
QCModeDepTimes          equ     COREForegroundCommonBuffer + 8 
QCTestType              equ     COREForegroundCommonBuffer + 9 
QCRotationCounters      equ     COREForegroundCommonBuffer + 10
QCPageOffsetMaxLimit    equ     COREForegroundCommonBuffer + 11
QCOldButtonData         equ     COREForegroundCommonBuffer + 14


QCEEPROMBuffer          equ     COREWorkBuffer 






;QC timeouts
QC2SECTIMEOUT           equ     4               ;count used for 2 seconds timeout
QC60SECTIMEOUT          equ     120             ;count used for 60 seconds timeout
QC4SECTIMEOUT           equ     8               ;count used for 4 seconds timeout


;QC Input events
QC_CROWN_OR_SWITCH_EVENT        equ     1
QC_TIMEOUT_DONE_EVENT           equ     2
QC_RECEIVED_SPI_DATA_EVENT      equ     3
QC_RING_PULSE_EVENT             equ     4

;QC Event arguments
QC_CW_PULSE                     equ     2
QC_CCW_PULSE                    equ     1

;QC Switch numbers
QC_ENTEREXIT_SWITCH             equ     1
QC_MODE_SWITCH                  equ     1
QC_STOPRESET_SWITCH             equ     2
QC_STARTSPLIT_SWITCH            equ     3


QCRAMTESTDATAFIRSTPASS          equ     10101010b
QCRAMTESTDATASECONDPASS         equ     01010101b
QCVALIDTESTDATA                 equ     01011010b

QCSTARTPAGEOFFSET               equ     00h
QCSTARTPAGEADDRESS              equ     00h
QCEEPROMADDRESSMAXLIMIT         equ     32768


QCNONSWITCHRELATEDTEST          equ     0
QCCROWNPOSITIONTEST             equ     3
QCCROWNRINGROTATIONTEST         equ     4
QCPUSHERDEPRESSIONTEST          equ     5
QC2SECWAIT                      equ     QC2SECTIMEOUT
QCCROWNPOSITIONTESTTIMEOUT      equ     QC60SECTIMEOUT
QCPUSHERTESTTIMEOUT             equ     QC4SECTIMEOUT
QCCROWNROTATIONTESTTIMEOUT      equ     QC60SECTIMEOUT






QCNUMBEROFCROWNPOSITIONINFO     equ     3



QCNEXTBONDOPTDISPPOSITIONOFFSET equ     6


QCMASKUNUSEDRINGDATA            equ     00000011b


IntFlagSPI                      equ     SICIntFlag
SPIControlReg                   equ     SICControlReg
SPIData                         equ     SICData
SPIPorts                        equ     SICPorts
SPIPortsDirReg                  equ     SICPortsDirReg
SPIConfigReg                    equ     SICConfigReg




QCBONDOPTIONSTARTDISP           equ     LCDMAINDMLINE1COL5
QCCROWNPOSITIONSTARTDISP        equ     LCDMAINDMLINE1COL5
QCROTATIONCOUNTERPOSITION       equ     LCDMAINDMLINE1COL20
QCCROWNROTATIONSTARTDISP        equ     LCDMAINDMLINE1COL5
QCNUMBEROFCROWNROTATIONINFO     equ     2
QCNOOFBONDOPTIONBITS            equ     4
                               
QCSTARTSPLITBUTTON              equ     3
QCSTOPRESETBUTTON               equ     2
QCMODEBUTTON                    equ     1


QCMASKNONCROWNPOSITIONINFO      equ     00001110b


QCMODEJUSTONCE                  equ     0
QCMODEDEPRESSTWICETOEXIT        equ     1

; Bypass the reserve bytes during ROM checksum calculations (specific to 88349)
QCROMTESTBYPASSADDRESS1         equ     026H
QCROMTESTBYPASSADDRESS2         equ     027H