dc31-addon-addon-badge-firm.../badge_firmware/code/inc/prng.h

38 lines
641 B
C

/*
* prng.h
*
* Created on: Aug 3, 2023
* Author: true
*/
#ifndef CODE_INC_PRNG_H_
#define CODE_INC_PRNG_H_
/**
* tinymt32 internal state vector and parameters
*/
typedef struct {
uint32_t status[4];
uint32_t mat1;
uint32_t mat2;
uint32_t tmat;
} tinymt32_t;
extern tinymt32_t tinymt32_s;
void tinymt32_init(tinymt32_t *s, uint32_t seed);
uint32_t tinymt32_get_uint32(tinymt32_t* s);
#define prng_get8() (tinymt32_get_uint32(&tinymt32_s) & 0xff)
#define prng_get16() (tinymt32_get_uint32(&tinymt32_s) & 0xffff)
#define prng_get32() tinymt32_get_uint32(&tinymt32_s)
#endif /* CODE_INC_PRNG_H_ */