mirror of
https://github.com/Keychron/qmk_firmware.git
synced 2024-12-29 12:48:52 +06:00
18 lines
405 B
C
18 lines
405 B
C
|
// Copyright 2021 Nicolas Druoton (druotoni)
|
||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||
|
#include "fast_random.h"
|
||
|
|
||
|
// seed for random
|
||
|
static unsigned long g_seed = 0;
|
||
|
|
||
|
int fastrand(void) {
|
||
|
// todo : try with random16();
|
||
|
g_seed = (214013 * g_seed + 2531011);
|
||
|
return (g_seed >> 16) & 0x7FFF;
|
||
|
}
|
||
|
|
||
|
unsigned long fastrand_long(void) {
|
||
|
g_seed = (214013 * g_seed + 2531011);
|
||
|
return g_seed;
|
||
|
}
|