aio: add initial analog input support
Signed-off-by: Nandkishor Sonar <nandkishor.sonar@intel.com> Reviewed-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
committed by
Brendan Le Foll
parent
8c016318a6
commit
207c54a5e7
@@ -2,6 +2,7 @@ add_executable (i2c_HMC5883L i2c_HMC5883L.c)
|
||||
add_executable (hellomaa hellomaa.c)
|
||||
add_executable (cycle-pwm3 cycle-pwm3.c)
|
||||
add_executable (blink-io8 blink-io8.c)
|
||||
add_executable (analogin_a0 analogin_a0.c)
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/api ${PROJECT_SOURCE_DIR}/include)
|
||||
|
||||
@@ -9,3 +10,4 @@ target_link_libraries (hellomaa maa)
|
||||
target_link_libraries (i2c_HMC5883L maa m)
|
||||
target_link_libraries (cycle-pwm3 maa)
|
||||
target_link_libraries (blink-io8 maa)
|
||||
target_link_libraries (analogin_a0 maa)
|
||||
|
||||
48
examples/analogin_a0.c
Normal file
48
examples/analogin_a0.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Author: Nandkishor Sonar
|
||||
* Copyright (c) 2014 Intel Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "aio.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
maa_aio_context* adc_a0;
|
||||
unsigned int adc_value = 0;
|
||||
int i = 0;
|
||||
|
||||
adc_a0 = maa_aio_init(A0);
|
||||
if (adc_a0 == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
for(i = 0; i < 10; i++) {
|
||||
adc_value = maa_aio_read_u16(adc_a0);
|
||||
fprintf(stdout, "ADC A0 read %X\n", adc_value);
|
||||
}
|
||||
|
||||
maa_aio_close(adc_a0);
|
||||
|
||||
return MAA_SUCCESS;
|
||||
}
|
||||
Reference in New Issue
Block a user