From b8011b8bf38fa87bbb51d1d0235044aba0357cc7 Mon Sep 17 00:00:00 2001 From: hisi_opensource Date: Sat, 27 Dec 2025 09:27:04 +0000 Subject: [PATCH] add vendor/HiHope_NearLink_DK_WS63_V03/demo/00_thread/failed_test.c. Signed-off-by: hisi_opensource --- .../demo/00_thread/failed_test.c | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 vendor/HiHope_NearLink_DK_WS63_V03/demo/00_thread/failed_test.c diff --git a/vendor/HiHope_NearLink_DK_WS63_V03/demo/00_thread/failed_test.c b/vendor/HiHope_NearLink_DK_WS63_V03/demo/00_thread/failed_test.c new file mode 100644 index 0000000..e0e03e3 --- /dev/null +++ b/vendor/HiHope_NearLink_DK_WS63_V03/demo/00_thread/failed_test.c @@ -0,0 +1,82 @@ +/** + * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2023-2023. All rights reserved. + * + * Description: ADC Sample Source. \n + * + * History: \n + * 2023-07-06, Create file. \n + */ +#include "pinctrl.h" +#include "soc_osal.h" +#include "adc.h" +#include "adc_porting.h" +#include "osal_debug.h" +#include "cmsis_os2.h" +#include "app_init.h" + +#define ADC_TASK_STACK_SIZE 0x1000 +#define ADC_TASK_PRIO (osPriority_t)(17) +#define ADC_AUTO_SAMPLE_TEST_TIMES 2000 + + +// ci-test +void test_adc_callback(uint8_t ch, uint32_t *buffer, uint32_t length, bool *next) +{ + UNUSED(next); + for (uint32_t i = 0; i < length; i++) { + printf("channel: %d, voltage: %dmv\r\n", ch, buffer[i]); + } +} + +static void *adc_task(const char *arg) +{ + UNUSED(arg); + osal_printk("start adc sample test"); + uapi_adc_init(ADC_CLOCK_500KHZ); + uapi_adc_power_en(AFE_SCAN_MODE_MAX_NUM, true); + adc_scan_config_t config = { + .type = 0, + .freq = 1, + }; + + while (1) + { + uapi_adc_auto_scan_ch_enable(ADC_CHANNEL_0, config, test_adc_callback); + uapi_adc_auto_scan_ch_disable(ADC_CHANNEL_0); + osal_msleep(ADC_AUTO_SAMPLE_TEST_TIMES); + } + + return NULL; +} + +// 不要重复定义基本类型 +typedef uint32_t errcode_t; + +// 不要使用难以理解的字面量 +static void abc_def_ghi(void) +{ + // 缩进问题 + osThreadAttr_t attr; + // 不要使用难以理解的字面量 + attr.asdfasdf = ""; +} + +static void adc_entry(void) +{ + osThreadAttr_t attr; + + attr.name = "ADCTask"; + attr.attr_bits = 0U; + attr.cb_mem = NULL; + attr.cb_size = 0U; + attr.stack_mem = NULL; + attr.stack_size = ADC_TASK_STACK_SIZE; + attr.priority = ADC_TASK_PRIO; + + if (osThreadNew((osThreadFunc_t)adc_task, NULL, &attr) == NULL) { + /* Create task fail. */ + } +} + +/* Run the adc_entry. */ +app_run(adc_entry); \ No newline at end of file -- Gitee