OpENer - Open Source EtherNet/IP(TM) I/O Target Stack  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
xorshiftrandom.c
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright (c) 2017, Rockwell Automation, Inc.
3  * All rights reserved.
4  *
5  ******************************************************************************/
6 
7 #include "xorshiftrandom.h"
8 
9 static uint32_t xor_shift_seed;
11 void SetXorShiftSeed(uint32_t seed) {
12  xor_shift_seed = seed;
13 }
14 
19 void CalculateNextSeed(void) {
20  xor_shift_seed ^= xor_shift_seed << 13;
21  xor_shift_seed ^= xor_shift_seed >> 17;
22  xor_shift_seed ^= xor_shift_seed << 5;
23 }
24 
25 uint32_t NextXorShiftUint32(void) {
27  return xor_shift_seed;
28 }
uint32_t NextXorShiftUint32(void)
Returns the next generated pseudo-random number.
void CalculateNextSeed(void)
Pseudo-random number algorithm The algorithm used to create the pseudo-random numbers. Works directly on the file global variable.
void SetXorShiftSeed(uint32_t seed)
Sets the initial seed for the XOR shift pseudo-random algorithm.