mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-09-21 23:44:48 +08:00
implement ADC poll test
This commit is contained in:
@@ -71,6 +71,7 @@ C_SOURCES = \
|
||||
Src/stm32f4xx_hal_msp.c \
|
||||
Src/gpio.c \
|
||||
Src/freertos.c \
|
||||
Src/test.c \
|
||||
Src/stm32f4xx_it.c \
|
||||
Src/adc.c \
|
||||
Src/usbd_conf.c
|
||||
@@ -96,7 +97,8 @@ AS_DEFS =
|
||||
C_DEFS = -D__weak="__attribute__((weak))" -D__packed="__attribute__((__packed__))" -DUSE_HAL_DRIVER -DSTM32F405xx
|
||||
# includes for gcc
|
||||
AS_INCLUDES =
|
||||
C_INCLUDES = -IInc
|
||||
C_INCLUDES = -I.
|
||||
C_INCLUDES += -IInc
|
||||
C_INCLUDES += -IDrivers/CMSIS/Device/ST/STM32F4xx/Include
|
||||
C_INCLUDES += -IDrivers/CMSIS/Include
|
||||
C_INCLUDES += -IDrivers/STM32F4xx_HAL_Driver/Inc
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
#include "task.h"
|
||||
#include "cmsis_os.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "test.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
|
||||
+12
-2
@@ -1,6 +1,8 @@
|
||||
|
||||
#include "test.h"
|
||||
|
||||
#include "cmsis_os.h"
|
||||
#include "stm32f4xx.h"
|
||||
#include "stm32f4xx_hal_adc.h"
|
||||
#include "adc.h"
|
||||
|
||||
@@ -12,6 +14,14 @@ void test_main(void) {
|
||||
|
||||
// Simple loop to read ADC1
|
||||
static void test_read_ADC(void){
|
||||
HAL_ADC_Start(&hadc1);
|
||||
|
||||
int measnum = 0;
|
||||
for (;;) {
|
||||
HAL_ADC_Start(&hadc1);
|
||||
osDelay(2);
|
||||
if (HAL_ADC_PollForConversion(&hadc1, 1000) == HAL_OK) {
|
||||
uint32_t ADCValue = HAL_ADC_GetValue(&hadc1);
|
||||
++measnum;
|
||||
}
|
||||
osDelay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user