;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Copyright (c) 2001-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:    hwVars.h
;
; Module Names: None
;                                  
; Purpose:      Definition of Hardware Variables and Flags used in m851 
;
; File Change History:
;
;               02/28/2002 RVD - Created hwVars.h for m851
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Hardware variables - Keyboard
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Top Pushers
HWKBDTopData:                   EQU HWBaseAddress           ; Storage for debounced top pusher inputs (1-byte)
HWKBDReleaseData:               EQU (HWBaseAddress + 1)     ; Storage for release event corresponding to 
                                                            ; current depression. (1-byte)
HWKBDTopDebounceDelay:          EQU (HWBaseAddress + 2)     ; Counter for time between debounce reads of 
                                                            ; top pusher input port. Set to two values,
                                                            ; HWTOPDEBOUNCEDEALYNOHSO or 
                                                            ; HWTOPDEBOUNCEDEALYWITHHSO (1-byte)


; Crown
HWKBDCrownData:                 EQU HWKBDTopData            ; Storage for debounced crown data

; Ring
HWKBDRingData:                  EQU HWKBDTopData            ; Storage for debounced ring data
HWKBDDebounceCounter:           EQU (HWBaseAddress + 3)     ; Storage for ring debounce time. (1-byte)
                                                            ; Value loaded is based on bond options.
HWCWCounter:                    EQU (HWBaseAddress + 4)     ; Number of CW pulses accumulated between (1-byte) 
                                                            ; 16Hz interrupts when in pulse mode.
HWCCWCounter:                   EQU (HWBaseAddress + 5)     ; Number of CCW pulses accumulated between (1-byte)
                                                            ; 16Hz interrupts when in pulse mode.
HWKBDRingStuckCounter:          EQU (HWBaseAddress + 6)     ; Counts how long ring is stuck (1-byte)
                                                            ; 0 = Not Stuck
                                                            ; 1..7  = Stuck
                                                            ; 8 = Reached limit - go to 8Hz monitor
HWKBDRingStuckData:             EQU (HWBaseAddress + 7)     ; Stores which Ring switch is stuck,
                                                            ; either CW or CCW. (1-byte)
HWKBDRingEdgeTrackingStatus:    EQU (HWBaseAddress + 8)     ; Ring edge status flags (1-byte)
                                                            ; See hwvars.h for definitions                                              
HWKBDRingEdgeTrackTimer:        EQU (HWBaseAddress + 9)     ; Timer to calculate if pulse is within acceptable 
                                                            ; width limits. (1-byte)
; Other
HWKBDRingCrownCompBuffer:       EQU (HWBaseAddress + 10)    ; Temporary storage for Ring or Crown comparison
                                                            ; buffer. The old value of the comparison register
                                                            ; is stored so that it can be XORed with the 
                                                            ; debounced data so we can detect which input caused 
                                                            ; the interrupt.
HWKBDCoreData:                  EQU (HWBaseAddress + 11)    ; Communication buffer between the core and the 
                                                            ; hardware - used to transfer events from the hardware
                                                            ; to the core. (1-byte)
HWKBDTracking:                  EQU HWKBDRingEdgeTrackingStatus ; Crown and top pusher tracking status flags.
                                                            ; See hwvars.h for definitions
HWKBDPullUpCounter:             EQU HWKBDTopDebounceDelay   ; Counter for Delay loop for pull-up re-enabling.
                                                            ; When pullups are reactived, it take a certain 
                                                            ; amount of time before the sampled data is valid. 
                                                            ; This serves as a loop counter to allow a delay 
                                                            ; before reading data.
HWKBDInterruptRegister          EQU MISCBlock1BaseAddress   ; Storage for the current value of the Kxx port
                                                            ; interrupt enable/disable control register.
HWKBDELDepIgnoreCounter			EQU	MISCBlock2BaseAddress   ; Counter for the 500mS delay after a HOME event
															; during which an EL depression is ignored.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Hardware variables - Stopwatch
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
HWSTPDataBuffer:                EQU (HWBaseAddress + 12)    ; Temporary storage for raw stopwatch 
                                                            ; 100s data. BCD [00-99] (1-byte)
HWSTP100sDataBuffer:            EQU (HWBaseAddress + 13)    ; Buffer for stopwatch 100s data used to update  
                                                            ; resources. BCD [00-99] (1-byte)
