1 /* 2 * Copyright (C) 2015-2017 Alibaba Group Holding Limited 3 */ 4 5 #include <stdio.h> 6 #include <stdint.h> 7 #include <string.h> 8 9 #include "aos/kernel.h" 10 #include "aos/hal/adc.h" 11 #include "adc_test.h" 12 13 static adc_dev_t adc_dev; 14 static aos_timer_t gpio_test_timer; 15 16 void adc_test_task(void *arg); 17 hal_adc_test(void)18void hal_adc_test(void) 19 { 20 int ret = -1; 21 22 printf("*********** adc test start ! ***********\n"); 23 24 adc_dev.port = PORT_ADC_TEST; 25 ret = hal_adc_init(&adc_dev); 26 if (ret != 0) { 27 printf("hal_adc_init error !\n"); 28 return; 29 } 30 31 aos_timer_new(&gpio_test_timer, adc_test_task, NULL, 1000, 1); 32 33 } 34 adc_test_task(void * arg)35void adc_test_task(void *arg) 36 { 37 int ret = -1; 38 uint16_t value = 0; 39 40 printf("adc_test_task\n"); 41 42 43 ret = hal_adc_value_get(&adc_dev, &value, 0xFFFFFFFF); 44 if (ret == 0) { 45 printf("adc value: %d\n", value); 46 } else { 47 printf("adc value get error !\n"); 48 } 49 50 } 51