Functions | |||
![]() | ![]() | void | systime_handler (void) |
![]() | ![]() | system time handler for the 16bit timer OCIA irq. More... | |
![]() | ![]() | __asm__ (" .text .align 1 .global _systime_handler .global _systime_tm_return _systime_handler: ; r6 saved by ROM push r0 ; both motors & task ; switcher need this reg. ; increment system timer mov.w @_sys_time+2,r6 ; LSW -> r6 add.b #0x1,r6l ; 16 bit: add 1 addx #0x0,r6h mov.w r6,@_sys_time+2 bcc sys_nohigh ; speedup for 65535 cases mov.w @_sys_time,r6 ; MSW -> r6 add.b #0x1,r6l addx #0x0,r6h mov.w r6,@_sys_time sys_nohigh: " " jsr _dm_handler ; call motor driver " " jsr _dsound_handler ; call sound handler " " mov.w @_lnp_timeout_counter,r6 ; check LNP timeout counter subs #0x1,r6 mov.w r6,r6 ; subs doesn't change flags! bne sys_noreset jsr _lnp_integrity_reset mov.w @_lnp_timeout,r6 ; reset timeout sys_noreset:mov.w r6,@_lnp_timeout_counter " " jsr _dkey_handler " " mov.b @_lcd_refresh_counter,r6l dec r6l bne sys_norefresh jsr @lcd_refresh " " jsr _vis_handler " " mov.b @_lcd_refresh_period,r6l sys_norefresh:mov.b r6l,@_lcd_refresh_counter " " mov.b @_tm_current_slice,r6l dec r6l bne sys_noswitch ; timeslice elapsed? mov.w @_tm_switcher_vector,r6 jsr @r6 ; call task switcher _systime_tm_return: mov.b @_tm_timeslice,r6l ; new timeslice sys_noswitch:mov.b r6l,@_tm_current_slice " " pop r0 bclr #3,@0x91:8 ; reset compare A IRQ flag rts ") | |
![]() | ![]() | void | systime_init (void) |
![]() | ![]() | initialize system timer. More... | |
![]() | ![]() | void | systime_shutdown (void) |
![]() | ![]() | shutdown system timer. More... | |
![]() | ![]() | void | systime_set_switcher (void* switcher) |
![]() | ![]() | set task switcher vector. More... | |
![]() | ![]() | void | systime_set_timeslice (unsigned char slice) |
![]() | ![]() | set multitasking timeslice in ms. More... | |
Variables | |||
![]() | ![]() | volatile time_t | sys_time |
![]() | ![]() | current system time in ms. More... | |
![]() | ![]() | unsigned char | tm_timeslice |
![]() | ![]() | task time slice. | |
![]() | ![]() | volatile unsigned char | tm_current_slice |
![]() | ![]() | current time remaining. | |
![]() | ![]() | void* | tm_switcher_vector |
![]() | ![]() | pointer to task switcher. |
void systime_handler (void) |
system time handler for the 16bit timer OCIA irq.
this is the pulse of the system. task switcher and motor driver calls are initiated here.
__asm__ (".text.align 1.global _systime_handler.global _systime_tm_return_systime_handler:;r6 saved by ROM push r0;both motors &task;switcher need this reg.;increment system timer mov.w@_sys_time+ 2, r6;LSW-, r6 add.b# 0x1, r6l;16 bit:add 1 addx# 0x0, r6h mov. w r6, @_sys_time+2 bcc sys_nohigh;speedup for 65535 cases mov.w@ _sys_time, r6;MSW-, r6 add.b# 0x1, r6l addx# 0x0, r6h mov. w r6, @_sys_time sys_nohigh:""jsr _dm_handler;call motor driver""jsr _dsound_handler;call sound handler""mov.w@ _lnp_timeout_counter, r6;check LNP timeout counter subs# 0x1, r6 mov. w r6, r6;subs doesn't change flags!bne sys_noreset jsr _lnp_integrity_reset mov.w@ _lnp_timeout, r6;reset timeout sys_noreset:mov. w r6, @_lnp_timeout_counter""jsr _dkey_handler""mov.b@ _lcd_refresh_counter, r6l dec r6l bne sys_norefresh jsr@lcd_refresh""jsr _vis_handler""mov.b@ _lcd_refresh_period, r6l sys_norefresh:mov. b r6l, @_lcd_refresh_counter""mov.b@ _tm_current_slice, r6l dec r6l bne sys_noswitch;timeslice elapsed?mov.w@ _tm_switcher_vector, r6 jsr@r6;call task switcher_systime_tm_return:mov.b@ _tm_timeslice, r6l;new timeslice sys_noswitch:mov. b r6l, @_tm_current_slice""pop r0 bclr# 3, @0x91:8;reset compare A IRQ flag rts") |
void systime_init (void) |
initialize system timer.
task switcher initialized to empty handler motors turned off
void systime_shutdown (void) |
shutdown system timer.
will also stop task switching and motors.
void systime_set_switcher (void * switcher) |
set task switcher vector.
switcher | the switcher |
void systime_set_timeslice (unsigned char slice) |
set multitasking timeslice in ms.
slice | the timeslice. must be at least 5ms. |
volatile time_t sys_time |
current system time in ms.
unsigned char tm_timeslice |
task time slice.
volatile unsigned char tm_current_slice |
current time remaining.
void* tm_switcher_vector |
pointer to task switcher.