# HG changeset patch # User boisy # Date 1093000318 0 # Node ID f389c6bca482228f432f1d931155f5a32bd7c30b # Parent 00d6e3a479876c4344cda100e053c17a69278b44 New clock2_*.asm files split from single clock2.asm for more source clarity diff -r 00d6e3a47987 -r f389c6bca482 level1/modules/clock2_disto2.asm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/level1/modules/clock2_disto2.asm Fri Aug 20 11:11:58 2004 +0000 @@ -0,0 +1,137 @@ +******************************************************************** +* Clock2 - Disto 2-N-1 RTC Driver +* +* $Id$ +* +* Edt/Rev YYYY/MM/DD Modified by +* Comment +* ------------------------------------------------------------------ +* 1 2004/08/18 Boisy G. Pitre +* Separated clock2 modules for source clarity. + + nam Clock2 + ttl Disto 2-N-1 RTC Driver + + ifp1 + use defsfile + endc + +tylg set Sbrtn+Objct +atrv set ReEnt+rev +rev set $00 +edition set 1 + +RTC.Base equ $FF50 Base address of clock + + mod eom,name,tylg,atrv,JmpTable,RTC.Base + +name fcs "Clock2" + fcb edition + + IFNE MPIFlag +SlotSlct fcb MPI.Slot-1 Slot constant for MPI select code + ENDC + +JmpTable + rts RTC Init + nop + nop + bra GetTime RTC Get Time + nop + bra SetTime RTC Set Time + +GetTime pshs a,cc Save old interrupt status and mask IRQs + bsr RTCPre + + bsr GetVal Get Year + bsr GetVal Get Month + bsr GetVal Get Day + decb ldb #5 + stb 2,x + decb + lda ,x + anda #3 + bsr GetVal1 Get Hour + bsr GetVal Get Minute + bsr GetVal Get Second + +RTCPost clr >$FFD9 2 MHz (Really should check $A0 first) + puls cc,b + + IFNE MPIFlag + stb >MPI.Slct Restore saved "currently" selected MPak slot + ENDC + + clrb + rts + +RTCPre orcc #IntMasks + + IFNE MPIFlag + ldb >MPI.Slct Save currently selected MPak slot on stack + stb 3,s + andb #$F0 + orb >SlotSlct,pcr Get slot to select + stb >MPI.Slct Select MPak slot for clock + ENDC + + ldy #D.Time + ldx M$Mem,pcr + clr 1,x + ldb #12 + clr >$FFD8 1 MHz + rts + +GetVal stb 2,x + decb + lda ,x read tens digit from clock + anda #$0f +GetVal1 pshs b save b + ldb #10 + mul multiply by 10 to get value + stb ,y save 10s value + puls b set up clock for ones digit + stb 2,x + decb + lda ,x read ones digit from clock + anda #$0f + adda ,y add ones + tens + sta ,y+ store clock value into time packet + rts + + +SetTime pshs a,cc + lbsr RTCPre Initialize + + bsr SetVal Set Year + bsr SetVal Set Month + bsr SetVal Set Day + ldd #$0805 $08 in A, $05 in B + bsr SetVal1 Set Hour (OR value in A ($08) with hour) + bsr SetVal Set Minute + bsr SetVal Set Second + + lbra RTCPost Clean up + return + +SetVal clra +SetVal1 stb 2,x Set Clock address + decb + pshs b + ldb ,y+ Get current value +DvLoop subb #10 Get Tens digit in A, ones digit in B + bcs DvDone + inca + bra DvLoop +DvDone addb #10 + sta ,x Store tens digit + tfr b,a + puls b Get back original clock address + stb 2,x + decb + sta ,x Store ones digit + rts + + emod +eom equ * + end + diff -r 00d6e3a47987 -r f389c6bca482 level1/modules/clock2_disto4.asm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/level1/modules/clock2_disto4.asm Fri Aug 20 11:11:58 2004 +0000 @@ -0,0 +1,152 @@ +******************************************************************** +* Clock2 - Disto 4-N-1 RTC Driver +* +* $Id$ +* +* Edt/Rev YYYY/MM/DD Modified by +* Comment +* ------------------------------------------------------------------ +* 1 2004/08/18 Boisy G. Pitre +* Separated clock2 modules for source clarity. + + nam Clock2 + ttl Disto 4-N-1 RTC Driver + + ifp1 + use defsfile + endc + +tylg set Sbrtn+Objct +atrv set ReEnt+rev +rev set $00 +edition set 1 + +RTC.Base equ $FF50 Base address of clock + + mod eom,name,tylg,atrv,JmpTable,RTC.Base + +name fcs "Clock2" + fcb edition + + IFNE MPIFlag +SlotSlct fcb MPI.Slot-1 Slot constant for MPI select code + ENDC + +JmpTable + lbra Init + bra GetTime + nop + lbra SetTime + +GetTime equ * + IFNE MPIFlag + pshs cc Save old interrupt status and mask IRQs + orcc #IntMasks + ldb >MPI.Slct Save currently selected MPak slot on stack + pshs b + andb #$F0 + orb >SlotSlct,pcr Select MPak slot for clock + stb >MPI.Slct + ENDC + + ldx M$Mem,pcr + ldy #D.Time Start with seconds + + ldb #11 + bsr GetVal Get Year + bsr GetVal Get Month + bsr GetVal Get Day + lda #3 Mask tens digit of hour to remove AM/PM bit + bsr GetVal1 Get Hour + bsr GetVal Get Minute + bsr GetVal Get Second + + IFNE MPIFlag + puls b Restore saved "currently" selected MPak slot + stb >MPI.Slct + puls cc,pc Restore previous IRQ status + ELSE + rts No MPI, don't need to mess with slot, CC + ENDC + +GetVal lda #$0f Mask to apply to tens digit +GetVal1 stb 1,x + decb + anda ,x read ones digit from clock + pshs b save b + ldb #10 + mul multiply by 10 to get value + stb ,y Add to ones digit + puls b + stb 1,x + decb + lda ,x read tens digit from clock and mask it + anda #$0f + adda ,y + sta ,y+ + rts + + + +SetTime pshs cc + orcc #IntMasks + + IFNE MPIFlag + ldb >MPI.Slct Save currently selected MPak slot + pshs b + andb #$F0 + orb >SlotSlct,pcr Get slot to select + stb >MPI.Slct Select MPak slot for clock + ENDC + + ldy #D.Time+6 + ldx M$Mem,pcr + clrb + bsr SetVal Set Second + bsr SetVal Set Minute + bsr SetVal Set Hour + bsr SetVal Set Day + bsr SetVal Set Month + bsr SetVal Set Year + + IFNE MPIFlag + puls b Restore old MPAK slot + stb >MPI.Slct + ENDC + + puls cc + clrb No error + rts + +SetVal clr ,-s Create variable for tens digit + lda ,-y Get current value +DvLoop suba #10 Get Tens digit on stack, ones digit in A + bcs DvDone + inc ,s + bra DvLoop +DvDone adda #10 + stb 1,x Set Clock address + incb + sta ,x Store ones digit + stb 1,x + incb + puls a + sta ,x Store tens digit + rts + + +Init +* Disto 4-N-1 RTC specific initialization + ldx M$Mem,pcr + ldd #$010F Set mode for RTC chip + stb 1,x + sta ,x + ldd #$0504 + sta ,x + stb ,x + rts + + emod +eom equ * + end + diff -r 00d6e3a47987 -r f389c6bca482 level1/modules/clock2_ds1315.asm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/level1/modules/clock2_ds1315.asm Fri Aug 20 11:11:58 2004 +0000 @@ -0,0 +1,146 @@ +******************************************************************** +* Clock2 - Dallas Semiconductor DS1315 RTC Driver +* +* $Id$ +* +* The Burke & Burke HD Controller as well as Cloud-9's products +* use the DS1315. +* +* Edt/Rev YYYY/MM/DD Modified by +* Comment +* ------------------------------------------------------------------ +* 1 2004/08/18 Boisy G. Pitre +* Separated clock2 modules for source clarity. + + nam Clock2 + ttl Dallas Semiconductor DS1315 RTC Driver + + ifp1 + use defsfile + endc + +tylg set Sbrtn+Objct +atrv set ReEnt+rev +rev set $00 +edition set 1 + + IFNE BNB +RTC.Base equ $FF5C In SCS* Decode + ELSE +RTC.Base equ $FF7C Fully decoded RTC + ENDC +RTC.Zero equ -4 Send zero bit by writing this offset +RTC.One equ -3 Send one bit by writing this offset +RTC.Read equ 0 Read data from this offset + + + mod eom,name,tylg,atrv,JmpTable,RTC.Base + +name fcs "Clock2" + fcb edition + + IFNE MPIFlag +SlotSlct fcb MPI.Slot-1 Slot constant for MPI select code + ENDC + +JmpTable + rts + nop + nop + bra GetTime + nop + +SetTime pshs u,y,cc + leay SendBCD,pcr Send bytes of clock + bra TfrTime + +GetTime pshs u,y,cc + leay ReadBCD,pcr Read bytes of clock + +TfrTime orcc #IntMasks turn off interrupts + ldu M$Mem,pcr Get base address + + IFNE MPIFlag + ldb >MPI.Slct Select slot + pshs b + andb #$F0 + orb SlotSlct,pcr + stb >MPI.Slct + ENDC + + lbsr SendMsg Initialize clock + ldx #D.Sec + ldb #8 Tfr 8 bytes + +tfrloop jsr ,y Tfr 1 byte + + bitb #$03 + beq skipstuf Skip over day-of-week, etc. + leax -1,x +skipstuf decb + bne tfrloop + + IFNE MPIFlag + puls b + stb >MPI.Slct restore MPAK slot + ENDC + + puls u,y,cc,pc + +ClkMsg fcb $C5,$3A,$A3,$5C,$C5,$3A,$A3,$5C +* Enable clock with message $C53AA35CC53AA35C +SendMsg lda RTC.Read,u Send Initialization message to clock + leax xx70 then its 19xx + bhi not20 + adda #100 + sta -1,y +not20 bsr getval month + bsr getval day + lda #7 AM/PM mask + stb 1,x + anda ,x + bitb #4 + pshs cc + anda #3 + bsr getval1 + puls cc + beq AM + lda #12 convert to 24hr time as it is PM + adda -1,y + sta -1,y +AM bsr getval minute +* and now fall through into get second +getval lda #$0f + stb 1,x + anda ,x +getval1 decb + pshs b + ldb #10 + mul + stb ,y + puls b + stb 1,x + decb + lda ,x + anda #$0f + adda ,y + sta ,y+ + rts + + emod +eom equ * + end + diff -r 00d6e3a47987 -r f389c6bca482 level1/modules/clock2_smart.asm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/level1/modules/clock2_smart.asm Fri Aug 20 11:11:58 2004 +0000 @@ -0,0 +1,422 @@ +******************************************************************** +* Clock2 - Dallas Semiconductor 1216 RTC Driver +* +* $Id$ +* +* Dallas Semiconductor DS1216 SmartWatch +* +* Wakeup sequence $C5 3A A3 5C C5 3A A3 5C +* +* Time byte sequence in Binary Coded Decimal +* +* byte bit 7 6 5 4 3 2 1 0 +* 0 | 0.1 sec MSB | 0.1 sec LSB | +* 1 | 0 | 10 sec | seconds | +* 2 | 0 | 10 min | minutes | +* 3 |12/24| 0 | AM/PM | HR | Hour | +* | 10 HR | Hour | +* 0=12, 1=24 0=AM, 1=PM +* 4 | 0 | 0 | OSC |RESET| 0 | Weekday | +* 5 | 0 | 0 | 10 Date | Date | +* 6 | 0 | 0 | 0 |10 Month| Month | +* 7 | 10 Year | Year | +* +* OSC = 1; turns off clock to save battery. RESET not used in Coco circuit. +* +* When inserted in external ROM socket, the clock is addressed at: +* $C000 bit = 0 +* $C001 bit = 1 +* $C004 read byte to wakeup then send wakeup sequence to bit toggles. +* Then either read or send time. +* +* +* Edt/Rev YYYY/MM/DD Modified by +* Comment +* ------------------------------------------------------------------ +* 2004/07/28 Robert Gault +* Complete rewrite of SmartWatch segment which would never have worked. +* See previous versions for old code if desired. Routine now will search +* through all MPI slots to find clock and accept either AM/PM or military +* time. User notified if clock not found or data memory not available. +* +* Initialization routine contains code that bypasses OS-9 system calls to +* acquire needed low RAM that can't become ROM. This type of code is not +* recommended in most cases but nothing else was usable. +* 2004/07/31 Robert Gault +* Added a settime routine and changed "no clock found" routine. If the +* clock is not found, the D.Time entries are cleared but no message is sent. +* Date -t will never get passed one minute. +* 2004/07/31 Rodney Hamilton +* Improved RTCJVEmu code, conditionalized RTC type comments. +* 2004/08/2 Robert Gault +* Alphabetized all clock listings so things can be found much more easily. +* Placed list of clock types at beginning of source for record keeping. +* +* 1 2004/08/18 Boisy G. Pitre +* Separated clock2 modules for source clarity. + + nam Clock2 + ttl Dallas Semiconductor 1216 RTC Driver + + ifp1 + use defsfile + endc + +tylg set Sbrtn+Objct +atrv set ReEnt+rev +rev set $00 +edition set 1 + +RTC.Base equ $C000 clock mapped to $C000-$DFFF; $FFA6 MMU slot +RTC.Zero equ 0 Send zero bit +RTC.One equ 1 Send ones bit +RTC.Read equ 4 +*D.SWPage on system DP; Refer to os9defs. +D.RTCSlt equ 0 on SmartWatch ?data? page +D.RTCFlg equ 1 on SW page +D.RTCMod equ 2 +D.Temp equ 3 on SW page, holds "clock" data +D.Start equ 4 on SW page, code starts here + + + mod eom,name,tylg,atrv,JmpTable,RTC.Base + +name fcs "Clock2" + fcb edition + + IFNE MPIFlag +SlotSlct fcb MPI.Slot-1 Slot constant for MPI select code + ENDC + +JmpTable + lbra Init + bra GetTime + nop + lbra SetTime + +GetTime pshs cc,d,x,y,u + orcc #$50 + lda D.SWPage + clrb + tfr d,u point to working space + lda $FF7F + pshs a + lda D.RTCSlt,u info for MPI slot + sta $FF7F + clr D.RTCMod,u set for read time + jsr D.Start,u jsr to it + lbra exit + + + +* This set time routine forces military time. It can't turn off clock but can +* be used as a timer if time set to 0:0:0 hr:min:sec +SetTime pshs cc,d,x,y,u + orcc #$50 + lda D.SWPage + clrb + tfr d,u point to working space + lda $FF7F + pshs a + lda D.RTCSlt,u info for MPI slot + sta $FF7F + lda #-1 + sta D.RTCMod,u indicate set time rather than read + IFGT Level-1 + ldx #D.Slice + ELSE + ldx #D.TSec + ENDC + tfr u,y get location of safe region + leay >D.Start+alrtend-reloc,y point to end of wakeup code + lda ,-x get D.Time data and store it + ldb #4 convert tenths sec, sec, min, hours + bsr binbcd to binary coded decimal + IFGT Level-1 + lda D.Daywk + ELSE + clra + ENDC + sta ,y+ set day of week if present + lda ,x + ldb #3 convert day of month, month, year + bsr binbcd to BCD + jsr >D.Start,u send data to clock + lbra exit + +binbcd pshs b +bcd3 clrb +bcd1 cmpa #10 + bcs bcd2 + addd #$f610 decrease bin regA by 10 add bcd $10 to regB + bra bcd1 +bcd2 pshs a + addb ,s+ add in remainder; BCD = binary when less than 10 + stb ,y+ place in message to clock + lda ,-x get next byte of D.Time + dec ,s decrease counter + bne bcd3 + puls b,pc + +* This becomes D.Start +reloc equ * + IFGT Level-1 + lda D.HINIT + anda #$CC + sta $FF90 + ENDC + ldb $FFA6 choose to use normal location + pshs b + ldb #$3E + stb $FFA6 reset MMU for clock + sta $FFDE + ldd #RTC.Base + tfr a,dp DP now points to clock + tst D.RTCMod,u are we reading the clock or setting it? + beq findclk go if reading + lbsr wakeup we are setting a found clock + lbra found +findclk lda #-1 + sta alrtend,pcr + lbsr wakeup wakeup the clock + ldx #D.Sec one incoming byte dropped + lda #8 bytes to get + pshs a +L0050 ldb #8 bits to get +L0052 lsr