Merge from kseries.
authorbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 7 Jun 2007 14:35:12 +0000 (14:35 +0000)
committerbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 7 Jun 2007 14:35:12 +0000 (14:35 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@796 38d2e660-2303-0410-9eaa-f027e97ec537

drv/ser.c
drv/timer.h
drv/timer_avr.c
drv/timer_avr.h
drv/twi.c
drv/wdt.h

index 5b9f2a362a69d365584da002d5f4b38de3f56a73..8c95a9d774c85b1c107e165d7a5867be5033f8fc 100755 (executable)
--- a/drv/ser.c
+++ b/drv/ser.c
@@ -28,6 +28,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.37  2007/06/07 14:35:12  batt
+ *#* Merge from project_ks.
+ *#*
  *#* Revision 1.36  2007/01/29 11:30:29  batt
  *#* Reimplement ser_clearstatus as a macro.
  *#*
  *#*/
 
 #include "ser.h"
+
+#if CONFIG_WATCHDOG
+       #include "wdt.h"
+#endif
+
 #include "ser_p.h"
 #include <mware/formatwr.h>
 #include <cfg/debug.h>
@@ -201,6 +209,9 @@ int ser_putchar(int c, struct Serial *port)
                /* Attende finche' il buffer e' pieno... */
                do
                {
+#if CONFIG_WATCHDOG
+                       wdt_reset();
+#endif
 #if CONFIG_KERNEL && CONFIG_KERN_SCHED
                        /* Give up timeslice to other processes. */
                        proc_switch();
@@ -245,6 +256,9 @@ int ser_getchar(struct Serial *port)
                /* Wait while buffer is empty */
                do
                {
+#if CONFIG_WATCHDOG
+                       wdt_reset();
+#endif
 #if CONFIG_KERNEL && CONFIG_KERN_SCHED
                        /* Give up timeslice to other processes. */
                        proc_switch();
@@ -491,6 +505,9 @@ void ser_drain(struct Serial *ser)
                        /* Give up timeslice to other processes. */
                        proc_switch();
                #endif
+               #if CONFIG_WATCHDOG
+                       wdt_reset();
+               #endif
        }
 }
 
index 5c1d9001402c60353d4a3358972efe0cb2b7a911..68fdc1dfe80a3d5a340957ac1ff4e8f4b428a500 100755 (executable)
@@ -15,6 +15,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.33  2007/06/07 14:35:12  batt
+ *#* Merge from project_ks.
+ *#*
  *#* Revision 1.32  2007/01/09 08:57:19  bernie
  *#* Remove excess parentheses.
  *#*
@@ -166,7 +169,7 @@ INLINE ticks_t timer_clock(void)
  * interrupt is disabled (DISABLE_INTS) or overridden by a
  * higher-priority or non-nesting interrupt.
  *
- * \sa timer_ticks
+ * \sa timer_clock
  */
 INLINE ticks_t timer_clock_unlocked(void)
 {
index 28f89349a02c9f4a01984fdcbb41d15a8d22fb27..5f203ad6341d8b4642175882ea3274315da0991c 100755 (executable)
@@ -15,6 +15,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.6  2007/06/07 14:35:12  batt
+ *#* Merge from project_ks.
+ *#*
  *#* Revision 1.5  2007/03/21 11:03:56  batt
  *#* Add missing support for ATMega1281.
  *#*
 #include <drv/timer_avr.h>
 #include <cfg/macros.h> // BV()
 
+#include <cfg/cpu.h>
+
 #include <avr/interrupt.h>
 #include <avr/io.h>
 
-#if CPU_AVR_ATMEGA1281
+#if CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA168
        #define REG_TIFR0 TIFR0
        #define REG_TIFR2 TIFR2
 
        }
 
 #elif (CONFIG_TIMER == TIMER_ON_OUTPUT_COMPARE2)
-
        static void timer_hw_init(void)
        {
                cpuflags_t flags;
 
                REG_TCCR2A = BV(WGM21);
                #if TIMER_PRESCALER == 64
-               #if CPU_AVR_ATMEGA1281
-                       // ATMega1281 has undocumented differences in timer2 prescaler!
+               #if CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA168
+                       // ATMega1281 & ATMega168 have undocumented differences in timer2 prescaler!
                        REG_TCCR2B |= BV(CS22);
                #else
                        REG_TCCR2B |= BV(CS21) | BV(CS20);
index 252e772fa59a64bcc98db4adbc14e816c0275457..0155ecc7d9a0287b2310b26b50b77fda1103017e 100755 (executable)
@@ -16,6 +16,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.30  2007/06/07 14:35:12  batt
+ *#* Merge from project_ks.
+ *#*
  *#* Revision 1.29  2007/03/21 11:01:36  batt
  *#* Add missing support for ATMega1281.
  *#*
 
        #define TIMER_PRESCALER      64
        #define TIMER_HW_BITS        8
-       #if CPU_AVR_ATMEGA1281
+       #if CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA168
                #define DEFINE_TIMER_ISR     SIGNAL(SIG_OUTPUT_COMPARE2A)
        #else
                #define DEFINE_TIMER_ISR     SIGNAL(SIG_OUTPUT_COMPARE2)
index d0c6537428369569fd50cea491eeaf89dbf719ac..52112d2f5d7910e26b6ac595dc7a46b3a52f6b48 100755 (executable)
--- a/drv/twi.c
+++ b/drv/twi.c
@@ -15,6 +15,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.8  2007/06/07 14:35:12  batt
+ *#* Merge from project_ks.
+ *#*
  *#* Revision 1.7  2006/07/19 12:56:26  bernie
  *#* Convert to new Doxygen style.
  *#*
@@ -43,7 +46,7 @@
 #include <cfg/debug.h>
 #include <cfg/cpu.h>
 #include <cfg/macros.h> // BV()
-#include <hw.h>
+#include <hw_cpu.h>  /* CLOCK_FREQ */
 #include <appconfig.h>
 
 #include <compat/twi.h>
@@ -238,12 +241,12 @@ void twi_init(void)
                 * probably due to some unwanted interaction between the
                 * port pin and the TWI lines.
                 */
-#if defined(__AVR_ATmega64__)
+#if CPU_AVR_ATMEGA64 || CPU_AVR_ATMEGA128 || CPU_AVR_ATMEGA1281
                PORTD |= BV(PD0) | BV(PD1);
-               DDRD |= BV(PD0) | BV(PD1);
-#elif defined(__AVR_ATmega8__)
+               DDRD  |= BV(PD0) | BV(PD1);
+#elif CPU_AVR_ATMEGA8
                PORTC |= BV(PC4) | BV(PC5);
-               DDRC |= BV(PC4) | BV(PC5);
+               DDRC  |= BV(PC4) | BV(PC5);
 #else
                #error Unsupported architecture
 #endif
index 7ff3e8f693c192c37f1c903bf2d9b6996587ae7d..8abba4791f9accaaf5f9193a62398c06add9c55e 100755 (executable)
--- a/drv/wdt.h
+++ b/drv/wdt.h
@@ -14,6 +14,9 @@
 
 /*#*
  *#* $Log$
+ *#* Revision 1.12  2007/06/07 14:35:12  batt
+ *#* Merge from project_ks.
+ *#*
  *#* Revision 1.11  2006/07/19 12:56:26  bernie
  *#* Convert to new Doxygen style.
  *#*
@@ -75,6 +78,9 @@
        #elif CPU_AVR
                #include <avr/io.h>
                #include <cfg/macros.h> // BV()
+               #if CPU_AVR_ATMEGA1281  // Name is different in atmega1281
+                       #define WDTCR WDTCSR
+               #endif
        #elif defined(ARCH_FREERTOS) && (ARCH & ARCH_FREERTOS)
                #include <task.h> /* taskYIELD() */
        #else