HWSTPSecondsDataBuffer:         EQU (HWBaseAddress + 14)    ; Buffer for stopwatch seconds data used to update 
                                                            ; resources. BCD [00-59] (1-byte)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Hardware variables - General Purpose
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
HWStatusFlag:                   EQU (HWBaseAddress + 15)    ; Storage for miscellaneous hardware flags. (1-byte)
HWCLK16Control:                 EQU HWStatusFlag            ; Control 32Hz (pseudo 16Hz) ISR enabling/disabling.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Hardware variables - Real Time Clocks
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
HW1HzRTC:                       EQU (HWBaseAddress + 16)    ; Eight bit counter for 1Hz interrupt. (1-byte)
                                                            ; Acts as a pseudo real-time clock.
                                                            ; BCD math accessed, so values are 0-99.

; EEPROM access variables
HWEEAddrLo:                     EQU (HWBaseAddress + 17)    ; Lo byte of EEPROM address to be accessed (1-byte)
HWEEAddrHi:                     EQU (HWBaseAddress + 18)    ; Hi byte of EEPROM address to be accessed (1-byte)
HWEEAddr:                       EQU HWEEAddrLo              ; Base address of variable for 16 bit access

HWRAMAddrLo:                    EQU (HWBaseAddress + 19)    ; Lo byte of E0C88 RAM to be accessed (1-byte)
HWRAMAddrHi:                    EQU (HWBaseAddress + 20)    ; Hi byte of E0C88 RAM to be accessed (1-byte)
HWRAMAddr:                      EQU HWRAMAddrLo             ; Base address of variable for 16 bit access

HWSizeLo:                       EQU (HWBaseAddress + 21)    ; Lo byte of size of EEPROM memory to be 
                                                            ; written to (1-byte)
HWSizeHi:                       EQU (HWBaseAddress + 22)    ; Hi byte of size of EEPROM memory to be 
                                                            ; written to (1-byte)
HWSize:                         EQU HWSizeLo                ; Base address of variable for 16 bit access

HWEEPROMPageSize                EQU (HWBaseAddress + 23)    ; Page size of EEPROM used (32/64/128). (1-byte)
                                                            ; Stored as a HEX number.
HWEEPROMPageMask                EQU (HWBaseAddress + 24)    ; Address mask corrresponding to size of 
                                                            ; EEPROM used (1FH/3FH/7FH). (1-byte)
                                                            ; Stored as a HEX number.
; Note that currently, the 128 byte page is unused.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Hardware variables - Bond Options/ICB Storage
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
HWBondOptions:                  EQU (HWBaseAddress + 25)    ; Bond Option storage (1-byte)

; Information Control Block (ICB) Variables
; These are the Bond Option functions which are stored in the EEPROM.

HWICBRingProcessingInfo:        EQU (HWBaseAddress + 26)    ; Storage for additional ring processing information
                                                            ; eg, Ring or Crown, etc. 
HWICBFlashPartInfo:             EQU HWICBRingProcessingInfo ; Storage for data to tell us if micro is a 
                                                            ; Flash or Masked part.
HWICBLCDContrastSetting:        EQU (HWBaseAddress + 27)    ; Storage for LCD contrast setting. (1-byte)
HWICBLowBattDetectionLevel:     EQU HWICBLCDContrastSetting ; Storage for Low Battery Level threshold.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Hardware variables - Serial Transmission to USB Microprocesser
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
HWSerialData                    EQU (HWBaseAddress + 28)    ; Temporary storage for serial input data

