Fix error on short hptime_t CPU.
authorbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 2 Sep 2009 15:16:09 +0000 (15:16 +0000)
committerbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 2 Sep 2009 15:16:09 +0000 (15:16 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2863 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/cpu/arm/drv/timer_at91.h
bertos/cpu/avr/drv/timer_avr.h
bertos/drv/timer.h
bertos/drv/timer_test.c
bertos/emul/timer_qt.h
bertos/os/hptime.h

index 54ba6e37f37f6d693e981b5693aba5954b161eb5..8666893c93fc8e12a1cc4abb48b1f9ee927f40eb 100644 (file)
@@ -75,6 +75,7 @@
 
        /** Type of time expressed in ticks of the hardware high-precision timer */
        typedef uint32_t hptime_t;
+       #define SIZEOF_HPTIME_T 4
 
        INLINE void timer_hw_irq(void)
        {
index 89d0dd76d134c9d5ff8ebb595838e4e0fa9fa2b2..1288057f6d01e3e3f89f08fea6340c43944ad09c 100644 (file)
@@ -83,6 +83,7 @@
 
        /// Type of time expressed in ticks of the hardware high-precision timer
        typedef uint8_t hptime_t;
+       #define SIZEOF_HPTIME_T 1
 
        INLINE hptime_t timer_hw_hpread(void)
        {
 
        /// Type of time expressed in ticks of the hardware high precision timer
        typedef uint16_t hptime_t;
+       #define SIZEOF_HPTIME_T 2
 
        INLINE hptime_t timer_hw_hpread(void)
        {
 
        /// Type of time expressed in ticks of the hardware high precision timer
        typedef uint8_t hptime_t;
+       #define SIZEOF_HPTIME_T 1
 
        INLINE hptime_t timer_hw_hpread(void)
        {
 
        /// Type of time expressed in ticks of the hardware high precision timer
        typedef uint16_t hptime_t;
+       #define SIZEOF_HPTIME_T 2
 
        INLINE hptime_t timer_hw_hpread(void)
        {
index a81b96f3dc0e609cfee5ede75c7be6d4776a516f..40802b543cb9f981f909e6c731fc1e17a8e499b9 100644 (file)
@@ -70,6 +70,8 @@
        #include CPU_HEADER(timer)
 #endif
 
+STATIC_ASSERT(sizeof(hptime_t) == SIZEOF_HPTIME_T);
+
 #include "cfg/cfg_timer.h"
 #include <cfg/debug.h>
 #include <cfg/compiler.h>
index 19522768cbfe36fb68608cdadf16583d209bc866..c3414d79f697dfca648042873be8e70431e61cc2 100644 (file)
@@ -68,7 +68,9 @@ static void timer_test_constants(void)
        kprintf("ticks_to_us(10000) = %lu\n",   (unsigned long)ticks_to_us(10000));
        kprintf("\n");
        kprintf("hptime_to_us(100)  = %lu\n",   (unsigned long)hptime_to_us(100));
-       kprintf("hptime_to_us(10000)= %lu\n",   (unsigned long)hptime_to_us(10000));
+       #if (SIZEOF_HPTIME_T > 1)
+               kprintf("hptime_to_us(10000)= %lu\n",   (unsigned long)hptime_to_us(10000));
+       #endif
        kprintf("us_to_hptime(100)  = %lu\n",   (unsigned long)us_to_hptime(100));
        kprintf("us_to_hptime(10000)= %lu\n",   (unsigned long)us_to_hptime(10000));
 }
index bf02773cf6295550449f5c902fbc2a624e9c062e..70650baeb5b49c4d34ba0c2dbe275e2f924e8fcc 100644 (file)
@@ -47,6 +47,7 @@
 
 /// Type of time expressed in ticks of the hardware high-precision timer.
 typedef unsigned int hptime_t;
+#define SIZEOF_HPTIME_T 4
 
 /// Frequency of the hardware high-precision timer.
 #define TIMER_HW_HPTICKS_PER_SEC  1000
index 0592bd3beadb212f1e40f5bbe3c5a617cb366b7d..d7699d0e5f11875b1d23b5eec449a01539446449 100644 (file)
@@ -45,6 +45,7 @@ extern "C" {
 
        /** our type for "high precision absolute time" */
        typedef __int64 hptime_t;
+       #define SIZEOF_HPTIME_T 8
 
        #define HPTIME_TICKS_PER_SECOND         (10000000I64)
        #define HPTIME_TICKS_PER_MILLISEC       (10000I64)
@@ -63,6 +64,7 @@ extern "C" {
 
        /** Type for "high precision absolute time". */
        typedef int64_t hptime_t;
+       #define SIZEOF_HPTIME_T 8
 
        #define HPTIME_TICKS_PER_SECOND         (1000000LL)
        #define HPTIME_TICKS_PER_MILLISEC       (1000LL)