| 1 |
/* |
| 2 |
comedi_calibrate/other.c - functions that might move to the library |
| 3 |
Copyright (C) 2002 David A. Schleef <[email protected]> |
| 4 |
|
| 5 |
This program is free software; you can redistribute it and/or modify |
| 6 |
it under the terms of version 2 of the GNU General Public License as |
| 7 |
published by the Free Software Foundation. |
| 8 |
|
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License |
| 15 |
along with this program; if not, write to the Free Software |
| 16 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 |
*/ |
| 18 |
|
| 19 |
|
| 20 |
#include <comedilib.h> |
| 21 |
#include <unistd.h> |
| 22 |
#include <string.h> |
| 23 |
|
| 24 |
void comedi_nanodelay(comedi_t *dev, unsigned int delay) |
| 25 |
{ |
| 26 |
comedi_insn insn; |
| 27 |
lsampl_t data = delay; |
| 28 |
int retval; |
| 29 |
|
| 30 |
memset(&insn, 0, sizeof(insn)); |
| 31 |
insn.insn = INSN_WAIT; |
| 32 |
insn.n = 1; |
| 33 |
insn.data = &data; |
| 34 |
retval = comedi_do_insn( dev, &insn ); |
| 35 |
// fall back on usleep for long delays |
| 36 |
if( retval < 0 ) |
| 37 |
usleep( delay / 1000 ); |
| 38 |
|
| 39 |
return; |
| 40 |
} |
| 41 |
|
| 42 |
|