Backport ADC driver from master.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka
2021-02-17 16:27:17 +09:00
parent d43fbb140a
commit 73d6c13d15
2 changed files with 4 additions and 5 deletions

View File

@@ -3,6 +3,7 @@
Backport from master.
* contrib/ackbtn-gnu-linux.c: New.
* mcu/usb-usbip.c (usbip_run_server): Add start-up message.
* contrib/adc-gnu-linux.c (adc_start_conversion): Use getrandom.
2021-02-12 NIIBE Yutaka <gniibe@fsij.org>

View File

@@ -3,7 +3,7 @@
* This ADC driver just fills pseudo random values.
* It's completely useless other than for NeuG.
*
* Copyright (C) 2017 Free Software Initiative of Japan
* Copyright (C) 2017, 2021 Free Software Initiative of Japan
* Author: NIIBE Yutaka <gniibe@fsij.org>
*
* This file is a part of Chopstx, a thread library for embedded.
@@ -33,7 +33,7 @@
#include <chopstx.h>
#include "adc.h"
#define ADC_RANDOM_SEED 0x01034649 /* "Hello, father!" in Japanese */
#include <sys/random.h>
/*
* Do calibration for ADC.
@@ -41,7 +41,6 @@
int
adc_init (void)
{
srandom (ADC_RANDOM_SEED);
return 0;
}
@@ -55,8 +54,7 @@ uint32_t adc_buf[64];
void
adc_start_conversion (int offset, int count)
{
while (count--)
adc_buf[offset++] = random ();
getrandom (adc_buf+offset, count, 0);
}