<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>change log for rtems (2010-05-09)</title>
</head>
<body text='#000000' bgcolor='#ffffff'>
<a name='cs1'></a>
<table border='0' cellspacing='0' cellpadding='5' width='100%' bgcolor='#eeeeee'>
<tr><td colspan='3' bgcolor='#dddddd'>
<font color='#bb2222'><strong>joel</strong></font>
</td></tr>
<tr><td colspan='3' bgcolor='#dddddd'><pre>2010-05-09 Joel Sherrill <joel.sherrill@oarcorp.com>
* timer/timer.c: Now runs on 486 and below again. Reformatted.
</pre></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/c/src/lib/libbsp/i386/pc386/ChangeLog.diff?r1=text&tr1=1.256&r2=text&tr2=1.257&diff_format=h">M</a></td><td width='1%'>1.257</td><td width='100%'>c/src/lib/libbsp/i386/pc386/ChangeLog</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/c/src/lib/libbsp/i386/pc386/timer/timer.c.diff?r1=text&tr1=1.28&r2=text&tr2=1.29&diff_format=h">M</a></td><td width='1%'>1.29</td><td width='100%'>c/src/lib/libbsp/i386/pc386/timer/timer.c</td></tr>
</table>
<pre>
<font color='#006600'>diff -u rtems/c/src/lib/libbsp/i386/pc386/ChangeLog:1.256 rtems/c/src/lib/libbsp/i386/pc386/ChangeLog:1.257
--- rtems/c/src/lib/libbsp/i386/pc386/ChangeLog:1.256 Fri Apr 30 06:43:01 2010
+++ rtems/c/src/lib/libbsp/i386/pc386/ChangeLog Sun May 9 19:29:30 2010
</font><font color='#997700'>@@ -1,3 +1,7 @@
</font><font color='#000088'>+2010-05-09 Joel Sherrill <joel.sherrill@oarcorp.com>
+
+ * timer/timer.c: Now runs on 486 and below again. Reformatted.
+
</font> 2010-04-30 Sebastian Huber <sebastian.huber@embedded-brains.de>
* Makefile.am, preinstall.am: Update for generic interrupt support
<font color='#006600'>diff -u rtems/c/src/lib/libbsp/i386/pc386/timer/timer.c:1.28 rtems/c/src/lib/libbsp/i386/pc386/timer/timer.c:1.29
--- rtems/c/src/lib/libbsp/i386/pc386/timer/timer.c:1.28 Wed Dec 3 11:28:10 2008
+++ rtems/c/src/lib/libbsp/i386/pc386/timer/timer.c Sun May 9 19:29:30 2010
</font><font color='#997700'>@@ -1,42 +1,31 @@
</font><font color='#880000'>-/*-------------------------------------------------------------------------+
-| timer.c v1.1 - PC386 BSP - 1997/08/07
-+--------------------------------------------------------------------------+
-| This file contains the PC386 timer package.
-+--------------------------------------------------------------------------+
-| NOTE: It is important that the timer start/stop overhead be determined
-| when porting or modifying this code.
-+--------------------------------------------------------------------------+
-| (C) Copyright 1997 -
-| - NavIST Group - Real-Time Distributed Systems and Industrial Automation
-|
-| http://pandora.ist.utl.pt
-|
-| Instituto Superior Tecnico * Lisboa * PORTUGAL
-+--------------------------------------------------------------------------+
-| Disclaimer:
-|
-| This file is provided "AS IS" without warranty of any kind, either
-| expressed or implied.
-+--------------------------------------------------------------------------+
-| This code is base on:
-| timer.c,v 1.7 1995/12/19 20:07:43 joel Exp - go32 BSP
-|
-| Rosimildo daSilva -ConnectTel, Inc - Fixed infinite loop in the Calibration
-| routine. I've seen this problems with faster machines ( pentiums ). Sometimes
-| RTEMS just hangs at startup.
-|
-| With the following copyright notice:
-| **************************************************************************
-| * COPYRIGHT (c) 1989-1999.
-| * On-Line Applications Research Corporation (OAR).
-| *
-| * The license and distribution terms for this file may be
-| * found in found in the file LICENSE in this distribution or at
-| * http://www.rtems.com/license/LICENSE.
-| **************************************************************************
-|
-| $Id$
-+--------------------------------------------------------------------------*/
</font><font color='#000088'>+/*
+ * This file contains the PC386 timer package.
+ *
+ * Rosimildo daSilva -ConnectTel, Inc - Fixed infinite loop in the Calibration
+ * routine. I've seen this problems with faster machines ( pentiums ). Sometimes
+ * RTEMS just hangs at startup.
+ *
+ * Joel 9 May 2010: This is now seen sometimes on qemu.
+ *
+ * Modifications by:
+ * (C) Copyright 1997 -
+ * NavIST Group - Real-Time Distributed Systems and Industrial Automation
+ * http://pandora.ist.utl.pt
+ * Instituto Superior Tecnico * Lisboa * PORTUGAL
+ *
+ * This file is provided "AS IS" without warranty of any kind, either
+ * expressed or implied.
+ *
+ * Based upon code by<span style="background-color: #FF0000"> </span>
+ * COPYRIGHT (c) 1989-1999.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
</font>
#include <stdlib.h>
<font color='#997700'>@@ -44,144 +33,115 @@
</font> #include <bsp/irq.h>
#include <libcpu/cpuModel.h>
<font color='#880000'>-/*-------------------------------------------------------------------------+
-| Constants
-+--------------------------------------------------------------------------*/
-#define AVG_OVERHEAD 0 /* 0.1 microseconds to start/stop timer. */
-#define LEAST_VALID 1 /* Don't trust a value lower than this. */
-#define SLOW_DOWN_IO 0x80<span style="background-color: #FF0000"> </span> /* io which does nothing */
</font><font color='#000088'>+/*
+ * Constants
+ */
+#define AVG_OVERHEAD 0 /* 0.1 microseconds to start/stop timer. */
+#define LEAST_VALID 1 /* Don't trust a value lower than this. */
+#define SLOW_DOWN_IO 0x80 /* io which does nothing */
</font>
<font color='#880000'>-#define TWO_MS (uint32_t)(2000) /* TWO_MS = 2000us (sic!) */
</font><font color='#000088'>+#define TWO_MS (uint32_t)(2000) /* TWO_MS = 2000us (sic!) */
</font>
<font color='#880000'>-#define MSK_NULL_COUNT 0x40 /* bit counter available for reading */
</font><font color='#000088'>+#define MSK_NULL_COUNT 0x40 /* bit counter available for reading */
</font>
#define CMD_READ_BACK_STATUS 0xE2 /* command read back status */
<font color='#880000'>-/*-------------------------------------------------------------------------+
-| Global Variables
-+--------------------------------------------------------------------------*/
</font><font color='#000088'>+
+/*
+ * Global Variables
+ */
</font> volatile uint32_t Ttimer_val;
<font color='#880000'>-bool<span style="background-color: #FF0000"> </span> benchmark_timer_find_average_overhead = true;
</font><font color='#000088'>+bool benchmark_timer_find_average_overhead = true;
</font> volatile unsigned int fastLoop1ms, slowLoop1ms;
void (*benchmark_timer_initialize_function)(void) = 0;
uint32_t (*benchmark_timer_read_function)(void) = 0;
void (*Timer_exit_function)(void) = 0;
<font color='#880000'>-/*-------------------------------------------------------------------------+
-| External Prototypes
-+--------------------------------------------------------------------------*/
</font><font color='#000088'>+/* timer (int 08h) Interrupt Service Routine (defined in 'timerisr.s') */
</font> extern void timerisr(void);
<font color='#880000'>- /* timer (int 08h) Interrupt Service Routine (defined in 'timerisr.s') */
</font><font color='#000088'>+
+void Timer_exit(void);
</font>
/*
<font color='#880000'>- * forward declarations
</font><font color='#000088'>+ * Pentium optimized timer handling.
</font> */
<font color='#880000'>-void Timer_exit(void);
</font><font color='#000088'>+/*
+ * Timer cleanup routine at RTEMS exit. NOTE: This routine is
+ * not really necessary, since there will be a reset at exit.
+ */
</font>
<font color='#880000'>-/*-------------------------------------------------------------------------+
-| Pentium optimized timer handling.
-+--------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------+
-| Function: Timer_exit
-| Description: Timer cleanup routine at RTEMS exit. NOTE: This routine is
-| not really necessary, since there will be a reset at exit.
-| Global Variables: None.
-| Arguments: None.
-| Returns: Nothing.
-+--------------------------------------------------------------------------*/
-void
-tsc_timer_exit(void)
</font><font color='#000088'>+void tsc_timer_exit(void)
</font> {
<font color='#880000'>-} /* tsc_timer_exit */
</font><font color='#000088'>+}
</font>
<font color='#880000'>-/*-------------------------------------------------------------------------+
-| Function: benchmark_timer_initialize
-| Description: Timer initialization routine.
-| Global Variables: Ttimer_val.
-| Arguments: None.
-| Returns: Nothing.
-+--------------------------------------------------------------------------*/
-void
-tsc_timer_initialize(void)
</font><font color='#000088'>+void tsc_timer_initialize(void)
</font> {
static bool First = true;
<font color='#880000'>- if (First)
- {
</font><font color='#000088'>+ if (First) {
</font> First = false;
atexit(Timer_exit); /* Try not to hose the system at exit. */
}
Ttimer_val = rdtsc(); /* read starting time */
<font color='#880000'>-} /* tsc_timer_initialize */
</font><font color='#000088'>+}
</font>
<font color='#880000'>-/*-------------------------------------------------------------------------+
-| Function: benchmark_timer_read
-| Description: Read hardware timer value.
-| Global Variables: Ttimer_val, benchmark_timer_find_average_overhead.
-| Arguments: None.
-| Returns: Nothing.
-+--------------------------------------------------------------------------*/
-uint32_t
-tsc_read_timer(void)
</font><font color='#000088'>+/*
+ *
+ */
+uint32_t tsc_read_timer(void)
</font> {
<font color='#880000'>- register uint32_t total;
</font><font color='#000088'>+ register uint32_t total;
</font>
total = (uint32_t)(rdtsc() - Ttimer_val);
if (benchmark_timer_find_average_overhead)
return total;
<font color='#880000'>- else if (total < LEAST_VALID)
- return 0; /* below timer resolution */
- else
- return (total - AVG_OVERHEAD);
-} /* tsc_read_timer */
</font>
<font color='#880000'>-/*-------------------------------------------------------------------------+
-| Non-Pentium timer handling.
-+--------------------------------------------------------------------------*/
</font><font color='#000088'>+ if (total < LEAST_VALID)
+ return 0; /* below timer resolution */
+
+ return (total - AVG_OVERHEAD);
+}
+
+/*
+ * Non-Pentium timer handling.
+ */
</font> #define US_PER_ISR 250 /* Number of micro-seconds per timer interruption */
<font color='#880000'>-/*-------------------------------------------------------------------------+
-| Function: Timer_exit
-| Description: Timer cleanup routine at RTEMS exit. NOTE: This routine is
-| not really necessary, since there will be a reset at exit.
-| Global Variables: None.
-| Arguments: None.
-| Returns: Nothing.
-+--------------------------------------------------------------------------*/
-static void
-timerOff(const rtems_raw_irq_connect_data* used)
</font><font color='#000088'>+/*
+ * Timer cleanup routine at RTEMS exit. NOTE: This routine is
+ * not really necessary, since there will be a reset at exit.
+ */
+static void timerOff(const rtems_raw_irq_connect_data* used)
</font> {
<font color='#880000'>- /*
- * disable interrrupt at i8259 level
- */
- BSP_irq_disable_at_i8259s(used->idtIndex - BSP_IRQ_VECTOR_BASE);
- /* reset timer mode to standard (DOS) value */
- outport_byte(TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN);
- outport_byte(TIMER_CNTR0, 0);
- outport_byte(TIMER_CNTR0, 0);
-} /* Timer_exit */
-
-static void
-timerOn(const rtems_raw_irq_connect_data* used)
-{
- /* load timer for US_PER_ISR microsecond period */
- outport_byte(TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN);
- outport_byte(TIMER_CNTR0, US_TO_TICK(US_PER_ISR) >> 0 & 0xff);
- outport_byte(TIMER_CNTR0, US_TO_TICK(US_PER_ISR) >> 8 & 0xff);
- /*
- * enable interrrupt at i8259 level
- */
- BSP_irq_enable_at_i8259s(used->idtIndex - BSP_IRQ_VECTOR_BASE);
</font><font color='#000088'>+ /*
+ * disable interrrupt at i8259 level
+ */
+ BSP_irq_disable_at_i8259s(used->idtIndex - BSP_IRQ_VECTOR_BASE);
+ /* reset timer mode to standard (DOS) value */
+ outport_byte(TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN);
+ outport_byte(TIMER_CNTR0, 0);
+ outport_byte(TIMER_CNTR0, 0);
+}
+
+static void timerOn(const rtems_raw_irq_connect_data* used)
+{
+ /* load timer for US_PER_ISR microsecond period */
+ outport_byte(TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN);
+ outport_byte(TIMER_CNTR0, US_TO_TICK(US_PER_ISR) >> 0 & 0xff);
+ outport_byte(TIMER_CNTR0, US_TO_TICK(US_PER_ISR) >> 8 & 0xff);
+
+ /*
+ * enable interrrupt at i8259 level
+ */
+ BSP_irq_enable_at_i8259s(used->idtIndex - BSP_IRQ_VECTOR_BASE);
</font> }
<font color='#880000'>-static int
-timerIsOn(const rtems_raw_irq_connect_data *used)
</font><font color='#000088'>+static int timerIsOn(const rtems_raw_irq_connect_data *used)
</font> {
<font color='#880000'>- return BSP_irq_enabled_at_i8259s(used->idtIndex - BSP_IRQ_VECTOR_BASE);
</font><font color='#000088'>+ return BSP_irq_enabled_at_i8259s(used->idtIndex - BSP_IRQ_VECTOR_BASE);
</font> }
static rtems_raw_irq_connect_data timer_raw_irq_data = {
<font color='#997700'>@@ -192,39 +152,35 @@
</font> timerIsOn
};
<font color='#880000'>-/*-------------------------------------------------------------------------+
-| Function: Timer_exit
-| Description: Timer cleanup routine at RTEMS exit. NOTE: This routine is
-| not really necessary, since there will be a reset at exit.
-| Global Variables: None.
-| Arguments: None.
-| Returns: Nothing.
-+--------------------------------------------------------------------------*/
-void
</font><font color='#000088'>+/*
+ * Timer cleanup routine at RTEMS exit. NOTE: This routine is
+ * not really necessary, since there will be a reset at exit.
+ */ void
</font> i386_timer_exit(void)
{
i386_delete_idt_entry (&timer_raw_irq_data);
<font color='#880000'>-} /* Timer_exit */
</font><font color='#000088'>+}
</font>
<font color='#880000'>-/*-------------------------------------------------------------------------+
-| Function: benchmark_timer_initialize
-| Description: Timer initialization routine.
-| Global Variables: Ttimer_val.
-| Arguments: None.
-| Returns: Nothing.
-+--------------------------------------------------------------------------*/
-void
-i386_timer_initialize(void)
</font><font color='#000088'>+extern void rtems_irq_prologue_0(void);
+void i386_timer_initialize(void)
</font> {
static bool First = true;
<font color='#880000'>- if (First)
- {
</font><font color='#000088'>+ if (First) {
+ rtems_raw_irq_connect_data raw_irq_data = {
+ BSP_PERIODIC_TIMER + BSP_IRQ_VECTOR_BASE,
+ rtems_irq_prologue_0,
+ NULL,
+ NULL,
+ NULL
+ };
+
</font> First = false;
<font color='#000088'>+ i386_delete_idt_entry (&raw_irq_data);
</font>
<font color='#880000'>- atexit(Timer_exit); /* Try not to hose the system at exit. */
</font><font color='#000088'>+ atexit(Timer_exit); /* Try not to hose the system at exit. */
</font> if (!i386_set_idt_entry (&timer_raw_irq_data)) {
<font color='#880000'>- printk("raw handler connexion failed\n");
</font><font color='#000088'>+ printk("raw handler connection failed\n");
</font> rtems_fatal_error_occurred(1);
}
}
<font color='#997700'>@@ -233,17 +189,12 @@
</font> while (Ttimer_val == 0)
continue;
Ttimer_val = 0;
<font color='#880000'>-} /* benchmark_timer_initialize */
</font><font color='#000088'>+}
</font>
<font color='#880000'>-/*-------------------------------------------------------------------------+
-| Function: benchmark_timer_read
-| Description: Read hardware timer value.
-| Global Variables: Ttimer_val, benchmark_timer_find_average_overhead.
-| Arguments: None.
-| Returns: Nothing.
-+--------------------------------------------------------------------------*/
-uint32_t
-i386_read_timer(void)
</font><font color='#000088'>+/*
+ * Read hardware timer value.
+ */
+uint32_t i386_read_timer(void)
</font> {
register uint32_t total, clicks;
register uint8_t lsb, msb;
<font color='#997700'>@@ -256,10 +207,11 @@
</font>
if (benchmark_timer_find_average_overhead)
return total;
<font color='#880000'>- else if (total < LEAST_VALID)
- return 0; /* below timer resolution */
- else
- return (total - AVG_OVERHEAD);
</font><font color='#000088'>+
+ if (total < LEAST_VALID)
+ return 0; /* below timer resolution */
+
+ return (total - AVG_OVERHEAD);
</font> }
/*
<font color='#997700'>@@ -267,64 +219,56 @@
</font> * or interrupt-based implementation
*/
<font color='#880000'>-void
-benchmark_timer_initialize(void)
</font><font color='#000088'>+void benchmark_timer_initialize(void)
</font> {
<font color='#880000'>- static bool First = true;
</font><font color='#000088'>+ static bool First = true;
</font>
<font color='#880000'>- if (First) {
- if (x86_has_tsc()) {
</font><font color='#000088'>+ if (First) {
+ if (x86_has_tsc()) {
</font> #if defined(DEBUG)
<font color='#880000'>- printk("TSC: timer initialization\n");
</font><font color='#000088'>+ printk("TSC: timer initialization\n");
</font> #endif /* DEBUG */
<font color='#880000'>- benchmark_timer_initialize_function = &tsc_timer_initialize;
- benchmark_timer_read_function = &tsc_read_timer;
- Timer_exit_function = &tsc_timer_exit;
- }
- else {
</font><font color='#000088'>+ benchmark_timer_initialize_function = &tsc_timer_initialize;
+ benchmark_timer_read_function = &tsc_read_timer;
+ Timer_exit_function = &tsc_timer_exit;
+ } else {
</font> #if defined(DEBUG)
<font color='#880000'>- printk("ISR: timer initialization\n");
</font><font color='#000088'>+ printk("ISR: timer initialization\n");
</font> #endif /* DEBUG */
<font color='#880000'>- benchmark_timer_initialize_function = &i386_timer_initialize;
- benchmark_timer_read_function = &i386_read_timer;
- Timer_exit_function = &i386_timer_exit;
- }
- First = false;
</font><font color='#000088'>+ benchmark_timer_initialize_function = &i386_timer_initialize;
+ benchmark_timer_read_function = &i386_read_timer;
+ Timer_exit_function = &i386_timer_exit;
</font> }
<font color='#880000'>- (*benchmark_timer_initialize_function)();
</font><font color='#000088'>+ First = false;
+ }
+ (*benchmark_timer_initialize_function)();
</font> }
<font color='#880000'>-uint32_t
-benchmark_timer_read(void)
</font><font color='#000088'>+uint32_t benchmark_timer_read(void)
</font> {
<font color='#880000'>- return (*benchmark_timer_read_function)();
</font><font color='#000088'>+ return (*benchmark_timer_read_function)();
</font> }
<font color='#880000'>-void
-Timer_exit(void)
</font><font color='#000088'>+void Timer_exit(void)
</font> {
<font color='#880000'>- return (*Timer_exit_function)();
</font><font color='#000088'>+ return (*Timer_exit_function)();
</font> }
<font color='#880000'>-/*-------------------------------------------------------------------------+
-| Function: benchmark_timer_disable_subtracting_average_overhead
-| Description: Set internal benchmark_timer_find_average_overhead flag value.
-| Global Variables: benchmark_timer_find_average_overhead.
-| Arguments: find_flag - new value of the flag.
-| Returns: Nothing.
-+--------------------------------------------------------------------------*/
-void
-benchmark_timer_disable_subtracting_average_overhead(bool find_flag)
</font><font color='#000088'>+/*
+ * Set internal benchmark_timer_find_average_overhead flag value.
+ */
+void benchmark_timer_disable_subtracting_average_overhead(bool find_flag)
</font> {
benchmark_timer_find_average_overhead = find_flag;
<font color='#880000'>-} /* benchmark_timer_disable_subtracting_average_overhead */
</font><font color='#000088'>+}
</font>
static unsigned short lastLoadedValue;
<font color='#880000'>-/*-------------------------------------------------------------------------+
-| Description: Loads timer 0 with value passed as arguemnt.
-| Returns: Nothing. Loaded value must be a number of clock bits...
-+--------------------------------------------------------------------------*/
</font><font color='#000088'>+/*
+ * Loads timer 0 with value passed as arguemnt.
+ *
+ * Returns: Nothing. Loaded value must be a number of clock bits...
+ */
</font> void loadTimerValue( unsigned short loadedValue )
{
lastLoadedValue = loadedValue;
<font color='#997700'>@@ -333,24 +277,28 @@
</font> outport_byte(TIMER_CNTR0, (loadedValue >> 8) & 0xff);
}
<font color='#880000'>-/*-------------------------------------------------------------------------+
-| Description: Reads the current value of the timer, and converts the
-| number of ticks to micro-seconds.
-| Returns: number of clock bits elapsed since last load.
-+--------------------------------------------------------------------------*/
</font><font color='#000088'>+/*
+ * Reads the current value of the timer, and converts the
+ * number of ticks to micro-seconds.
+ *
+ * Returns: number of clock bits elapsed since last load.
+ */
</font> unsigned int readTimer0(void)
{
unsigned short lsb, msb;
unsigned char status;
<font color='#880000'>- unsigned int count;
</font><font color='#000088'>+ unsigned int count;
</font>
<font color='#880000'>- outport_byte(TIMER_MODE, (TIMER_RD_BACK | (RB_COUNT_0 & ~(RB_NOT_STATUS | RB_NOT_COUNT))));
</font><font color='#000088'>+ outport_byte(
+ TIMER_MODE,
+ (TIMER_RD_BACK | (RB_COUNT_0 & ~(RB_NOT_STATUS | RB_NOT_COUNT)))
+ );
</font> inport_byte(TIMER_CNTR0, status);
inport_byte(TIMER_CNTR0, lsb);
inport_byte(TIMER_CNTR0, msb);
count = ( msb << 8 ) | lsb ;
if (status & RB_OUTPUT )
<font color='#880000'>-<span style="background-color: #FF0000"> </span> count += lastLoadedValue;
</font><font color='#000088'>+ count += lastLoadedValue;
</font>
return (2*lastLoadedValue - count);
}
<font color='#997700'>@@ -387,7 +335,7 @@
</font> rtems_interrupt_level level;
#ifdef DEBUG_CALIBRATE
<font color='#880000'>- printk( "Calibrate_loop_1ms is starting, please wait ( but not too loooong. )\n" );
</font><font color='#000088'>+ printk("Calibrate_loop_1ms is starting, please wait (but not too long.)\n");
</font> #endif
targetClockBits = US_TO_TICK(1000);
<font color='#997700'>@@ -459,9 +407,9 @@
</font> targetClockBits += offset;
#ifdef DEBUG_CALIBRATE
printk("offset = %u, emptyCall = %u, targetClockBits = %u\n",
<font color='#880000'>- offset, emptyCall, targetClockBits);
</font><font color='#000088'>+ offset, emptyCall, targetClockBits);
</font> printk("slowLoopGranularity = %u fastLoopGranularity = %u\n",
<font color='#880000'>- slowLoopGranularity, fastLoopGranularity);
</font><font color='#000088'>+ slowLoopGranularity, fastLoopGranularity);
</font> #endif
slowLoop1ms = (targetClockBits - emptyCall) / slowLoopGranularity;
if (slowLoop1ms != 0) {
<font color='#997700'>@@ -478,33 +426,33 @@
</font>
while(1)
{
<font color='#880000'>- int previousSign = 0; /* 0 = unset, 1 = incrementing, 2 = decrementing */
- Timer0Reset();
- slowLoop(slowLoop1ms);
- currentClockBits = readTimer0();
- if (currentClockBits > targetClockBits) {
- if ((currentClockBits - targetClockBits) < slowLoopGranularity) {
- /* decrement loop counter anyway to be sure slowLoop(slowLoop1ms) < targetClockBits */
- --slowLoop1ms;
- break;
- }
- else {
- --slowLoop1ms;
- if (slowLoop1ms == 0) break;
- if (previousSign == 0) previousSign = 2;
- if (previousSign == 1) break;
- }
- }
- else {
- if ((targetClockBits - currentClockBits) < slowLoopGranularity) {
- break;
- }
- else {
- ++slowLoop1ms;
- if (previousSign == 0) previousSign = 1;
- if (previousSign == 2) break;
- }
- }
</font><font color='#000088'>+ int previousSign = 0; /* 0 = unset, 1 = incrementing, 2 = decrementing */
+ Timer0Reset();
+ slowLoop(slowLoop1ms);
+ currentClockBits = readTimer0();
+ if (currentClockBits > targetClockBits) {
+ if ((currentClockBits - targetClockBits) < slowLoopGranularity) {
+ /* decrement loop counter anyway to be sure slowLoop(slowLoop1ms) < targetClockBits */
+ --slowLoop1ms;
+ break;
+ }
+ else {
+ --slowLoop1ms;
+ if (slowLoop1ms == 0) break;
+ if (previousSign == 0) previousSign = 2;
+ if (previousSign == 1) break;
+ }
+ }
+ else {
+ if ((targetClockBits - currentClockBits) < slowLoopGranularity) {
+ break;
+ }
+ else {
+ ++slowLoop1ms;
+ if (previousSign == 0) previousSign = 1;
+ if (previousSign == 2) break;
+ }
+ }
</font> }
}
/*
<font color='#997700'>@@ -519,22 +467,22 @@
</font> fastLoop(fastLoop1ms);
currentClockBits = readTimer0();
if (currentClockBits > targetClockBits) {
<font color='#880000'>- if ((currentClockBits - targetClockBits) < fastLoopGranularity)
- break;
- else {
- --fastLoop1ms;
- if (previousSign == 0) previousSign = 2;
- if (previousSign == 1) break;
- }
</font><font color='#000088'>+ if ((currentClockBits - targetClockBits) < fastLoopGranularity)
+ break;
+ else {
+ --fastLoop1ms;
+ if (previousSign == 0) previousSign = 2;
+ if (previousSign == 1) break;
+ }
</font> }
else {
<font color='#880000'>- if ((targetClockBits - currentClockBits) < fastLoopGranularity)
- break;
- else {
- ++fastLoop1ms;
- if (previousSign == 0) previousSign = 1;
- if (previousSign == 2) break;
- }
</font><font color='#000088'>+ if ((targetClockBits - currentClockBits) < fastLoopGranularity)
+ break;
+ else {
+ ++fastLoop1ms;
+ if (previousSign == 0) previousSign = 1;
+ if (previousSign == 2) break;
+ }
</font> }
}
}
<font color='#997700'>@@ -545,21 +493,15 @@
</font>
}
<font color='#880000'>-/*-------------------------------------------------------------------------+
-| Function: Wait_X_1ms
-| Description: loop which waits at least timeToWait ms
-| Global Variables: loop1ms
-| Arguments: timeToWait
-| Returns: Nothing.
-+--------------------------------------------------------------------------*/
-void
-Wait_X_ms( unsigned int timeToWait){
-
</font><font color='#000088'>+/*
+ * loop which waits at least timeToWait ms
+ */
+void Wait_X_ms( unsigned int timeToWait)
+{
</font> unsigned int j;
for (j=0; j<timeToWait ; j++) {
if (slowLoop1ms != 0) slowLoop(slowLoop1ms);
fastLoop(fastLoop1ms);
}
<font color='#880000'>-
</font> }
</pre>
<p> </p>
<p>--<br />
<small>Generated by <a href="http://www.codewiz.org/projects/index.html#loginfo">Deluxe Loginfo</a> 2.122 by Bernardo Innocenti <bernie@develer.com></small></p>
</body>
</html>