*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
int usb_buf_id;
uint16_t i;
uint16_t *buf;
- uint32_t *rnd;
+ uint16_t t;
+ uint32_t *rnd = (uint32_t *) ao_adc_ring;
if (!buffer[0]) {
buffer[0] = ao_usb_alloc();
ao_led_on(AO_LED_TRNG_READ);
while (count--) {
- rnd = (uint32_t *) ao_adc_get(AO_USB_IN_SIZE); /* one 16-bit value per output byte */
+ t = ao_adc_get(AO_USB_IN_SIZE) >> 1; /* one 16-bit value per output byte */
buf = buffer[usb_buf_id];
- for (i = 0; i < AO_USB_IN_SIZE / sizeof (uint16_t); i++)
- *buf++ = ao_crc_in_32_out_16(*rnd++);
+ for (i = 0; i < AO_USB_IN_SIZE / sizeof (uint16_t); i++) {
+ *buf++ = ao_crc_in_32_out_16(rnd[t]);
+ t = (t + 1) & ((AO_ADC_RING_SIZE>>1) - 1);
+ }
ao_adc_ack(AO_USB_IN_SIZE);
ao_led_toggle(AO_LED_TRNG_READ|AO_LED_TRNG_WRITE);
ao_usb_write(buffer[usb_buf_id], AO_USB_IN_SIZE);