ba13d329f861cc0717a227ee6eab248a51b74f26
[rpi-open-firmware.git] / lib / udelay.c
1 /*=============================================================================
2 Copyright (C) 2016 Kristina Brooks
3 All rights reserved.
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 FILE DESCRIPTION
16 Simple timer based delay routine.
17
18 =============================================================================*/
19
20 #ifdef __arm__
21 #include <stdint.h>
22 #else
23 #include "common.h"
24 #endif
25
26 #include "../hardware.h"
27
28
29 void udelay(uint32_t t) {
30 uint32_t tv = ST_CLO;
31
32 for (;;) {
33 /* nop still takes a cycle i think? */
34 __asm__ __volatile__ ("nop" :::);
35 if ((ST_CLO - tv) > t)
36 return;
37 }
38 }
This page took 0.061717 seconds and 3 git commands to generate.