From 1f492d6a3877eba8e97911e865bf9dfdc9e157cd Mon Sep 17 00:00:00 2001 From: qqwang Date: Tue, 6 Jul 2021 17:31:23 +0800 Subject: [PATCH] [feat][examples/adc] update adc case --- examples/adc/adc_continuous_differential/main.c | 10 +++++++++- examples/adc/adc_continuous_single_ended/main.c | 7 ++++++- examples/adc/adc_key/main.c | 8 +++++++- examples/adc/adc_one_shot_differential/main.c | 7 ++++++- examples/adc/adc_one_shot_single_ended/main.c | 7 ++++++- examples/adc/adc_scan_single_ended/main.c | 7 ++++++- 6 files changed, 40 insertions(+), 6 deletions(-) diff --git a/examples/adc/adc_continuous_differential/main.c b/examples/adc/adc_continuous_differential/main.c index fcdb3154..204f1599 100644 --- a/examples/adc/adc_continuous_differential/main.c +++ b/examples/adc/adc_continuous_differential/main.c @@ -51,7 +51,14 @@ int main(void) ADC_DEV(adc_test)->differential_mode = ENABLE; ADC_DEV(adc_test)->continuous_conv_mode = ENABLE; device_open(adc_test, DEVICE_OFLAG_STREAM_RX); - device_control(adc_test, DEVICE_CTRL_ADC_CHANNEL_CONFIG, &adc_channel_cfg); + + if (device_control(adc_test, DEVICE_CTRL_ADC_CHANNEL_CONFIG, &adc_channel_cfg) == ERROR) { + MSG("ADC channel config error , Please check the channel corresponding to IO is initial success by board system or Channel is invaild \r\n"); + BL_CASE_FAIL; + while (1) + ; + } + MSG("adc device find success\r\n"); } @@ -66,5 +73,6 @@ int main(void) } else { MSG("PosId = %d NegId = %d V= %d mV \r\n", result_val.posChan, result_val.negChan, (uint32_t)(result_val.volt * 1000)); } + bflb_platform_delay_ms(500); } } \ No newline at end of file diff --git a/examples/adc/adc_continuous_single_ended/main.c b/examples/adc/adc_continuous_single_ended/main.c index f02daf54..822e38a7 100644 --- a/examples/adc/adc_continuous_single_ended/main.c +++ b/examples/adc/adc_continuous_single_ended/main.c @@ -48,7 +48,12 @@ int main(void) if (adc_test) { ADC_DEV(adc_test)->continuous_conv_mode = ENABLE; device_open(adc_test, DEVICE_OFLAG_STREAM_RX); - device_control(adc_test, DEVICE_CTRL_ADC_CHANNEL_CONFIG, &adc_channel_cfg); + if (device_control(adc_test, DEVICE_CTRL_ADC_CHANNEL_CONFIG, &adc_channel_cfg) == ERROR) { + MSG("ADC channel config error , Please check the channel corresponding to IO is initial success by board system or Channel is invaild \r\n"); + BL_CASE_FAIL; + while (1) + ; + } MSG("adc device find success\r\n"); } diff --git a/examples/adc/adc_key/main.c b/examples/adc/adc_key/main.c index ff63de7c..190561a4 100644 --- a/examples/adc/adc_key/main.c +++ b/examples/adc/adc_key/main.c @@ -181,7 +181,13 @@ int main(void) if (adc_key) { ADC_DEV(adc_key)->continuous_conv_mode = ENABLE; device_open(adc_key, DEVICE_OFLAG_STREAM_RX); - device_control(adc_key, DEVICE_CTRL_ADC_CHANNEL_CONFIG, &adc_channel_cfg); + + if (device_control(adc_key, DEVICE_CTRL_ADC_CHANNEL_CONFIG, &adc_channel_cfg) == ERROR) { + MSG("ADC channel config error , Please check the channel corresponding to IO is initial success by board system or Channel is invaild \r\n"); + BL_CASE_FAIL; + while (1) + ; + } } else { MSG("device open failed\r\n"); diff --git a/examples/adc/adc_one_shot_differential/main.c b/examples/adc/adc_one_shot_differential/main.c index 5e292847..9cbdb0b5 100644 --- a/examples/adc/adc_one_shot_differential/main.c +++ b/examples/adc/adc_one_shot_differential/main.c @@ -50,7 +50,12 @@ int main(void) if (adc_test) { ADC_DEV(adc_test)->differential_mode = ENABLE; device_open(adc_test, DEVICE_OFLAG_STREAM_RX); - device_control(adc_test, DEVICE_CTRL_ADC_CHANNEL_CONFIG, &adc_channel_cfg); + if (device_control(adc_test, DEVICE_CTRL_ADC_CHANNEL_CONFIG, &adc_channel_cfg) == ERROR) { + MSG("ADC channel config error , Please check the channel corresponding to IO is initial success by board system or Channel is invaild \r\n"); + BL_CASE_FAIL; + while (1) + ; + } MSG("adc device find success\r\n"); } diff --git a/examples/adc/adc_one_shot_single_ended/main.c b/examples/adc/adc_one_shot_single_ended/main.c index 7fc2b8c9..bac34f3f 100644 --- a/examples/adc/adc_one_shot_single_ended/main.c +++ b/examples/adc/adc_one_shot_single_ended/main.c @@ -49,7 +49,12 @@ int main(void) if (adc_test) { device_open(adc_test, DEVICE_OFLAG_STREAM_RX); - device_control(adc_test, DEVICE_CTRL_ADC_CHANNEL_CONFIG, &adc_channel_cfg); + if (device_control(adc_test, DEVICE_CTRL_ADC_CHANNEL_CONFIG, &adc_channel_cfg) == ERROR) { + MSG("ADC channel config error , Please check the channel corresponding to IO is initial success by board system or Channel is invaild \r\n"); + BL_CASE_FAIL; + while (1) + ; + } MSG("adc device find success\r\n"); } diff --git a/examples/adc/adc_scan_single_ended/main.c b/examples/adc/adc_scan_single_ended/main.c index 2e34caa6..bfa9943b 100644 --- a/examples/adc/adc_scan_single_ended/main.c +++ b/examples/adc/adc_scan_single_ended/main.c @@ -50,7 +50,12 @@ int main(void) if (adc_test) { ADC_DEV(adc_test)->continuous_conv_mode = ENABLE; device_open(adc_test, DEVICE_OFLAG_STREAM_RX); - device_control(adc_test, DEVICE_CTRL_ADC_CHANNEL_CONFIG, &adc_channel_cfg); + if (device_control(adc_test, DEVICE_CTRL_ADC_CHANNEL_CONFIG, &adc_channel_cfg) == ERROR) { + MSG("ADC channel config error , Please check the channel corresponding to IO is initial success by board system or Channel is invaild \r\n"); + BL_CASE_FAIL; + while (1) + ; + } MSG("adc device find success\r\n"); }