Exemplo n.º 1
0
static inline void
write_zero() {
	digitalWrite(PIN, LOW);
	delayMicrosecondsHard(9);
	digitalWrite(PIN, HIGH); 
	delayMicrosecondsHard(19);
	digitalWrite(PIN, LOW);
}
Exemplo n.º 2
0
int blink(int x)
{
	wiringPiSetup();
	pinMode(PIN, OUTPUT);
	int j;
	for(j = 0; j < 10; j++)
	{
		digitalWrite(PIN, HIGH); delayMicrosecondsHard(x);
		digitalWrite(PIN, LOW); delayMicrosecondsHard(x);
	}
	return 0;
}
Exemplo n.º 3
0
value caml_time_delay_microseconds(value ms)
{
  CAMLparam1 (ms);
  unsigned int delay = Int_val(ms);
#ifdef DEBUG
  printf("entering delay_microseconds returning: %d\n", delay);
#endif
  struct timespec sleeper ;
  struct timespec remainder ;
  if (delay == 0) return ;
  else if (delay < 100)
    delayMicrosecondsHard (delay) ;
  else {
    sleeper.tv_sec  = (long)(delay/1000000);
    sleeper.tv_nsec = (long)((delay%1000000) * 1000);
    while (-1 == nanosleep (&sleeper, &remainder)) {
      sleeper.tv_sec  = remainder.tv_sec;
      sleeper.tv_nsec = remainder.tv_nsec;
    }
  }
#ifdef DEBUG
  printf("delay_microseconds returning: %d\n", delay);
#endif
  CAMLreturn (Val_unit);
}
Exemplo n.º 4
0
static inline void write_begin() {
	wiringPiSetup();
	pinMode(PIN, OUTPUT);
	digitalWrite(PIN, HIGH); 
	delayMicrosecondsHard(10);
	digitalWrite(PIN, LOW);
}
Exemplo n.º 5
0
void delayMicrosecondsWPi (unsigned int howLong)
{
  struct timespec sleeper ;

  /**/ if (howLong ==   0)
    return ;
  else if (howLong  < 100)
    delayMicrosecondsHard (howLong) ;
  else
  {
    sleeper.tv_sec  = 0 ;
    sleeper.tv_nsec = (long)(howLong * 1000) ;
    nanosleep (&sleeper, NULL) ;
  }
}
Exemplo n.º 6
0
void delayMicrosecs(unsigned int howLong) {
	struct timespec sleeper;
	unsigned int uSecs = howLong % 1000000;
	unsigned int wSecs = howLong / 1000000;

	/**/if (howLong == 0)
		return;
	else if (howLong < 100)
		delayMicrosecondsHard(howLong);
	else {
		sleeper.tv_sec = wSecs;
		sleeper.tv_nsec = (long) (uSecs * 1000L);
		nanosleep(&sleeper, NULL);
	}
}
Exemplo n.º 7
0
void delayMicroseconds(unsigned int howLong) {
	struct timespec sleeper;
	long int uSecs = (__time_t)howLong % 1000000;
	unsigned int wSecs = howLong / 1000000;

	if(howLong == 0) {
		return;
	} else if(howLong  < 100) {
		delayMicrosecondsHard(howLong);
	} else {
		sleeper.tv_sec = (__time_t)wSecs;
		sleeper.tv_nsec = (long)(uSecs * 1000L);
		nanosleep(&sleeper, NULL);
	}
}
Exemplo n.º 8
0
//dwell is time in tenth's of seconds.  So, if want to count for 1 sec, pass '10'
int getUSB1208Counter(unsigned short dwell, long int * returncounts){
    int counts,i;
    counts=0;
    for (i=0;i<dwell;i++){ 
        /* the for loop is used instead of putting dwell in the delayMicroseconds.
           In high count rates (not likely for us, but could be) the USB counter could 'roll over'
           during a very long dwell time.  So, by doing smaller chunks and adding, less 
           chance of roll over. 
           */
        usbInitCounter_USB1208LS(hid);
        delayMicrosecondsHard(100000); // wiringPi
        counts+=usbReadCounter_USB1208LS(hid);
    }
    *returncounts=counts;
    return 0;
}
Exemplo n.º 9
0
void delayMicroseconds(unsigned int howLong) {
	struct timespec sleeper;
#ifdef _WIN32
	long int uSecs = howLong % 1000000;
	unsigned int wSecs = howLong / 1000000;
#else
	long int uSecs = (__time_t)howLong % 1000000;
	unsigned int wSecs = howLong / 1000000;
#endif

	if(howLong == 0) {
		return;
	} else if(howLong  < 100) {
		delayMicrosecondsHard(howLong);
	} else {
#ifdef _WIN32
		sleeper.tv_sec = wSecs;
#else
		sleeper.tv_sec = (__time_t)wSecs;	
#endif
		sleeper.tv_nsec = (long)(uSecs * 1000L);
		nanosleep(&sleeper, NULL);
	}
}
Exemplo n.º 10
0
static inline void
write_end() {
	digitalWrite(PIN, LOW);
	delayMicrosecondsHard(40);
}