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
USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.

Comments

  1. Anonymous

    2 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

Leave a Reply to Anonymous Cancel reply

Your email address will not be published. Required fields are marked *