~abogani/ubuntu/lucid/avr-libc/avr-libc.fix-FTBFS

« back to all changes in this revision

Viewing changes to include/util/delay.h

  • Committer: Bazaar Package Importer
  • Author(s): Hakan Ardo
  • Date: 2007-12-29 16:20:03 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20071229162003-lyyrt60vipc9xbwm
Tags: 1:1.4.7-1
* New upstream release (closes: #410831, #420163, #421088, #452199, #394231)
* Replaced tetex packages with texlive in Build-Depends (closes:
  #427266)
* Now ignores returnstatus of pdflatex when generating docs to prevent
  the build processing from halting on latex warnings (closes:
  #427266)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Copyright (c) 2002, Marek Michalkiewicz
2
2
   Copyright (c) 2004,2005,2007 Joerg Wunsch
 
3
   Copyright (c) 2007  Florin-Viorel Petrov
3
4
   All rights reserved.
4
5
 
5
6
   Redistribution and use in source and binary forms, with or without
29
30
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
31
  POSSIBILITY OF SUCH DAMAGE. */
31
32
 
32
 
/* $Id: delay.h,v 1.1.2.3 2007/05/13 21:26:06 joerg_wunsch Exp $ */
 
33
/* $Id: delay.h,v 1.1.2.4 2007/10/28 23:26:40 joerg_wunsch Exp $ */
33
34
 
34
35
#ifndef _UTIL_DELAY_H_
35
36
#define _UTIL_DELAY_H_ 1
98
99
   constant defining the CPU clock frequency (in Hertz).
99
100
 
100
101
   The maximal possible delay is 768 us / F_CPU in MHz.
 
102
 
 
103
   If the user requests a delay greater than the maximal possible one,
 
104
   _delay_us() will automatically call _delay_ms() instead.  The user
 
105
   will not be informed about this case.
101
106
 */
102
107
void
103
108
_delay_us(double __us)
107
112
        if (__tmp < 1.0)
108
113
                __ticks = 1;
109
114
        else if (__tmp > 255)
110
 
                __ticks = 0;    /* i.e. 256 */
 
115
        {
 
116
                _delay_ms(__us / 1000.0);
 
117
                return;
 
118
        }
111
119
        else
112
120
                __ticks = (uint8_t)__tmp;
113
121
        _delay_loop_1(__ticks);
123
131
   constant defining the CPU clock frequency (in Hertz).
124
132
 
125
133
   The maximal possible delay is 262.14 ms / F_CPU in MHz.
 
134
 
 
135
   When the user request delay which exceed the maximum possible one,
 
136
   _delay_ms() provides a decreased resolution functionality. In this
 
137
   mode _delay_ms() will work with a resolution of 1/10 ms, providing
 
138
   delays up to 6.5535 seconds (independent from CPU frequency).  The
 
139
   user will not be informed about decreased resolution.
126
140
 */
127
141
void
128
142
_delay_ms(double __ms)
132
146
        if (__tmp < 1.0)
133
147
                __ticks = 1;
134
148
        else if (__tmp > 65535)
135
 
                __ticks = 0;    /* i.e. 65536 */
 
149
        {
 
150
                //      __ticks = requested delay in 1/10 ms
 
151
                __ticks = (uint16_t) (__ms * 10.0);
 
152
                while(__ticks)
 
153
                {
 
154
                        // wait 1/10 ms
 
155
                        _delay_loop_2(((F_CPU) / 4e3) / 10);
 
156
                        __ticks --;
 
157
                }
 
158
                return;
 
159
        }
136
160
        else
137
161
                __ticks = (uint16_t)__tmp;
138
162
        _delay_loop_2(__ticks);