summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-06-09 15:49:44 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-06-09 15:49:44 +0000
commit05dd8c79b40af0221973ba0ee19ee0066c3a8dde (patch)
tree6aa570fa88dbc3e31d4d6061276f3f72c21b3ff3
parent747de88ae98ba1e232db4c61b01b114772236c02 (diff)
downloadnuttx-05dd8c79b40af0221973ba0ee19ee0066c3a8dde.tar.gz
nuttx-05dd8c79b40af0221973ba0ee19ee0066c3a8dde.tar.bz2
nuttx-05dd8c79b40af0221973ba0ee19ee0066c3a8dde.zip
Add support for custom system timer frequency
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@274 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/ChangeLog4
-rw-r--r--nuttx/Documentation/NuttX.html6
-rw-r--r--nuttx/Documentation/NuttxPortingGuide.html6
-rw-r--r--nuttx/TODO4
-rw-r--r--nuttx/configs/README.txt5
-rw-r--r--nuttx/configs/c5471evm/defconfig5
-rw-r--r--nuttx/configs/m68332evb/defconfig5
-rw-r--r--nuttx/configs/mcu123-lpc214x/defconfig5
-rw-r--r--nuttx/configs/ntosd-dm320/defconfig5
-rw-r--r--nuttx/configs/pjrc-8051/defconfig5
-rw-r--r--nuttx/configs/sim/defconfig5
-rw-r--r--nuttx/include/limits.h20
-rw-r--r--nuttx/include/time.h11
-rw-r--r--nuttx/sched/clock_internal.h28
14 files changed, 97 insertions, 17 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 416f47873..4280c0b61 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -161,6 +161,8 @@
* sched/usleep.c: Fixed nsec calculation
* lib/lib_strcspn.c: Function incorrectly named strspn().
* examples/ostest/main.c: Errors in SDCC version of a memcpy() call
- * examples/ostest/sighandl.c: Don't call fflush() if streams are disabled
+ * examples/ostest/sighand.c: Don't call fflush() if streams are disabled
+ * include/limits.h, include/time.h, sched/clock_internal.h: A support for
+ using selectable system timer frequency.
* Started m68322
diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html
index c68001742..6b5d03248 100644
--- a/nuttx/Documentation/NuttX.html
+++ b/nuttx/Documentation/NuttX.html
@@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
- <p>Last Updated: May 26, 2007</p>
+ <p>Last Updated: June 9, 2007</p>
</td>
</tr>
</table>
@@ -595,7 +595,9 @@ Other memory:
* sched/usleep.c: Fixed nsec calculation
* lib/lib_strcspn.c: Function incorrectly named strspn().
* examples/ostest/main.c: Errors in SDCC version of a memcpy() call
- * examples/ostest/sighandl.c: Don't call fflush() if streams are disabled
+ * examples/ostest/sighand.c: Don't call fflush() if streams are disabled
+ * include/limits.h, include/time.h, sched/clock_internal.h: A support for
+ using selectable system timer frequency.
* Started m68322
</pre></ul>
diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html
index 8cd9d06e3..38ab0c31e 100644
--- a/nuttx/Documentation/NuttxPortingGuide.html
+++ b/nuttx/Documentation/NuttxPortingGuide.html
@@ -1164,6 +1164,12 @@ The system can be re-made subsequently by just typing <code>make</code>.
handle and enables the API mm_addregion(start, end);
</li>
<li>
+ <code>CONFIG_TICKS_PER_MSEC</code>: The default system timer is 100Hz
+ or <code>TICKS_PER_MSEC</code>=10. This setting may be defined to inform NuttX
+ that the processor hardware is providing system timer interrupts at some interrupt
+ interval other than 10 msec.
+ </li>
+ <li>
<code>CONFIG_RR_INTERVAL</code>: The round robin timeslice will be set
this number of milliseconds; Round robin scheduling can
be disabled by setting this value to zero.
diff --git a/nuttx/TODO b/nuttx/TODO
index 0f16e150f..3c5a1e83e 100644
--- a/nuttx/TODO
+++ b/nuttx/TODO
@@ -7,10 +7,6 @@ o Task/Scheduler
- Implement sys/mman.h and functions
- Implement sys/wait.h and functions
- Implement priority inheritance
-- Make the system timer frequency configurable via defconfig. See:
- _POSIX_CLOCKRES_MIN in limits.h
- CLK_TCK in time.h
- MSEC_PER_TICK in sched/clock_internal.h
- Consider implementing wait, waitpid, waitid. At present, a parent has
no information about child tasks.
- Several APIs do not set errno. Need to review all APIs.
diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt
index 77d41e131..a123a1f01 100644
--- a/nuttx/configs/README.txt
+++ b/nuttx/configs/README.txt
@@ -132,6 +132,11 @@ defconfig -- This is a configuration file similar to the Linux
regions of memory to allocate from, this specifies the
number of memory regions that the memory manager must
handle and enables the API mm_addregion(start, end);
+ CONFIG_TICKS_PER_MSEC - The default system timer is 100Hz
+ or TICKS_PER_MSEC=10. This setting may be defined to
+ inform NuttX that the processor hardware is providing
+ system timer interrupts at some interrupt interval other
+ than 10 msec.
CONFIG_RR_INTERVAL - The round robin timeslice will be set
this number of milliseconds; Round robin scheduling can
be disabled by setting this value to zero.
diff --git a/nuttx/configs/c5471evm/defconfig b/nuttx/configs/c5471evm/defconfig
index a534ae283..e247d9e87 100644
--- a/nuttx/configs/c5471evm/defconfig
+++ b/nuttx/configs/c5471evm/defconfig
@@ -109,6 +109,11 @@ CONFIG_UART_MODEM_2STOP=0
# handle and enables the API mm_addregion(start, end);
# CONFIG_HAVE_LOWPUTC - architecture supports low-level, boot
# time console output
+# CONFIG_TICKS_PER_MSEC - The default system timer is 100Hz
+# or TICKS_PER_MSEC=10. This setting may be defined to
+# inform NuttX that the processor hardware is providing
+# system timer interrupts at some interrupt interval other
+# than 10 msec.
# CONFIG_RR_INTERVAL - The round robin timeslice will be set
# this number of milliseconds; Round robin scheduling can
# be disabled by setting this value to zero.
diff --git a/nuttx/configs/m68332evb/defconfig b/nuttx/configs/m68332evb/defconfig
index 2df6f2e51..2185e760a 100644
--- a/nuttx/configs/m68332evb/defconfig
+++ b/nuttx/configs/m68332evb/defconfig
@@ -98,6 +98,11 @@ CONFIG_UART1_2STOP=0
# handle and enables the API mm_addregion(start, end);
# CONFIG_HAVE_LOWPUTC - architecture supports low-level, boot
# time console output
+# CONFIG_TICKS_PER_MSEC - The default system timer is 100Hz
+# or TICKS_PER_MSEC=10. This setting may be defined to
+# inform NuttX that the processor hardware is providing
+# system timer interrupts at some interrupt interval other
+# than 10 msec.
# CONFIG_RR_INTERVAL - The round robin timeslice will be set
# this number of milliseconds; Round robin scheduling can
# be disabled by setting this value to zero.
diff --git a/nuttx/configs/mcu123-lpc214x/defconfig b/nuttx/configs/mcu123-lpc214x/defconfig
index e9e97326b..ca0c9a153 100644
--- a/nuttx/configs/mcu123-lpc214x/defconfig
+++ b/nuttx/configs/mcu123-lpc214x/defconfig
@@ -122,6 +122,11 @@ CONFIG_UART1_2STOP=0
# handle and enables the API mm_addregion(start, end);
# CONFIG_HAVE_LOWPUTC - architecture supports low-level, boot
# time console output
+# CONFIG_TICKS_PER_MSEC - The default system timer is 100Hz
+# or TICKS_PER_MSEC=10. This setting may be defined to
+# inform NuttX that the processor hardware is providing
+# system timer interrupts at some interrupt interval other
+# than 10 msec.
# CONFIG_RR_INTERVAL - The round robin timeslice will be set
# this number of milliseconds; Round robin scheduling can
# be disabled by setting this value to zero.
diff --git a/nuttx/configs/ntosd-dm320/defconfig b/nuttx/configs/ntosd-dm320/defconfig
index aa6270250..640783cf1 100644
--- a/nuttx/configs/ntosd-dm320/defconfig
+++ b/nuttx/configs/ntosd-dm320/defconfig
@@ -107,6 +107,11 @@ CONFIG_UART1_2STOP=0
# handle and enables the API mm_addregion(start, end);
# CONFIG_HAVE_LOWPUTC - architecture supports low-level, boot
# time console output
+# CONFIG_TICKS_PER_MSEC - The default system timer is 100Hz
+# or TICKS_PER_MSEC=10. This setting may be defined to
+# inform NuttX that the processor hardware is providing
+# system timer interrupts at some interrupt interval other
+# than 10 msec.
# CONFIG_RR_INTERVAL - The round robin timeslice will be set
# this number of milliseconds; Round robin scheduling can
# be disabled by setting this value to zero.
diff --git a/nuttx/configs/pjrc-8051/defconfig b/nuttx/configs/pjrc-8051/defconfig
index bc6084f0b..c9b8a481a 100644
--- a/nuttx/configs/pjrc-8051/defconfig
+++ b/nuttx/configs/pjrc-8051/defconfig
@@ -95,6 +95,11 @@ CONFIG_LED_DEBUG=n
# handle and enables the API mm_addregion(start, end);
# CONFIG_HAVE_LOWPUTC - architecture supports low-level, boot
# time console output
+# CONFIG_TICKS_PER_MSEC - The default system timer is 100Hz
+# or TICKS_PER_MSEC=10. This setting may be defined to
+# inform NuttX that the processor hardware is providing
+# system timer interrupts at some interrupt interval other
+# than 10 msec.
# CONFIG_RR_INTERVAL - The round robin timeslice will be set
# this number of milliseconds; Round robin scheduling can
# be disabled by setting this value to zero.
diff --git a/nuttx/configs/sim/defconfig b/nuttx/configs/sim/defconfig
index 59f05d4ac..e5940848e 100644
--- a/nuttx/configs/sim/defconfig
+++ b/nuttx/configs/sim/defconfig
@@ -63,6 +63,11 @@ CONFIG_ARCH_BOARD_SIM=y
# handle and enables the API mm_addregion(start, end);
# CONFIG_HAVE_LOWPUTC - architecture supports low-level, boot
# time console output
+# CONFIG_TICKS_PER_MSEC - The default system timer is 100Hz
+# or TICKS_PER_MSEC=10. This setting may be defined to
+# inform NuttX that the processor hardware is providing
+# system timer interrupts at some interrupt interval other
+# than 10 msec.
# CONFIG_RR_INTERVAL - The round robin timeslice will be set
# this number of milliseconds; Round robin scheduling can
# be disabled by setting this value to zero.
diff --git a/nuttx/include/limits.h b/nuttx/include/limits.h
index 285eea684..d32c7177a 100644
--- a/nuttx/include/limits.h
+++ b/nuttx/include/limits.h
@@ -114,11 +114,27 @@
#define _POSIX_RTSIG_MAX 31
#define _POSIX_SIGQUEUE_MAX 32
-/* Required for POSIX timers */
+/* Required for POSIX timers.
+ *
+ * _POSIX_DELAYTIMER_MAX is the number of timer expiration overruns.
+ *
+ * _POSIX_TIMER_MAX is the per-process number of timers.
+ *
+ * _POSIX_CLOCKRES_MIN is the resolution of the CLOCK_REALTIME clock in nanoseconds.
+ * CLOCK_REALTIME is controlled by the NuttX system time. The default value is the
+ * system timer which has a resolution of 10 milliseconds. This default setting can
+ * be overridden by defining the clock interval in milliseconds as CONFIG_MSEC_PER_TICK
+ * in the board configuration file.
+ */
#define _POSIX_DELAYTIMER_MAX 32
#define _POSIX_TIMER_MAX 32
-#define _POSIX_CLOCKRES_MIN 10000000
+
+#ifdef CONFIG_MSEC_PER_TICK
+# define _POSIX_CLOCKRES_MIN ((CONFIG_MSEC_PER_TICK)*1000000)
+#else
+# define _POSIX_CLOCKRES_MIN (10*1000000)
+#endif
/* Required for asynchronous I/O */
diff --git a/nuttx/include/time.h b/nuttx/include/time.h
index 7a9731423..92b849fbe 100644
--- a/nuttx/include/time.h
+++ b/nuttx/include/time.h
@@ -51,9 +51,16 @@
* Definitions
********************************************************************************/
-/* Clock tick of the system */
+/* Clock tick of the system (frequency Hz). The default value is 100Hz, but this
+ * default setting can be overridden by defining the clock interval in
+ * milliseconds as CONFIG_MSEC_PER_TICK in the board configuration file.
+ */
-#define CLK_TCK 100
+#ifdef CONFIG_MSEC_PER_TICK
+# define CLK_TCK (1000/CONFIG_MSEC_PER_TICK)
+#else
+# define CLK_TCK (100)
+#endif
/* This is the only clock_id supported by the "Clock and Timer
* Functions."
diff --git a/nuttx/sched/clock_internal.h b/nuttx/sched/clock_internal.h
index 85cb13f06..2f7a9c783 100644
--- a/nuttx/sched/clock_internal.h
+++ b/nuttx/sched/clock_internal.h
@@ -40,6 +40,7 @@
* Included Files
********************************************************************************/
+#include <nuttx/config.h>
#include <sys/types.h>
#include <nuttx/compiler.h>
@@ -56,7 +57,20 @@
#define USEC_PER_MSEC 1000
#define NSEC_PER_USEC 1000
-#define MSEC_PER_TICK 10
+/* The interrupt interval of the system timer is given by MSEC_PER_TICK. This
+ * is the expected number of milliseconds between calls from the processor-
+ * specific logic to sched_process_timer(). The default value of MSEC_PER_TICK
+ * is 10 milliseconds (100KHz). However, this default setting can be overridden
+ * by defining the interval in milliseconds as CONFIG_MSEC_PER_TICK in the board
+ * configuration file.
+ */
+
+#ifdef CONFIG_MSEC_PER_TICK
+# define MSEC_PER_TICK (CONFIG_MSEC_PER_TICK)
+#else
+# define MSEC_PER_TICK (10)
+#endif
+
#define USEC_PER_TICK (MSEC_PER_TICK * USEC_PER_MSEC)
#define NSEC_PER_TICK (MSEC_PER_TICK * NSEC_PER_MSEC)
#define TICK_PER_SEC (MSEC_PER_SEC / MSEC_PER_TICK)
@@ -64,13 +78,15 @@
#define MSEC2TICK(msec) (((msec)+(MSEC_PER_TICK/2))/MSEC_PER_TICK)
#define USEC2TICK(usec) (((usec)+(USEC_PER_TICK/2))/USEC_PER_TICK)
-#define JD_OF_EPOCH 2440588 /* Julian Date of noon, J1970 */
+#define JD_OF_EPOCH 2440588 /* Julian Date of noon, J1970 */
#ifdef CONFIG_JULIAN_TIME
-# define GREG_DUTC -141427 /* Default is October 15, 1582 */
-# define GREG_YEAR 1582
-# define GREG_MONTH 10
-# define GREG_DAY 15
+
+# define GREG_DUTC -141427 /* Default is October 15, 1582 */
+# define GREG_YEAR 1582
+# define GREG_MONTH 10
+# define GREG_DAY 15
+
#endif /* CONFIG_JULIAN_TIME */
/********************************************************************************