From 3be9d3dc5f5e88d2eb50dfc5e73abf5c07eda9b2 Mon Sep 17 00:00:00 2001 From: WXK <287788329@qq.com> Date: 星期二, 12 十一月 2024 18:04:29 +0800 Subject: [PATCH] 可以跟标签uwb测距。 --- Src/OnChipDevices/ADC.c | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/Src/OnChipDevices/ADC.c b/Src/OnChipDevices/ADC.c index cfdf1c0..c029a89 100644 --- a/Src/OnChipDevices/ADC.c +++ b/Src/OnChipDevices/ADC.c @@ -1,5 +1,6 @@ #include "ADC.h" #include "main.h" + uint16_t Get_ADC_Value() { HAL_ADC_Start(&hadc); @@ -9,6 +10,18 @@ return HAL_ADC_GetValue(&hadc); } } +uint16_t GetRandomValue(void) +{ + uint16_t temp; + for(uint8_t i=0;i<16;i++) + { + if(Get_ADC_Value()%2) + { + temp=temp|(1<<i); + } + } + return temp; +} float bat_volt; uint8_t Get_Battary(void) {static float last_value = 100; -- Gitblit v1.9.3