1/*
2 * Copyright 2017, Data61
3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 * ABN 41 687 119 230.
5 *
6 * This software may be distributed and modified according to the terms of
7 * the GNU General Public License version 2. Note that NO WARRANTY is provided.
8 * See "LICENSE_GPLv2.txt" for details.
9 *
10 * @TAG(DATA61_GPL)
11 */
12
13#include <stdio.h>
14#include <stdint.h>
15#include <ctype.h>
16
17void udelay(uint32_t us){
18    volatile int i;
19    for(; us > 0; us--){
20        for(i = 0; i < 100; i++){
21        }
22    }
23}
24
25unsigned long simple_strtoul(const char *cp, char **endp,
26				unsigned int base)
27{
28	unsigned long result = 0;
29	unsigned long value;
30
31	if (*cp == '0') {
32		cp++;
33		if ((*cp == 'x') && isxdigit(cp[1])) {
34			base = 16;
35			cp++;
36		}
37
38		if (!base)
39			base = 8;
40	}
41
42	if (!base)
43		base = 10;
44
45	while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp)
46	    ? toupper(*cp) : *cp)-'A'+10) < base) {
47		result = result*base + value;
48		cp++;
49	}
50
51	if (endp)
52		*endp = (char *)cp;
53
54	return result;
55}
56