UoS³ Flight Computer Firmware
Main Page
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Groups
Pages
src
board
gnulinux
random.c
Go to the documentation of this file.
1
11
#include "board.h"
12
13
#include "../random.h"
14
15
#include <time.h>
16
#include <stdlib.h>
17
#include <stdbool.h>
18
19
static
bool
rng_seeded =
false
;
20
21
uint32_t
Random
(uint32_t max)
22
{
23
uint32_t prev, out;
24
25
if
(!rng_seeded)
26
{
27
srand((
unsigned
int
)time(NULL));
28
rng_seeded =
true
;
29
}
30
31
out = (uint32_t)rand();
32
prev = out;
33
34
while
(prev == out)
35
{
36
out = (uint32_t)rand();
37
}
38
39
return
(uint32_t)((float)out * ((
float
)max / (float)RAND_MAX));
40
}
41
Random
uint32_t Random(uint32_t max)
Definition:
random.c:21
Generated by
1.8.6