[En-Nut-Discussion] Usage of NutDelay() in arch/avr/dev/ and probably else

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Mon Feb 23 19:28:37 CET 2009


Hello,

with the heartbeat setting on a port pin when idle (and not toggling), I could
see something hogging the AVR CPU for long on my board. After some looking I
saw that that was  
_ioctl(_fileno(owi_uart), UART_SETSPEED, &baud_presence);
on the AT90CAN128 builtin device, when switching speeds to implement
One-Wire Transactions via the UART. This boiled down to the usage of
NutDelay(), even when NutSleep() was available. Appended patch fixes the
problem for arch/avr/dev/usartavr.c and arch/avr/dev/uartavr.c

But isn't the problem more general:
arch/avr/dev> grep NutDelay *c |wc
     42     112    1402
> grep NutSleep *c | wc
     31      84    1083

Shouldn't even NutDelay() itself resolve to NutSleep(), if NutSleep() is
available? 

Any comments

Thanks
-- 
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Index: arch/avr/dev/usartavr.c
===================================================================
--- arch/avr/dev/usartavr.c	(Revision 1033)
+++ arch/avr/dev/usartavr.c	(Arbeitskopie)
@@ -528,7 +528,11 @@
     /*
      * Allow incoming or outgoing character to finish.
      */
+#if defined(NUT_CPU_FREQ)    
+    NutSleep(10);
+#else
     NutDelay(10);
+#endif
 
     /*
      * Disable USART transmit and receive.
Index: arch/avr/dev/uartavr.c
===================================================================
--- arch/avr/dev/uartavr.c	(Revision 1033)
+++ arch/avr/dev/uartavr.c	(Arbeitskopie)
@@ -344,7 +344,11 @@
     /*
      * Allow incoming or outgoing character to finish.
      */
+#if defined(NUT_CPU_FREQ)    
+    NutSleep(10);
+#else
     NutDelay(10);
+#endif
 
     /*
      * Now disable UART functions.



More information about the En-Nut-Discussion mailing list