1 /* Copyright 2016-present Samsung Electronics Co., Ltd. and other contributors
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 var Adc = require('adc');
18 var assert = require('assert');
20 var configuration = {};
22 if (process.platform === 'linux') {
23 configuration.device =
24 '/sys/devices/12d10000.adc/iio:device0/in_voltage0_raw';
25 } else if (process.platform === 'nuttx') {
26 configuration.pin = require('stm32f4dis').pin.ADC1_3;
31 var adc0 = adc.open(configuration, function(err) {
32 console.log('ADC initialized');
45 console.log('test1 start(read async test)');
46 var test1Loop = setInterval(function() {
48 console.log('test1 complete');
49 clearInterval(test1Loop);
52 adc0.read(function(err, value) {
54 console.log('read failed');
69 console.log('test2 start(read sync test)');
70 var test2Loop = setInterval(function() {
72 console.log('test2 complete');
73 clearInterval(test2Loop);
76 value = adc0.readSync();
78 console.log('read failed');