Index: ChangeLog =================================================================== RCS file: /cvsroot/brickos/brickos/ChangeLog,v retrieving revision 1.40 diff -u -r1.40 ChangeLog --- ChangeLog 17 Feb 2004 03:23:59 -0000 1.40 +++ ChangeLog 17 Aug 2004 15:07:46 -0000 @@ -1,3 +1,16 @@ +2004-08-17 Jochen Hoenicke + + * Reworked timer interrupts: + Watchdog timer is now free for other (user defined) purposes. + OCRA fires every 1 msec again, OCRB fires shortly after. + OCRA increases sys_time, turns off active sensors for polling + OCRB starts polling and calls sub-system handlers. + All times were multiplied by 2 again since handler is now called + every msec. + + * Don't poll the sensors the whole time. This did in fact use + 66 % computation time. + 2004-02-16 Stephen M Moraco * Added new index.html page to installed docs Index: include/dsound.h =================================================================== RCS file: /cvsroot/brickos/brickos/include/dsound.h,v retrieving revision 1.7 diff -u -r1.7 dsound.h --- include/dsound.h 4 Jan 2004 00:32:27 -0000 1.7 +++ include/dsound.h 17 Aug 2004 15:07:47 -0000 @@ -217,7 +217,7 @@ extern unsigned dsound_16th_ms; //!< length of 1/16 note in ms extern unsigned dsound_internote_ms; //!< length of internote spacing in ms extern volatile note_t *dsound_next_note; //!< pointer to current note -extern volatile time_t dsound_next_time; //!< when to play next note +extern volatile unsigned dsound_next_time; //!< when to play next note extern const note_t *dsound_system_sounds[]; //!< system sound data @@ -233,7 +233,7 @@ //! play a sequence of notes static inline void dsound_play(const note_t *notes) { dsound_next_note=(volatile note_t*) notes; - dsound_next_time=0; + dsound_next_time=1; } //! play a system sound Index: include/lnp/sys/lnp-logical.h =================================================================== RCS file: /cvsroot/brickos/brickos/include/lnp/sys/lnp-logical.h,v retrieving revision 1.7 diff -u -r1.7 lnp-logical.h --- include/lnp/sys/lnp-logical.h 12 Oct 2002 03:22:26 -0000 1.7 +++ include/lnp/sys/lnp-logical.h 17 Aug 2004 15:07:47 -0000 @@ -56,7 +56,7 @@ #define LNP_BYTE_TIME MSECS_TO_TICKS(5) //!< time to transmit a byte #endif -#define LNP_BYTE_TIMEOUT (3*LNP_BYTE_TIME/2) //!< timeout waiting for a byte +#define LNP_BYTE_TIMEOUT (3*LNP_BYTE_TIME) //!< timeout waiting for a byte #define LNP_BYTE_SAFE (4*LNP_BYTE_TIME) //!< delay before transmitting a byte #define LNP_WAIT_TXOK (2*LNP_BYTE_TIMEOUT) //!< delay after good transmit Index: kernel/battery.c =================================================================== RCS file: /cvsroot/brickos/brickos/kernel/battery.c,v retrieving revision 1.5 diff -u -r1.5 battery.c --- kernel/battery.c 16 Sep 2002 05:44:19 -0000 1.5 +++ kernel/battery.c 17 Aug 2004 15:07:47 -0000 @@ -35,10 +35,12 @@ // Global Variables // /////////////////////////////////////////////////////////////////////// +#ifndef CONF_VIS #ifdef CONF_BATTERY_INDICATOR unsigned int battery_refresh_counter = 0; //!< counter for lcd refresh in ms unsigned int battery_refresh_period = 2000; //!< LCD refresh period in ms #endif +#endif /////////////////////////////////////////////////////////////////////// // @@ -55,22 +57,20 @@ } #endif // CONF_DSENSOR +#ifndef CONF_VIS #ifdef CONF_BATTERY_INDICATOR // battery indicator handed by kernel task when CONF_TM #ifndef CONF_TM //! battery indicator handler, called from system timer interrupt -#ifdef CONF_RCX_COMPILER void battery_refresh(void) { -#else // CONF_RCX_COMPILER -HANDLER_WRAPPER("battery_refresh","battery_refresh_core"); -void battery_refresh_core(void) { -#endif // CONF_RCX_COMPILER - int bmv = get_battery_mv(); - - if (bmv > BATTERY_NORMAL_THRESHOLD_MV) - dlcd_hide(LCD_BATTERY_X); - else if (bmv > BATTERY_LOW_THRESHOLD_MV) - dlcd_show(LCD_BATTERY_X); + int bmv = get_battery_mv(); + + if (bmv > BATTERY_NORMAL_THRESHOLD_MV) + dlcd_hide(LCD_BATTERY_X); + else if (bmv > BATTERY_LOW_THRESHOLD_MV) + dlcd_show(LCD_BATTERY_X); + battery_refresh_counter = battery_refresh_period; } #endif // CONF_TM #endif // CONF_BATTERY_INDICATOR +#endif // !CONF_VIS Index: kernel/conio.c =================================================================== RCS file: /cvsroot/brickos/brickos/kernel/conio.c,v retrieving revision 1.4 diff -u -r1.4 conio.c --- kernel/conio.c 2 Jan 2004 10:52:32 -0000 1.4 +++ kernel/conio.c 17 Aug 2004 15:07:47 -0000 @@ -201,15 +201,24 @@ //! uncalibrated delay loop /*! \param ms approximate time in ms */ -void delay(unsigned ms) -{ - unsigned i; - - while (ms-- > 0) - for (i = 0; i < 600; i++) // not well calibrated. - ; +extern void delay(unsigned ms); -} +#ifndef DOXYGEN_SHOULD_SKIP_THIS +__asm__("\n\ +.text\n\ +.align 1\n\ +.global _delay\n\ +\n\ +_delay:\n\ +1: mov.w #614, r1\n\ +2: subs #1, r1\n\ + mov.w r1, r1\n\ + bne 2b\n\ + subs #1, r0\n\ + mov.w r0, r0\n\ + bne 1b\n\ + rts\n"); +#endif #ifdef CONF_CONIO Index: kernel/dsensor.c =================================================================== RCS file: /cvsroot/brickos/brickos/kernel/dsensor.c,v retrieving revision 1.4 diff -u -r1.4 dsensor.c --- kernel/dsensor.c 9 Jan 2004 01:44:56 -0000 1.4 +++ kernel/dsensor.c 17 Aug 2004 15:07:47 -0000 @@ -538,36 +538,11 @@ "\n\ inc r6l ; next channel\n\ and #0x03,r6l ; limit to 0-3\n\ -\n\ - mov.b @_ds_activation,r6h ; r6h = activation bitmask\n\ - btst r6l,r6h ; activate output?\n\ - beq ds_nounset\n\ - bclr r6l,@_PORT6:8 ; set output inactive for reading\n\ - ds_nounset:\n\ -\n\ - ; The settle time for reading the value from active sensor start here\n\ -\n\ - ; moved here for helping timing problems\n\ - mov.b r6l,@_ds_channel ; store next channel\n\ -\n\ - ; Added a delay loop for sensor settle time\n\ -\n\ - mov.b #0x04, r6h ; delay loop\n\ -settle:\n\ - nop ; each nop is a 2 state clock delay\n\ - dec.b r6h ; 2 states ?\n\ - bne settle ; 4 states\n\ -\n\ - ; Total loop delay 32 states (?)\n\ -\n\ - mov.b @_AD_CSR:8,r6h ; r6h = A/D CSR\n\ - and.b #0x7c,r6h ; reset scanmode and channel num\n\ - or.b r6l,r6h ; scan next channel\n\ - mov.b r6h,@_AD_CSR:8 ; put r6h back on A/D CSR\n\ -\n\ - ; The settle time for reading the value from active sensor finish here\n\ -\n\ - bset #0x5,@_AD_CSR:8 ; go!\n\ + mov.b r6l, @_ds_channel ; save channel\n\ + mov.b @_AD_CSR:8,r6h ; r6h = A/D CSR\n\ + and.b #0x7c,r6h ; reset interrupt flag and channel num\n\ + or.b r6l,r6h ; scan next channel\n\ + mov.b r6h,@_AD_CSR:8 ; put r6h back on A/D CSR\n\ \n\ rts\n\ "); @@ -597,12 +572,6 @@ AD_CR &=~ADCR_EXTERN; AD_CSR =ADCSR_TIME_266 | ADCSR_GROUP_0 | ADCSR_AN_0 | ADCSR_ENABLE_IRQ | ADCSR_START; - -#ifdef CONF_CONIO - delay(10); // wait for initial A/D -#else -# warning "Rotation initialization might fail." -#endif } Index: kernel/dsound.c =================================================================== RCS file: /cvsroot/brickos/brickos/kernel/dsound.c,v retrieving revision 1.6 diff -u -r1.6 dsound.c --- kernel/dsound.c 4 Jan 2004 00:32:27 -0000 1.6 +++ kernel/dsound.c 17 Aug 2004 15:07:47 -0000 @@ -73,7 +73,7 @@ unsigned dsound_16th_ms; //!< length of 1/16 note in ms unsigned dsound_internote_ms; //!< length of internote spacing in ms volatile note_t *dsound_next_note; //!< pointer to current note -volatile time_t dsound_next_time; //!< when to play next note +volatile unsigned dsound_next_time; //!< when to play next note static volatile int internote; //!< internote delay flag @@ -119,42 +119,32 @@ /////////////////////////////////////////////////////////////////////////////// //! sound handler, called from system timer interrupt -#ifdef CONF_RCX_COMPILER void dsound_handler(void) { -#else -HANDLER_WRAPPER("dsound_handler","dsound_core"); -//! sound core, called from ???? -void dsound_core(void) { -#endif - if (get_system_up_time() >= dsound_next_time) { + if(internote && dsound_internote_ms) { + play_pause(); + dsound_next_time = dsound_internote_ms; + + internote=0; + return; + } + + if(dsound_next_note) { + unsigned char pitch =dsound_next_note->pitch; - if(internote) { - play_pause(); - dsound_next_time = get_system_up_time() + dsound_internote_ms; + if(pitchlength + - dsound_internote_ms; + dsound_next_note++; + internote=1; return; - } - - if(dsound_next_note) { - unsigned char pitch =dsound_next_note->pitch; - - if(pitchlength - - dsound_internote_ms; - dsound_next_note++; - internote=1; - return; - } } - - dsound_stop(); - } + } + dsound_stop(); } //! initialize sound driver @@ -181,7 +171,7 @@ void dsound_stop(void) { play_pause(); dsound_next_note=0; - dsound_next_time=0xffffffff; + dsound_next_time=0xffff; internote=0; } Index: kernel/kmain.c =================================================================== RCS file: /cvsroot/brickos/brickos/kernel/kmain.c,v retrieving revision 1.11 diff -u -r1.11 kmain.c --- kernel/kmain.c 9 Jan 2004 01:44:56 -0000 1.11 +++ kernel/kmain.c 17 Aug 2004 15:07:47 -0000 @@ -55,7 +55,7 @@ //! firmware recognition string /*! the ROM checks for this string when validating new firmware */ -unsigned char *firmware_string = "Do you byte, when I knock?"; +const unsigned char *firmware_string = "Do you byte, when I knock?"; extern char __bss; //!< the start of the uninitialized data segment extern char __bss_end; //!< the end of the uninitialized data segment @@ -176,9 +176,6 @@ #ifdef CONF_DSOUND dsound_init(); #endif -#ifdef CONF_TIME - systime_init(); -#endif #ifdef CONF_DSENSOR ds_init(); #endif @@ -189,6 +186,9 @@ lnp_init(); lnp_logical_init(); #endif +#ifdef CONF_TIME + systime_init(); +#endif #ifdef CONF_TM tm_init(); #endif Index: kernel/lcd.c =================================================================== RCS file: /cvsroot/brickos/brickos/kernel/lcd.c,v retrieving revision 1.5 diff -u -r1.5 lcd.c --- kernel/lcd.c 9 Jan 2004 01:44:56 -0000 1.5 +++ kernel/lcd.c 17 Aug 2004 15:07:47 -0000 @@ -39,9 +39,9 @@ /////////////////////////////////////////////////////////////////////////////// #ifdef CONF_LCD_REFRESH -unsigned char lcd_refresh_counter; //!< counter for lcd refresh in ms -unsigned char lcd_byte_counter; //!< LCD byte to refresh -unsigned char lcd_refresh_period = 2; //!< LCD refresh period in ms +unsigned char lcd_refresh_counter = 1; //!< counter for lcd refresh in ms +unsigned char lcd_byte_counter; //!< LCD byte to refresh +unsigned char lcd_refresh_period = 6; //!< LCD refresh period in ms #endif //! lcd_shadow buffer: @@ -219,18 +219,10 @@ resulting in a complete LCD update every 54ms, which is a refresh rate of 18 updates per second. */ -#ifdef CONF_RCX_COMPILER void lcd_refresh_next_byte(void) -#else -HANDLER_WRAPPER("lcd_refresh_next_byte", "lcd_refresh_next_byte_core"); -//! alternate name for the refresh next byte routine -/*! \todo find a better description for this -*/ -void lcd_refresh_next_byte_core(void) -#endif { unsigned char byte; - + lcd_refresh_counter = lcd_refresh_period; byte = lcd_byte_counter++; if (lcd_byte_counter >= LCD_DATA_SIZE) lcd_byte_counter = 0; Index: kernel/lnp.c =================================================================== RCS file: /cvsroot/brickos/brickos/kernel/lnp.c,v retrieving revision 1.8 diff -u -r1.8 lnp.c --- kernel/lnp.c 2 Jan 2004 12:27:40 -0000 1.8 +++ kernel/lnp.c 17 Aug 2004 15:07:47 -0000 @@ -441,12 +443,7 @@ } //! reset the integrity layer on error or timeout. -#if defined(CONF_RCX_COMPILER) || defined(CONF_HOST) -__TEXT_HI__ void lnp_integrity_reset(void) { -#else -HANDLER_WRAPPER("lnp_integrity_reset","lnp_integrity_reset_core"); -__TEXT_HI__ void lnp_integrity_reset_core(void) { -#endif +__TEXT_HI__ void lnp_integrity_reset(void) { #ifndef CONF_HOST if(tx_state>TX_IDLE) { txend_handler(); @@ -464,6 +461,7 @@ #endif #endif } + lnp_timeout_counter = lnp_timeout; /* reset timeout */ } //! return whether a packet is currently being received Index: kernel/systime.c =================================================================== RCS file: /cvsroot/brickos/brickos/kernel/systime.c,v retrieving revision 1.8 diff -u -r1.8 systime.c --- kernel/systime.c 9 Jan 2004 01:44:56 -0000 1.8 +++ kernel/systime.c 17 Aug 2004 15:07:47 -0000 @@ -82,183 +82,186 @@ // /////////////////////////////////////////////////////////////////////////////// -//! clock handler triggered on the WDT overflow (every msec) on the NMI -/*! this is the system clock - */ -extern void clock_handler(void); -#ifndef DOXYGEN_SHOULD_SKIP_THIS -__asm__("\n\ -.text\n\ -.align 1\n\ -.global _clock_handler\n\ - _clock_handler:\n\ - mov.w #0x5a07,r6 ; reset wd timer to 6\n\ - mov.w r6,@0xffa8\n\ -\n\ - mov.w @_sys_time+2,r6 ; lower 8 bits\n\ - add.b #0x1,r6l ; inc lower 4 bits\n\ - addx #0x0,r6h ; add carry to top 4 bits\n\ - mov.w r6,@_sys_time+2\n\ - bcc sys_nohigh ; if carry, inc upper 8 bits\n\ - mov.w @_sys_time,r6 ; \n\ - add.b #0x1,r6l ; inc lower 4 bits\n\ - addx #0x0,r6h ; add carry to top 4 bits\n\ - mov.w r6,@_sys_time\n\ - sys_nohigh: \n\ - rts\n\ - "); -#endif // DOXYGEN_SHOULD_SKIP_THIS -//! subsystem handler for every 2nd msec +//! subsystem handler for every msec /*! this is the pulse of the system (subsystems). + It just increases sys_time and turns off active sensors to + settle down. The remaining functions are done in secondary + handler. +*/ +extern void subsystem_handler(void); +//! subsystem handler for every msec +/*! this is the other part of the pulse of the system. sound, motor and lcd driver calls are initiated here. task_switch_handler is called from here as well. */ -extern void subsystem_handler(void); +extern void secondary_handler(void); -//! task switch handler called every msec -/*! handles swapping between tasks - */ -extern void task_switch_handler(void); #ifndef DOXYGEN_SHOULD_SKIP_THIS __asm__("\n\ .text\n\ .align 1\n\ .global _subsystem_handler\n\ -.global _task_switch_handler\n\ +.global _secondary_handler\n\ .global _systime_tm_return\n\ +\n\ _subsystem_handler:\n\ - ; r6 saved by ROM\n\ + ; r6 saved by ROM\n\ \n\ - push r0 ; both motors & task\n\ - ; switcher need this reg.\n\ - " + mov.w @_sys_time+2,r6 ; lower 16 bits\n\ + adds #1,r6 ; inc lower 16 bits\n\ + mov.w r6,@_sys_time+2\n\ + bne sys_nohigh ; if carry, inc upper 8 bits\n\ + mov.w @_sys_time,r6 ; \n\ + adds #1,r6 ; inc upper 16 bits\n\ + mov.w r6,@_sys_time\n\ +sys_nohigh: \n\ +\n\ + ; disable active sensor so it can be read.\n\ + mov.b @_ds_channel,r6l ; r6l = current channel\n\ + bclr r6l,@_PORT6:8 ; set output inactive for reading\n\ + ; the actual reading is startet in secondary_handler\n\ + ; this allows the sensor to settle\n\ + bclr #3,@0x91:8 ; reset compare A IRQ flag\n\ + rts\n\n" + "\n\ +.text\n\ +.align 1\n\ +.global _secondary_handler\n\ +\n\ +_secondary_handler:\n\ +\n\ + ; The settle time for reading the value from active sensor\n\ + ; finish here. Now start sampling the sensor.\n\ +\n\ + ;\n\ + mov.b @_ds_channel,r6l ; r6l = current channel\n\ +\n\ + bset #0x5,@_AD_CSR:8 ; go!\n\ +\n\ + push r0 ; this reg isn't saved by rom\n\ + push r1 ; this reg isn't saved by rom\n\ + push r2 ; this reg isn't saved by rom\n\ + push r3 ; this reg isn't saved by rom\n\ +" #ifdef CONF_DSOUND "\n\ - jsr _dsound_handler ; call sound handler\n\ - " + mov.w @_dsound_next_time,r6 ; check sound timeout counter\n\ + subs #1,r6\n\ + mov.w r6,@_dsound_next_time\n\ + bne 1f\n\ +\n\ + jsr _dsound_handler ; call sound handler\n\ +1:\n" #endif // CONF_DSOUND #ifdef CONF_LNP "\n\ - mov.w @_lnp_timeout_counter,r6 ; check LNP timeout counter\n\ - subs #0x1,r6\n\ - mov.w r6,r6 ; subs doesn't change flags!\n\ - bne sys_noreset\n\ - \n\ - jsr _lnp_integrity_reset\n\ - mov.w @_lnp_timeout,r6 ; reset timeout\n\ + mov.w @_lnp_timeout_counter,r6 ; check LNP timeout counter\n\ + subs #0x1,r6\n\ + mov.w r6,@_lnp_timeout_counter\n\ + bne sys_noreset\n\ \n\ - sys_noreset:\n\ - mov.w r6,@_lnp_timeout_counter\n\ - " + jsr _lnp_integrity_reset\n\ +\n\ +sys_noreset:\n" #endif // CONF_LNP #ifdef CONF_DKEY "\n\ - jsr _dkey_handler\n\ - " + jsr _dkey_handler\n" #endif // CONF_DKEY #ifndef CONF_TM +#ifndef CONF_VIS #ifdef CONF_BATTERY_INDICATOR "\n\ - mov.w @_battery_refresh_counter,r6\n\ - subs #0x1,r6\n\ - bne batt_norefresh\n\ + mov.w @_battery_refresh_counter,r6\n\ + subs #0x1,r6\n\ + mov.w r6,@_battery_refresh_counter\n\ + bne batt_norefresh\n\ \n\ - jsr _battery_refresh\n\ - mov.w @_battery_refresh_period,r6\n\ + jsr _battery_refresh\n\ \n\ - batt_norefresh:\n\ - mov.w r6,@_battery_refresh_counter\n\ - " +batt_norefresh:\n" #endif // CONF_BATTERY_INDICATOR -#endif // CONF_TM +#endif // !CONF_VIS +#endif // !CONF_TM #ifdef CONF_AUTOSHUTOFF "\n\ - mov.w @_auto_shutoff_counter,r6\n\ - subs #0x1,r6\n\ - bne auto_notshutoff\n\ -\n\ - jsr _autoshutoff_check\n\ - mov.w @_auto_shutoff_period,r6\n\ - \n\ - auto_notshutoff:\n\ - mov.w r6,@_auto_shutoff_counter\n\ + mov.w @_auto_shutoff_counter,r6\n\ + subs #0x1,r6\n\ + mov.w r6,@_auto_shutoff_counter\n\ + bne auto_notshutoff\n\ +\n\ + jsr _autoshutoff_check\n\ +\n\ +auto_notshutoff:\n\ " #endif // CONF_AUTOSHUTOFF #ifdef CONF_VIS "\n\ - mov.b @_vis_refresh_counter,r6l\n\ - dec r6l\n\ - bne vis_norefresh\n\ - \n\ - jsr _vis_handler\n\ - mov.b @_vis_refresh_period,r6l\n\ - \n\ - vis_norefresh:\n\ - mov.b r6l,@_vis_refresh_counter\n\ - " + mov.b @_vis_refresh_counter,r6l\n\ + dec r6l\n\ + mov.b r6l,@_vis_refresh_counter\n\ + bne vis_norefresh\n\ +\n\ + jsr _vis_handler\n\ +\n\ +vis_norefresh:\n" #endif // CONF_VIS #ifdef CONF_LCD_REFRESH "\n\ - mov.b @_lcd_refresh_counter,r6l\n\ - dec r6l\n\ - bne lcd_norefresh\n\ - \n\ - jsr _lcd_refresh_next_byte\n\ - mov.b @_lcd_refresh_period,r6l\n\ - \n\ - lcd_norefresh:\n\ - mov.b r6l,@_lcd_refresh_counter\n\ + mov.b @_lcd_refresh_counter,r6l\n\ + dec r6l\n\ + mov.b r6l,@_lcd_refresh_counter\n\ + bne lcd_norefresh\n\ +\n\ + jsr _lcd_refresh_next_byte\n\ + \n\ +lcd_norefresh:\n\ " #endif // CONF_LCD_REFRESH - "\n\ - bclr #2,@0x91:8 ; reset compare B IRQ flag\n\ - " + #ifdef CONF_TM "\n\ - pop r0 ; if fallthrough, pop r0\n\ - _task_switch_handler:\n\ - push r0 ; save r0\n\ -\n\ - mov.b @_tm_current_slice,r6l\n\ - dec r6l\n\ - bne sys_noswitch ; timeslice elapsed?\n\ -\n\ - mov.w @_kernel_critsec_count,r6 ; check critical section\n\ - beq sys_switch ; ok to switch\n\ - mov.b #1,r6l ; wait another tick\n\ - jmp sys_noswitch ; don't switch\n\ -\n\ - sys_switch:\n\ - mov.w @_tm_switcher_vector,r6\n\ - jsr @r6 ; call task switcher\n\ - \n\ - _systime_tm_return:\n\ - mov.b @_tm_timeslice,r6l ; new timeslice\n\ + mov.b @_tm_current_slice,r6l\n\ + dec r6l\n\ + bne sys_noswitch ; timeslice elapsed?\n\ \n\ - sys_noswitch:\n\ - mov.b r6l,@_tm_current_slice\n\ - " + mov.w @_kernel_critsec_count,r6 ; check critical section\n\ + beq sys_switch ; ok to switch\n\ + mov.b #1,r6l ; wait another tick\n\ + jmp sys_noswitch ; don't switch\n\ +\n\ +sys_switch:\n\ + mov.w @_tm_switcher_vector,r6\n\ + jsr @r6 ; call task switcher\n\ +\n\ +_systime_tm_return:\n\ + mov.b @_tm_timeslice,r6l ; new timeslice\n\ +\n\ +sys_noswitch:\n\ + mov.b r6l,@_tm_current_slice\n" #endif // CONF_TM #ifdef CONF_DMOTOR "\n\ - jsr _dm_handler ; call motor driver\n\ - " + jsr _dm_handler ; call motor driver\n" #endif // CONF_DMOTOR "\n\ - pop r0\n\ - bclr #3,@0x91:8 ; reset compare A IRQ flag\n\ - rts\n\ - " + pop r3\n\ + pop r2\n\ + pop r1\n\ + pop r0\n\ +\n\ + bclr #2,@0x91:8 ; reset compare B IRQ flag\n\ + rts\n" ); #endif // DOXYGEN_SHOULD_SKIP_THIS @@ -277,38 +280,24 @@ tm_switcher_vector=&rom_dummy_handler; // empty handler #endif -#ifdef CONF_DMOTOR - dm_shutdown(); -#endif - // configure 16-bit timer - // compare B IRQ will fire after one msec - // compare A IRQ will fire after another msec + // compare B IRQ will fire after 10 usec + // compare A IRQ will fire after 1000 usec // counter is then reset // T_CSR = TCSR_RESET_ON_A; T_CR = TCR_CLOCK_32; - T_OCR &= ~TOCR_OCRB; - T_OCRA = 1000; - T_OCR &= ~TOCR_OCRA; - T_OCR |= TOCR_OCRB; - T_OCRB = 500; - -#if defined(CONF_TM) - ocia_vector = &task_switch_handler; -#else // CONF_TM + T_OCR &= ~TOCR_OCRB; /* select register A */ + T_OCRA = 500; + T_OCR |= TOCR_OCRB; /* select register B */ + T_OCRB = 5; + T_CNT = 6; + T_CSR &= ~TCSR_OCA; + T_CSR &= ~TCSR_OCB; + ocia_vector = &subsystem_handler; -#endif // CONF_TM - ocib_vector = &subsystem_handler; + ocib_vector = &secondary_handler; T_IER |= (TIER_ENABLE_OCB | TIER_ENABLE_OCA); - - nmi_vector = &clock_handler; - WDT_CSR = WDT_CNT_PASSWORD | WDT_CNT_MSEC_64; // trigger every msec - WDT_CSR = WDT_CSR_PASSWORD - | WDT_CSR_CLOCK_64 - | WDT_CSR_WATCHDOG_NMI - | WDT_CSR_ENABLE - | WDT_CSR_MODE_WATCHDOG; } //! shutdown system timer Index: kernel/timeout.c =================================================================== RCS file: /cvsroot/brickos/brickos/kernel/timeout.c,v retrieving revision 1.5 diff -u -r1.5 timeout.c --- kernel/timeout.c 12 Oct 2002 03:22:26 -0000 1.5 +++ kernel/timeout.c 17 Aug 2004 15:07:47 -0000 @@ -29,8 +29,8 @@ #include #ifdef CONF_AUTOSHUTOFF -volatile unsigned int auto_shutoff_counter = 0; // nb_system_tasks) state ^= 1; else state=0; - lcd_show(state == 0 ? man_stand : man_run); -#ifndef CONF_LCD_REFRESH - lcd_refresh(); -#endif // CONF_LCD_REFRESH - msleep(500); - } - return 0; -} - -#ifdef CONF_BATTERY_INDICATOR -//! the battery system task -/*! updates the battery low indicator when necessary -*/ -int tm_battery_task(int argc, char **argv) { - int bmv; - - while (!shutdown_requested()) { - bmv=get_battery_mv(); - - if(bmv>BATTERY_NORMAL_THRESHOLD_MV) - dlcd_hide(LCD_BATTERY_X); - else if(bmvtflags |= T_IDLE; -#ifdef CONF_VIS - execi(&tm_man_task, 0, NULL, 1, IDLE_STACK_SIZE); - -#ifdef CONF_BATTERY_INDICATOR - execi(&tm_battery_task, 0, NULL, 1, IDLE_STACK_SIZE); -#endif // CONF_BATTERY_INDICATOR -#endif // CONF_VIS - systime_set_timeslice(TM_DEFAULT_SLICE); -} +} //! start task management @@ -463,13 +417,13 @@ *(--sp)=(size_t) &rom_ocia_return; // ROM return < rts in systime_handler - *(--sp)=(size_t) argc; // r0 < pop r0 in systime handler + *(--sp)=(size_t) argc; // r0 < pop r0 in systime handler + *(--sp)=(size_t) argv; // r1..r3 < pop r1 in systime handler + *(--sp)=0; + *(--sp)=0; *(--sp)=(size_t) &systime_tm_return; // systime return < rts in tm_switcher - *(--sp)=(size_t) argv; // r1..r5 < pop r1..r5 in tm_switcher - *(--sp)=0; - *(--sp)=0; *(--sp)=0; *(--sp)=0; Index: kernel/vis.c =================================================================== RCS file: /cvsroot/brickos/brickos/kernel/vis.c,v retrieving revision 1.5 diff -u -r1.5 vis.c --- kernel/vis.c 12 Oct 2002 03:22:26 -0000 1.5 +++ kernel/vis.c 17 Aug 2004 15:07:47 -0000 @@ -33,6 +33,7 @@ #include #include #include +#include /////////////////////////////////////////////////////////////////////////////// // @@ -40,8 +41,11 @@ // /////////////////////////////////////////////////////////////////////////////// -unsigned char vis_refresh_counter = 0; -unsigned char vis_refresh_period = 50; +unsigned char vis_refresh_counter = 1; //!< counter; decreased every ms +unsigned char vis_refresh_period = 100; //!< VIS refresh period in ms + +unsigned char vis_animated_man; +unsigned char vis_animated_man_ctr; /////////////////////////////////////////////////////////////////////////////// // @@ -49,12 +53,7 @@ // /////////////////////////////////////////////////////////////////////////////// -#ifdef CONF_RCX_COMPILER void vis_handler(void) { -#else -HANDLER_WRAPPER("vis_handler","vis_core"); -void vis_core(void) { -#endif #ifdef CONF_DSENSOR bit_iload(AD_C_H,0x7); dlcd_store(LCD_S1_ACTIVE); @@ -72,8 +71,27 @@ cputc_hex_0(cprog+1); else cputc_0('-'); + vis_animated_man = 0; + lcd_show(man_stand); + } else { + if (vis_animated_man_ctr-- == 0) { + vis_animated_man ^= 1; + vis_animated_man_ctr = 4; + lcd_show(vis_animated_man == 0 ? man_stand : man_run); + } } #endif + +#ifdef CONF_BATTERY_INDICATOR + { + int bmv = get_battery_mv(); + if (bmv > BATTERY_NORMAL_THRESHOLD_MV) + dlcd_hide(LCD_BATTERY_X); + else if (bmv < BATTERY_LOW_THRESHOLD_MV) + dlcd_show(LCD_BATTERY_X); + } +#endif // CONF_BATTERY_INDICATOR + vis_refresh_counter = vis_refresh_period; } #endif // CONF_VIS