GNU/Linux: Use getrandom for ADC driver.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
2021-02-17 NIIBE Yutaka <gniibe@fsij.org>
|
2021-02-17 NIIBE Yutaka <gniibe@fsij.org>
|
||||||
|
|
||||||
|
* contrib/adc-gnu-linux.c (adc_start_conversion): Use getrandom.
|
||||||
|
|
||||||
* mcu/usb-usbip.c (usbip_run_server): Add start-up message.
|
* mcu/usb-usbip.c (usbip_run_server): Add start-up message.
|
||||||
|
|
||||||
2021-02-16 NIIBE Yutaka <gniibe@fsij.org>
|
2021-02-16 NIIBE Yutaka <gniibe@fsij.org>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* This ADC driver just fills pseudo random values.
|
* This ADC driver just fills pseudo random values.
|
||||||
* It's completely useless other than for NeuG.
|
* 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>
|
* Author: NIIBE Yutaka <gniibe@fsij.org>
|
||||||
*
|
*
|
||||||
* This file is a part of Chopstx, a thread library for embedded.
|
* This file is a part of Chopstx, a thread library for embedded.
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
#include <chopstx.h>
|
#include <chopstx.h>
|
||||||
#include "adc.h"
|
#include "adc.h"
|
||||||
|
|
||||||
#define ADC_RANDOM_SEED 0x01034649 /* "Hello, father!" in Japanese */
|
#include <sys/random.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Do calibration for ADC.
|
* Do calibration for ADC.
|
||||||
@@ -41,7 +41,6 @@
|
|||||||
int
|
int
|
||||||
adc_init (void)
|
adc_init (void)
|
||||||
{
|
{
|
||||||
srandom (ADC_RANDOM_SEED);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,8 +54,7 @@ uint32_t adc_buf[64];
|
|||||||
void
|
void
|
||||||
adc_start_conversion (int offset, int count)
|
adc_start_conversion (int offset, int count)
|
||||||
{
|
{
|
||||||
while (count--)
|
getrandom (adc_buf+offset, count, 0);
|
||||||
adc_buf[offset++] = random ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user