PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Utility
libsimpletools
source
random.c
1
/*
2
* @file random.c
3
*
4
* @author Andy Lindsay
5
*
6
* @version 1.1.8
7
*
8
* @copyright Copyright (C) Parallax, Inc. 2018. See end of file for
9
* terms of use (MIT License).
10
*
11
* @brief random function source, see simpletools.h for documentation.
12
*
13
* @detail Please submit bug reports, suggestions, and improvements to
14
* this code to editor@parallax.com.
15
*/
16
17
static
int
seeded = 0;
18
19
#include "
simpletools.h
"
20
21
22
int
random
(
int
limitLow,
int
limitHigh)
23
{
24
if
(!seeded)
25
{
26
srand(
INA
+
CNT
);
27
seeded = 1;
28
}
29
30
if
(limitLow > limitHigh)
31
{
32
int
temp = limitLow;
33
limitLow = limitHigh;
34
limitHigh = temp;
35
}
36
return
(limitLow + (rand() % ((limitHigh + 1) - limitLow)) );
37
}
38
39
40
41
63
INA
#define INA
Use to read the pins when corresponding DIRA bits are 0.
Definition:
propeller1.h:153
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
random
int random(int limitLow, int limitHigh)
Generates a pseudo-random integer value that falls in a range from limitLow to limitHigh....
Definition:
random.c:22
CNT
#define CNT
The system clock count.
Definition:
propeller1.h:151
Generated on Fri May 20 2022 16:48:05 for PropWare by
1.8.17