+static void
+ao_trng_start(void)
+{
+ if (!trng_running) {
+ ao_mutex_get(&random_mutex);
+ if (!trng_running) {
+ AO_TICK_TYPE delay;
+
+ delay = trng_power_time + TRNG_ENABLE_DELAY - ao_time();
+ if (delay > TRNG_ENABLE_DELAY)
+ delay = TRNG_ENABLE_DELAY;
+
+ /* Delay long enough for the HV power supply
+ * to stabilize so that the first bits we read
+ * aren't of poor quality
+ */
+ ao_delay(delay);
+ trng_running = true;
+ }
+ ao_mutex_put(&random_mutex);
+ }
+}
+
+#if AO_USB_HAS_IN2
+
+static struct ao_task ao_trng_send_raw_task;
+