I'm running a collection of shift register from a pi. I need to clock data into them and want to get this whole operation done in less than a millisecond. I don't need great accuracy but need to have delays atleast 1uS long and ideally less than 10uS long, less than 10uS long is pretty essential. I execute these delays between toggling GPIO pins and there are about 50 such delays involved in the sequence of actions needed to write to my register bank. For shorter delays than 1uS I would be at risk of the shift register not seeing the signals properly (datasheet says ideally not to feed in at >1MHz), for longer delays substantially longer than 20uS I'm getting close to spoiling my hope of getting the setting of the register bank all done in under 1ms. I stress than accurate timing isn't critical, just creating a delay which is always between the upper (20uS but ideally 10uS) and lower (1uS) time limits.I can cope if it occasionally takes longer than 20uS but don't want it to be always, or often, taking 80uS or some other time period >> 10uS.
I use the bcm2835 library for all my GPIO stuff and it works well, I certainly can't change library and start using pigpio or wiringpi at this point, I've got far too much stuff working perfectly in bcm2835. I know the bcm2835 library does a microseconds delay function but it apparently gives a whole 80uS of delay when told to give a zero uS delay, so it can't do 1 to 20uS delay times.
I've heard about busy waits but am not sure quite what these are. I've also heard mentions of micro and nano sleep functions but have seen warnings about them not working well at all. I would wonder about doing a pointless iteration of a while loop with a few instructions on each cycle of it, but can't be sure how long that would actually take and whether, as the Pi's non-realtime raspbian operating system shifts between executing different processes, any such attempt to work this out would become futile if different amounts of background tasks were running on the pi at the time.