home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / DEV / CLOCK / RTC.INC < prev   
Text File  |  1995-04-14  |  5KB  |  91 lines

  1. ;*DDK*************************************************************************/
  2. ;
  3. ; COPYRIGHT    Copyright (C) 1995 IBM Corporation
  4. ;
  5. ;    The following IBM OS/2 WARP source code is provided to you solely for
  6. ;    the purpose of assisting you in your development of OS/2 WARP device
  7. ;    drivers. You may use this code in accordance with the IBM License
  8. ;    Agreement provided in the IBM Device Driver Source Kit for OS/2. This
  9. ;    Copyright statement may not be removed.;
  10. ;*****************************************************************************/
  11.  
  12. ;**     RTC.INC - Real Time Clock include file
  13. ;
  14. ;       This file contains equates and macros that are useful in programming
  15. ;       Real Time Clock Plus CMOS RAM device (RTC).
  16. ;
  17. ;  The following equates control or are dependent on the clock interrupt
  18. ;  frequency.  These equates come from tables provided in Motorola Spec.
  19. ;  sheets for the MC146818 (Real-Time Clock Plus RAM - RTC)
  20.  
  21. DV32K   EQU     00100000B          ; 32.768KHz Base divider rate
  22.  
  23. IN002   EQU     00001111B          ;   2Hz int rate, period = 500ms
  24. IN004   EQU     00001110B          ;   4Hz int rate, period = 250ms
  25. IN008   EQU     00001101B          ;   8Hz int rate, period = 125ms
  26. IN016   EQU     00001100B          ;  16Hz int rate, period =  62.5ms
  27. IN032   EQU     00001011B          ;  32Hz int rate, period =  31.25ms
  28. IN064   EQU     00001010B          ;  64Hz int rate, period =  15.625ms
  29. IN128   EQU     00001001B          ; 128Hz int rate, period =   7.8125ms
  30. IN256   EQU     00001000B          ; 256Hz int rate, period =   3.90625ms
  31. IN512   EQU     00000111B          ; 512Hz int rate, period =   1.953125ms
  32. IN1K    EQU     00000110B          ;  1KHz int rate, period = 976.562us
  33. IN2K    EQU     00000101B          ;  2KHz int rate, period = 488.281us
  34. IN4K    EQU     00000100B          ;  4KHz int rate, period = 244.141us
  35. IN8K    EQU     00000011B          ;  8KHz int rate, period = 122.070us
  36.  
  37. ifdef profile
  38. RABYTE  EQU     (DV32K OR IN512)        ; Alter this equ to change clock freq
  39. else
  40. RABYTE  EQU     (DV32K OR IN032)        ; Alter this equ to change clock freq
  41. endif
  42.  
  43. cmos_port       equ     70h             ; command port for cmos
  44. cmos_data       equ     71h             ; cmos data port
  45. cmos_reg_d      equ     0dh             ; cmos data port
  46. RTCCTL  EQU     070H                    ; RT/CMOS Register select port
  47. RTCDTA  EQU     071H                    ; RT/CMOS Data I/O port
  48.  
  49. RBWRIT  EQU     11010010B               ; RT/CMOS Register 'B' Init byte
  50. RBINIT  EQU     01010010B               ; RT/CMOS Register 'B' Init byte
  51.                                         ; Values for byte shown are
  52.                                         ; Bit 7 = Update inhibit
  53.                                         ; Bit 6 = Periodic interrupt enable
  54.                                         ; Bit 5 = Alarm interrupt disable
  55.                                         ; Bit 4 = Update interrupt enable
  56.                                         ; Bit 3 = Square wave disable
  57.                                         ; Bit 2 = BCD data format
  58.                                         ; Bit 1 = 24 hour time mode
  59.                                         ; Bit 0 = Daylight Savings disable
  60.  
  61. PIMASK  EQU     01000000B               ; Reg C bit mask for periodic interrupt
  62. UIMASK  EQU     00010000B               ; Reg C bit mask for update interrupt
  63.  
  64.  
  65. ; Input: al=address
  66. ; Output: al=data
  67. cmos_read_clock macro
  68.         OUT     CMOS_PORT,al            ; ADDRESS LOCATION AND DISABLE NMI
  69.         JMP     $+2                     ; I/O DELAY
  70.         IN      AL,CMOS_DATA            ; READ IN REQUESTED CMOS DATA
  71. endm
  72.  
  73. ; Input: ah=data
  74. ;        al=address
  75. cmos_write_clock macro
  76.         OUT     CMOS_PORT,al            ; ADDRESS LOCATION AND DISABLE NMI
  77.         JMP     $+2                     ; I/O DELAY
  78.         MOV     AL,ah                   ; write century
  79.         OUT     CMOS_DATA,AL            ; PLACE IN REQUESTED CMOS LOCATION
  80.         JMP     $+2                     ; I/O DELAY
  81. endm
  82.  
  83. ; set cmos RAM to read port with NMI enabled
  84. cmos_reset macro
  85.         MOV     AL,CMOS_REG_D           ; read only port/enable NMI
  86.         OUT     CMOS_PORT,AL            ; SET DEFAULT TO READ ONLY REGISTER
  87.         JMP     $+2                     ; I/O DELAY FOR WRANGLER 3 -- 06/04/87
  88.         IN      AL,CMOS_DATA            ; OPEN STANDBY LATCH
  89.         JMP     $+2                     ; I/O DELAY
  90. endm
  91.