/* ANY-LICENSE V1.0 ---------------- You can use these files under any license approved by the Open Source Initiative, preferrably one of the popular licenses, as long as the license you choose is compatible to the dependencies of these files. See http://www.opensource.org/licenses/ for a list of approved licenses. Author: Martin Furter Project: Tins AVR Lib Repository: http://repos.borg.ch/projects/tins_avr_lib/trunk Copyright: 2015 */ #include static uint16_t xorshift16_state; void xorshift16_init( uint16_t state ) { xorshift16_state = state; } void xorshift16_add( uint16_t value ) { xorshift16_state += value; } uint8_t xorshift16_next() { // xorshift 16 bit register uint16_t tmp = xorshift16_state; tmp ^= tmp << 13; tmp ^= tmp >> 9; tmp ^= tmp << 7; xorshift16_state = tmp; return tmp; } uint16_t xorshift16_get_state() { return xorshift16_state; }