; Calculate RAM usage by this module
HWVARIABLESIZE                  EQU 29                                          

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Hardware Bits 
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;HWKBDRingEdgeTrackingStatus                                ; Ring edge status flags
;HWKBDTracking                                              ; Crown and top pusher tracking status. 
    bHWKBDRingEdgeTracking      EQU     00000001B           ; Ring edge tracking flag -
                                                            ; 1 = RingEdgeTrackTimer has not expired
                                                            ;     OK to pass Ring Edge Trailing to Core
                                                            ; 0 = Timer expired or canceled
                                                            ;     Not OK to pass Ring Edge Trailing to Core
    bHWKBDRingEdgeTrackLeading  EQU     00000010B           ; Ring edge tracking Leading flag -
                                                            ; 1 = RingEdgeTrackTimer is tracking a Leading time

    bHWKBDHomeTracking          EQU     00000100B           ; Home tracking flag 
                                                            ; 0 = Not tracking a home event, so home pull-up and
                                                            ;     interrupt de-activated.
                                                            ; 1 = Tracking a home event, so home pull-up and
                                                            ;     interrupt activated.
    bHWKBDReleaseTracking       EQU     00001000B           ; Release Tracking Flag
                                                            ; 0 = Not tracking a release, ie, top pusher was not
                                                            ;     depressed, or depression was canceled 
                                                            ; 1 = Tracking a release, ie, top pusher was 
                                                            ;     depressed, and HWKBDReleaseData contains the
                                                            ;     corresponding release event. 
    bHWKBDELReleaseTracking     EQU     00010000B           ; EL Release Tracking Flag
                                                            ; 0 = Not tracking an EL release, ie, EL was not
                                                            ;     depressed, or depression was canceled 
                                                            ; 1 = Tracking an EL release, ie, EL was 
                                                            ;     depressed. 
    bHWKBDHomeResistorTracking  EQU     00100000B           ; HOME resisitor Tracking Flag
                                                            ; Used ONLY during crown debounce to kill HOME resistor
                                                            ; 0 = Home resistor not activated before ISR 
                                                            ; 1 = Home resistor active before ISR 

;HWICBRingProcessingInfo:                                   ; Storage for additional ring processing information
                                                            ; eg, Ring or Crown, etc.
;HWICBFlashPartInfo:                                        ; Storage for data to tell us if micro is a 
                                                            ; Flash or Masked part.
    bHWICBRingSet               EQU     00000010B           ; Crown or Ring Set Selection
                                                            ; 0 = Watch is a CrownSet Model
                                                            ; 1 = Watch is a RingSet Model
    bHWICBLongDebounce          EQU     00000100B           ; CW/CCW Debounce time
                                                            ; 1 = Long Debounce (roughly 2mS)
                                                            ; 0 = Short Debounce (roughly 1mS)
    bHWICBFlashMicro            EQU     00001000B           ; Flash or Masked part Micro processor
                                                            ; 1 = Flash Part
                                                            ; 0 = Maked Part

;HWStatusFlag:                                              ; Storage for miscellaneous hardware flags.
;HWCLK16Control:                                            ; Control 32Hz (pseudo 16Hz) melody is 8Hz
    bHWSVDBatteryLevelLow       EQU     00000001B           ; Battery Level Indicator flag.
                                                            ; 1 = Battery level is LOW.
                                                            ; 0 = Battery level is OK.
    bHWEEHighCurrentState       EQU     00000010b           ; EEPROM high current condition.
                                                            ; Flag is used for EEPROM/Buzzer/EL power management
                                                            ; 1 = EEPROM current usage is HIGH, eg, writing
                                                            ; 0 = EEPROM current usage is LOW, eg, standby.
                                                            ; Currently, the READ current is considered to be LOW.                                              

    bHWEEPROMPoweredUp          EQU     00000100B           ; Indicates power condition of EEPROM
                                                            ; 1 = EEPROM is powered up
                                                            ; 0 = EEPROM is NOT powered up.
    
    bHWCLK16Ring                EQU     00001000B           ; PulseMode enab 1 = En, 0 = Dis /bCoreSetMode
                                                            ;                             /bCorePulseMode
    bHWCLK32Alert               EQU     00010000B           ; Alert Start 1 = Run 
                                                            ;             0 = Stopped
                                                        
    bHWLampRequestOn            EQU     00100000B           ; Core Lamp request flag
                                                            ; 1 = CORE has request Lamp is on
                                                            ; 0 = CORE has requested lamp is OFF
    bHWLampPopupRequestOn       EQU     01000000B           ; Popup Lamp request flag
                                                            ; 1 = Popup has request Lamp is on
                                                            ; 0 = Popup no longer needs the lamp.
    bHWCLK32ELIgnoreDepCounterON 	EQU     10000000B       ; Status flag for the 500mS timeout which disallows 
															;  EL depressions after the HOME event for 500mS
                                                            ; 1 = Timer is ACTIVE
                                                            ; 0 = Timer is INACTIVE.


