Subversion Repositories HomeAutomation

Rev

Blame | Last modification | View Log | SVN | RSS feed

  1. /*
  2.    Precise Delay Functions
  3.    V 0.51, Martin Thomas, 9/2004 & 1/2005
  4.    
  5.    See also delay.h.
  6.    
  7.    Inspired by the avr-libc's loop-code
  8. */
  9.  
  10. #include <avr/io.h>
  11. #include <avr/io.h>
  12. #include <inttypes.h>
  13.  
  14. #include "delay.h"
  15.  
  16. void delayloop32(uint32_t loops)
  17. {
  18.   __asm__ volatile ( "cp  %A0,__zero_reg__ \n\t"  \
  19.                      "cpc %B0,__zero_reg__ \n\t"  \
  20.                      "cpc %C0,__zero_reg__ \n\t"  \
  21.                      "cpc %D0,__zero_reg__ \n\t"  \
  22.                      "breq L_Exit_%=       \n\t"  \
  23.                      "L_LOOP_%=:           \n\t"  \
  24.                      "subi %A0,1           \n\t"  \
  25.                      "sbci %B0,0           \n\t"  \
  26.                      "sbci %C0,0           \n\t"  \
  27.                      "sbci %D0,0           \n\t"  \
  28.                      "brne L_LOOP_%=            \n\t"  \
  29.                      "L_Exit_%=:           \n\t"  \
  30.                      : "=w" (loops)              \
  31.                      : "0"  (loops)              \
  32.                    );                             \
  33.    
  34.     return;
  35. }
  36.