;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; 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:    aud.h
;
; Purpose:      Audio Header File
;
; File Change History:
;
;               03/04/2002 RVD  Created File for m851
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 
; FLAGS EQUATES
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;AUDFlags

bAUDRunning             EQU 00000001B       ; 1 - audio is playing melody
                                            ; 0 - audio is not playing any melody

;bxxxxxxxxxxxxxxxxxxx   EQU 00000010B
                                            
bAUDSendMelodyDone      EQU 00000100B       ; 1 - melody done event will be sent to application at the 
                                            ;     end of melody
                                            ; 0 - melody done event will not be sent to application at the 
                                            ;     end of melody

bAUDIgnoreFirstInt      EQU 00001000B       ; used to ignore the first 32 Hz interrupt fo sych.

bAUDBuzzerActive        EQU 00010000B       ; 1 = Buzzer active 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; PATTERN FREQUENCY EQAUTES
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


AUD1KHZ                 EQU (FREQ_1170<<4)  ; 1170.3  hz 
AUD1P3KHZ               EQU (FREQ_1365<<4)  ; 1365.3  hz 
AUD1P6KHZ               EQU (FREQ_1638<<4)  ; 1638.4  hz 
AUD2KHZ                 EQU (FREQ_2048<<4)  ; 2048.0  hz 
AUD2P3KHZ               EQU (FREQ_2340<<4)  ; 2340.6  hz 
AUD2P7KHZ               EQU (FREQ_2730<<4)  ; 2730.7  hz 
AUD3P2KHZ               EQU (FREQ_3276<<4)  ; 3276.8  hz     
AUD4KHZ                 EQU (FREQ_4096<<4)  ; 4096.0  hz     
            
AUDNULL                 EQU 080H            ; 0 hz  used when the pattern is silent pattern(no sound)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; SYSTEM MELODY TYPES EQUATES   
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; these symbols is used as parameter to AUDSTARTSYSMELODY macro
; these symblos are the offsets from the start of AUDMelodyAddressTable to the
; start of the melody address.

AUDSWBEEPMELODY         EQU 0               ; Switch beep melody offset             
AUDHOURCHIMEMELODY      EQU 2               ; Hour Chime melody offset              
AUDALARMMELODY          EQU 4               ; Alarm melody offset                   
AUDAPPOINTMENTMELODY    EQU 6               ; Appointment melody offset
AUDTIMERMELODY          EQU 8               ; Timer Melody offset                   
AUDINTERVALTIMERMELODY  EQU 10              ; Interval Timer Melody offset
AUDHALFTIMERMELODY      EQU 12              ; Half timer melody offset
AUDCOMMERRORMELODY      EQU 14              ; Communication Error melody offset     
AUDCUSTOMMELODY         EQU 16              ; Custom melody offset


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; MISCELLANEOUS EQUATES    
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


AUDENDMELODYPATTERN         EQU 0FFH                ; end of melody pattern
AUDCONTINUEPATTERN          EQU 0FEH                ; patten use to contacnate back to back melodies


; MELODYDONEEVENT EQUATES

AUDSENDMELODYDONEEVENT      EQU bAUDSendMelodyDone  ; send MELODYDONEEVENT at the end of melody to application
AUDNOMELODYDONEEVENT        EQU 00H                 ; do not send MELODYDONEEVENT at the end melody to applicaion


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; AUDIO VARIABLES DEFINED IN LCD RAM    
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

AUDFlags                EQU AUDBaseAddress      ; audio general flags (1-byte)
AUDMelodyAddressTable   EQU (AUDBaseAddress+1)  ; table for melodies addresses (20-byte)

; The melodies addresses stored in this table must be in the following order:
;
;   - Switch beep melody address              2bytes
;   - Hour Chime melody address               2bytes
;   - Alarm melody address                    2bytes
;   - Timer Melody address                    2bytes
;   - Interval Timer Melody address           2bytes
;   - Half Timer Melody address               2bytes
;   - Communication Error melody address      2bytes
;   - Custom melody address                   2bytes 
;
; Note: These addresses is set to the ROM addresses of melodies at the POR by audInit,
;       and can be changed to RAM addresses of melodies during PC communication.


AUDMelodyAddress                    EQU (AUDBaseAddress+19)     ; the start address of the playing melody (2-byte)
AUDRepeatCounter                    EQU (AUDBaseAddress+21)     ; holds the number of repetitions of the playing melody (1-byte)
AUDPatternCounter                   EQU (AUDBaseAddress+22)     ; number of the current pattern of the playing melody (1-byte)
AUDDurationCounter                  EQU (AUDBaseAddress+23)     ; the duration counter of the current pattern of 
                                                                ; the playing melody, the duration could be
                                                                ; from 0 to 15 which is the number of 1/32 sec periods. (1-byte)
AUDPatternFreq                      EQU (AUDBaseAddress+24)     ; the frequecy of the current pattern of the playing melody (1-byte)
AUDPlayingMelodyOffset              EQU (AUDBaseAddress+25)     ; the offset of the current playing melody. (1-byte)



; Base address for Custom Popup Melodies. This can be a maximum of 16 bytes long. This table
; contains the actual melody table data loaded from the PC.  If the PC does not utilize the
; memory allocated for ram based audio melodies (offset AUDPopupCustomMelody+16 with max size of 20),
; then the system can have a maximum of 36 bytes for each melody stored in EEPROM.

AUDPopupCustomMelody                EQU (AUDBaseAddress+26)
