aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2017-08-02 14:09:13 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2017-08-02 14:19:10 +0900
commita4f28ee17680742b0b0055f68b7a0741ccb17d6b (patch)
tree13f83854e641e6884d6faad1299b088cd044ee5f
parent87767f1be5d8d4adac8d23a285250299eccee3fb (diff)
Add adc-gnu-linux driver.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
-rw-r--r--ChangeLog4
-rw-r--r--contrib/adc-gnu-linux.c77
2 files changed, 81 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index c14b305..c5c56c4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2017-08-02 NIIBE Yutaka <gniibe@fsij.org>
+
+ * contrib/adc-gnu-linux.c: New.
+
2017-07-07 NIIBE Yutaka <gniibe@fsij.org>
* mcu/usb-usbip.c (usbip_handle_data_urb): Fix error return value.
diff --git a/contrib/adc-gnu-linux.c b/contrib/adc-gnu-linux.c
new file mode 100644
index 0000000..e71d7f9
--- /dev/null
+++ b/contrib/adc-gnu-linux.c
@@ -0,0 +1,77 @@
+/*
+ * adc-gnu-linux.c - ADC driver for GNU/Linux emulation.
+ * This ADC driver just fills pseudo random values.
+ * It's completely useless other than for NeuG.
+ *
+ * Copyright (C) 2017 Free Software Initiative of Japan
+ * Author: NIIBE Yutaka <gniibe@fsij.org>
+ *
+ * This file is a part of Chopstx, a thread library for embedded.
+ *
+ * Chopstx 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, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chopstx is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As additional permission under GNU GPL version 3 section 7, you may
+ * distribute non-source form of the Program without the copy of the
+ * GNU GPL normally required by section 4, provided you inform the
+ * receipents of GNU GPL by a written offer.
+ *
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <chopstx.h>
+#include "adc.h"
+
+#define ADC_RANDOM_SEED 0x01034649 /* "Hello, father!" in Japanese */
+
+/*
+ * Do calibration for ADC.
+ */
+int
+adc_init (void)
+{
+ srandom (ADC_RANDOM_SEED);
+ return 0;
+}
+
+void
+adc_start (void)
+{
+}
+
+uint32_t adc_buf[64];
+
+void
+adc_start_conversion (int offset, int count)
+{
+ while (count--)
+ adc_buf[offset++] = random ();
+}
+
+
+void
+adc_stop (void)
+{
+}
+
+
+/*
+ * Return 0 on success.
+ * Return 1 on error.
+ */
+int
+adc_wait_completion (void)
+{
+ return 0;
+}