avr/base/base.c

22 lines
398 B
C
Raw Normal View History

2022-05-08 00:16:20 +00:00
#include "base.h"
2022-05-07 23:49:54 +00:00
rng_t rng_new(uint8_t seed) {
2022-05-08 00:16:20 +00:00
rng_t rng = { .mod = 255, .a = 253, .c = 41, .seed = seed };
return rng;
2022-05-07 23:49:54 +00:00
}
uint8_t rng_sample(rng_t *state) {
state->seed = (state->a * state->seed + state->c) % state->mod;
return state->seed;
}
2022-06-26 15:38:20 +00:00
/*
void strobe_line(gpio_t *line, uint32_t us) {
set_line(line);
_delay_us(us);
clear_line(line);
_delay_us(us);
}
*/