Linux Functions

usleep
#include <unistd.h>

	usleep(1000);		//uS (unsigned int)
sleep
	sleep(1.5);       //Secs

BCM2835 Library

The bcm2835 library by Mike McCauley includes some useful delay functions:

	bcm2835_delayMicroseconds(100);				//Sleep occasionally so scheduler doesn't penalise us (THIS REQUIRES -lrt ADDING AS A COMPILER FLAG OR IT WILL CAUSE LOCK UP)
    	
	bcm2835_delay(1);		//Delay in mS

Comments

  1. Anonymous

    5 years ago

    Are the sleep / usleep functions blocking?
    I like that they are part of a library that is part of RaspbianOS!
    I have just started trying out C on the RPi, and am still checking out libraries. First lesson has been to try and stick to the standard libaries in /usr/include !
    Thanks
    Bruce