1 ; Various functions: init, (RAM) disk, mmc, timer
2 ; This file needs to get split up.
4 ; Copyright (C) 2010 Sprite_tm
5 ; Copyright (C) 2010 Leo C.
7 ; This file is part of avrcpm.
9 ; avrcpm is free software: you can redistribute it and/or modify it
10 ; under the terms of the GNU General Public License as published by
11 ; the Free Software Foundation, either version 3 of the License, or
12 ; (at your option) any later version.
14 ; avrcpm is distributed in the hope that it will be useful,
15 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ; GNU General Public License for more details.
19 ; You should have received a copy of the GNU General Public License
20 ; along with avrcpm. If not, see <http://www.gnu.org/licenses/>.
26 ; ------------------- DRAM Refresh Interrupt --------------------
30 ; Refresh interupt; exec 2 cbr cycles
37 cbi P_CAS,ram_cas ;2 1| 1|
39 cbi P_RAS,ram_ras ;2 |0 1|
43 sbi P_RAS,ram_ras ;2 |0 |0
45 dram_wait DRAM_WAITSTATES-1 ; | |
47 cbi P_RAS,ram_ras ;2 |0 1|
49 sbi P_CAS,ram_cas ;2 |0 |0
51 sbi P_RAS,ram_ras ;2 1| |0
58 ;Print a unsigned lonng value to the uart
59 ; temp4:temp3:temp2:temp = value
70 clr yl ;yl = stack level
72 ultoa1: ldi z_flags, 32 ;yh = temp4:temp % 10
73 clr yh ;temp4:temp /= 10
85 cpi yh, 10 ;yh is a numeral digit '0'-'9'
89 cp temp,_0 ;Repeat until temp4:temp gets zero
96 ultoa5: cpi yl,3 ; at least 3 digits (ms)
102 ultoa6: pop temp ;Flush stacked digits
117 ;Prints temp2:temp in hex to the uart
125 ;Prints temp in hex to the uart
132 ;Prints the lower nibble
145 ;Prints the zero-terminated string following the call statement.
195 ; ****************************************************************************
197 ; ------------- system timer 1ms ---------------
210 ; don't change order here, clock put/get depends on it.
211 cntms_out: ; register for ms
213 utime_io: ; register for uptime.
220 .equ timer_size = timer_top - timer_base
222 .equ clkofs = cnt_1ms-cntms_out
223 .equ timerofs = cnt_1ms-timer_ms
228 ; Timer/Counter1 Compare Match B interrupt
242 #if DRAM_8BIT /* Implies software uart */
268 ldi zl,high(1000) ;doesn't change flags
301 sts delay_timer1,temp
303 lds temp,delay_timer1
312 subi temp2,TIMER_MSECS
313 brcs clkget_end ;Port number in range?
315 breq clkget_copy ;lowest byte requestet, latch clock
317 brsh clkget_end ;Port number to high?
343 brcs clkput_end ;Port number in range?
348 cpi temp,starttimercmd
350 cpi temp,quitTimerCmd
352 cpi temp,printTimerCmd
367 breq clkput_copy ;lowest byte requestet, latch clock
369 brsh clkput_end ;Port number to high?
414 ; put ms on stack (16 bit)
449 printstring "Timer running. Elapsed: "
481 printstring "Uptime: "
497 ; --------------- Debugging stuff ---------------
498 ; Print a line with the Z80 main registers
510 ldiw z,zflags_to_ch*2
516 cpi temp,' ' ; Test if no flag
519 ldi temp,' ' ; Flag not set