From ba71d92b5b7e27f4501911cdacf676782de2f097 Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Wed, 11 Jan 2023 10:33:31 +0800 Subject: [PATCH] =?UTF-8?q?adc=20=E9=A9=B1=E5=8A=A8=E5=90=AF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: a1012112796 <1012112796@qq.com> --- .config | 6 +- board/board.c | 3 + libraries/HAL_Drivers/drv_adc.c | 4 +- project.uvoptx | 256 +++++++++++++++++++------------- project.uvprojx | 54 ++++--- rtconfig.h | 3 + 6 files changed, 201 insertions(+), 125 deletions(-) diff --git a/.config b/.config index f9073be..68b28ab 100644 --- a/.config +++ b/.config @@ -135,7 +135,7 @@ CONFIG_RT_USING_CAN=y # CONFIG_RT_USING_I2C is not set # CONFIG_RT_USING_PHY is not set CONFIG_RT_USING_PIN=y -# CONFIG_RT_USING_ADC is not set +CONFIG_RT_USING_ADC=y # CONFIG_RT_USING_DAC is not set CONFIG_RT_USING_PWM=y # CONFIG_RT_USING_MTD_NOR is not set @@ -536,6 +536,7 @@ CONFIG_PKG_RT_VSNPRINTF_FULL_VER="latest" # CONFIG_PKG_USING_TFDB is not set # CONFIG_PKG_USING_QPC is not set # CONFIG_PKG_USING_AGILE_UPGRADE is not set +# CONFIG_PKG_USING_FLASH_BLOB is not set # # peripheral libraries and drivers @@ -1050,7 +1051,8 @@ CONFIG_BSP_USING_PWM4_CH1=y CONFIG_BSP_USING_PWM4_CH2=y CONFIG_BSP_USING_PWM4_CH3=y CONFIG_BSP_USING_PWM4_CH4=y -# CONFIG_BSP_USING_ADC is not set +CONFIG_BSP_USING_ADC=y +CONFIG_BSP_USING_ADC1=y # CONFIG_BSP_USING_ONCHIP_RTC is not set # CONFIG_BSP_USING_WDT is not set CONFIG_BSP_USING_ON_CHIP_FLASH=y diff --git a/board/board.c b/board/board.c index da912f6..6ab2bbc 100644 --- a/board/board.c +++ b/board/board.c @@ -101,3 +101,6 @@ INIT_BOARD_EXPORT(rt_hw_can_init); extern int stm32_pwm_init(void); INIT_DEVICE_EXPORT(stm32_pwm_init); + +extern int stm32_adc_init(void); +INIT_BOARD_EXPORT(stm32_adc_init); diff --git a/libraries/HAL_Drivers/drv_adc.c b/libraries/HAL_Drivers/drv_adc.c index d70cfcd..39ee4c7 100644 --- a/libraries/HAL_Drivers/drv_adc.c +++ b/libraries/HAL_Drivers/drv_adc.c @@ -297,7 +297,7 @@ static const struct rt_adc_ops stm_adc_ops = .get_vref = stm32_adc_get_vref, }; -static int stm32_adc_init(void) +int stm32_adc_init(void) { int result = RT_EOK; /* save adc name */ @@ -349,6 +349,6 @@ static int stm32_adc_init(void) return result; } -INIT_BOARD_EXPORT(stm32_adc_init); +// INIT_BOARD_EXPORT(stm32_adc_init); #endif /* BSP_USING_ADC */ diff --git a/project.uvoptx b/project.uvoptx index 845e525..7e4e9b0 100644 --- a/project.uvoptx +++ b/project.uvoptx @@ -303,18 +303,6 @@ 0 0 0 - rt-thread\components\libc\cplusplus\cxx_Mutex.cpp - cxx_Mutex.cpp - 0 - 0 - - - 2 - 10 - 8 - 0 - 0 - 0 rt-thread\components\libc\cplusplus\cxx_crt.cpp cxx_crt.cpp 0 @@ -322,19 +310,7 @@ 2 - 11 - 8 - 0 - 0 - 0 - rt-thread\components\libc\cplusplus\cxx_Semaphore.cpp - cxx_Semaphore.cpp - 0 - 0 - - - 2 - 12 + 10 8 0 0 @@ -346,7 +322,7 @@ 2 - 13 + 11 1 0 0 @@ -356,6 +332,30 @@ 0 0 + + 2 + 12 + 8 + 0 + 0 + 0 + rt-thread\components\libc\cplusplus\cxx_Mutex.cpp + cxx_Mutex.cpp + 0 + 0 + + + 2 + 13 + 8 + 0 + 0 + 0 + rt-thread\components\libc\cplusplus\cxx_Semaphore.cpp + cxx_Semaphore.cpp + 0 + 0 + @@ -535,6 +535,18 @@ 0 0 0 + rt-thread\components\drivers\misc\adc.c + adc.c + 0 + 0 + + + 4 + 28 + 1 + 0 + 0 + 0 rt-thread\components\drivers\misc\pin.c pin.c 0 @@ -542,7 +554,7 @@ 4 - 28 + 29 1 0 0 @@ -554,7 +566,7 @@ 4 - 29 + 30 1 0 0 @@ -566,7 +578,7 @@ 4 - 30 + 31 1 0 0 @@ -586,7 +598,7 @@ 0 5 - 31 + 32 1 0 0 @@ -598,7 +610,7 @@ 5 - 32 + 33 1 0 0 @@ -610,7 +622,7 @@ 5 - 33 + 34 2 0 0 @@ -622,7 +634,19 @@ 5 - 34 + 35 + 1 + 0 + 0 + 0 + libraries\HAL_Drivers\drv_adc.c + drv_adc.c + 0 + 0 + + + 5 + 36 1 0 0 @@ -634,7 +658,7 @@ 5 - 35 + 37 1 0 0 @@ -646,7 +670,7 @@ 5 - 36 + 38 1 0 0 @@ -658,7 +682,7 @@ 5 - 37 + 39 1 0 0 @@ -670,7 +694,7 @@ 5 - 38 + 40 1 0 0 @@ -682,7 +706,7 @@ 5 - 39 + 41 1 0 0 @@ -702,19 +726,7 @@ 0 6 - 40 - 1 - 0 - 0 - 0 - rt-thread\components\fal\src\fal_partition.c - fal_partition.c - 0 - 0 - - - 6 - 41 + 42 1 0 0 @@ -726,19 +738,19 @@ 6 - 42 + 43 1 0 0 0 - rt-thread\components\fal\src\fal_flash.c - fal_flash.c + rt-thread\components\fal\src\fal_partition.c + fal_partition.c 0 0 6 - 43 + 44 1 0 0 @@ -748,6 +760,18 @@ 0 0 + + 6 + 45 + 1 + 0 + 0 + 0 + rt-thread\components\fal\src\fal_flash.c + fal_flash.c + 0 + 0 + @@ -758,7 +782,7 @@ 0 7 - 44 + 46 1 0 0 @@ -770,7 +794,7 @@ 7 - 45 + 47 1 0 0 @@ -782,7 +806,7 @@ 7 - 46 + 48 1 0 0 @@ -794,7 +818,7 @@ 7 - 47 + 49 1 0 0 @@ -814,7 +838,7 @@ 0 8 - 48 + 50 1 0 0 @@ -834,7 +858,7 @@ 0 9 - 49 + 51 1 0 0 @@ -846,7 +870,7 @@ 9 - 50 + 52 1 0 0 @@ -858,7 +882,7 @@ 9 - 51 + 53 1 0 0 @@ -870,7 +894,7 @@ 9 - 52 + 54 1 0 0 @@ -882,7 +906,7 @@ 9 - 53 + 55 1 0 0 @@ -894,7 +918,7 @@ 9 - 54 + 56 1 0 0 @@ -906,7 +930,7 @@ 9 - 55 + 57 1 0 0 @@ -918,7 +942,7 @@ 9 - 56 + 58 1 0 0 @@ -930,7 +954,7 @@ 9 - 57 + 59 1 0 0 @@ -942,7 +966,7 @@ 9 - 58 + 60 1 0 0 @@ -954,7 +978,7 @@ 9 - 59 + 61 1 0 0 @@ -966,7 +990,7 @@ 9 - 60 + 62 1 0 0 @@ -978,7 +1002,7 @@ 9 - 61 + 63 1 0 0 @@ -998,7 +1022,7 @@ 0 10 - 62 + 64 1 0 0 @@ -1010,7 +1034,7 @@ 10 - 63 + 65 1 0 0 @@ -1022,7 +1046,19 @@ 10 - 64 + 66 + 1 + 0 + 0 + 0 + libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_adc.c + stm32f4xx_hal_adc.c + 0 + 0 + + + 10 + 67 1 0 0 @@ -1034,7 +1070,7 @@ 10 - 65 + 68 1 0 0 @@ -1046,7 +1082,7 @@ 10 - 66 + 69 1 0 0 @@ -1058,7 +1094,7 @@ 10 - 67 + 70 1 0 0 @@ -1070,7 +1106,7 @@ 10 - 68 + 71 1 0 0 @@ -1082,7 +1118,7 @@ 10 - 69 + 72 1 0 0 @@ -1094,7 +1130,7 @@ 10 - 70 + 73 1 0 0 @@ -1106,7 +1142,7 @@ 10 - 71 + 74 1 0 0 @@ -1118,7 +1154,7 @@ 10 - 72 + 75 1 0 0 @@ -1130,7 +1166,7 @@ 10 - 73 + 76 1 0 0 @@ -1142,7 +1178,7 @@ 10 - 74 + 77 1 0 0 @@ -1154,7 +1190,19 @@ 10 - 75 + 78 + 1 + 0 + 0 + 0 + libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_adc_ex.c + stm32f4xx_hal_adc_ex.c + 0 + 0 + + + 10 + 79 1 0 0 @@ -1166,7 +1214,7 @@ 10 - 76 + 80 1 0 0 @@ -1178,7 +1226,7 @@ 10 - 77 + 81 1 0 0 @@ -1190,7 +1238,7 @@ 10 - 78 + 82 1 0 0 @@ -1202,7 +1250,7 @@ 10 - 79 + 83 1 0 0 @@ -1214,7 +1262,7 @@ 10 - 80 + 84 1 0 0 @@ -1226,7 +1274,7 @@ 10 - 81 + 85 1 0 0 @@ -1238,7 +1286,7 @@ 10 - 82 + 86 1 0 0 @@ -1250,7 +1298,7 @@ 10 - 83 + 87 1 0 0 @@ -1262,7 +1310,7 @@ 10 - 84 + 88 1 0 0 @@ -1274,7 +1322,7 @@ 10 - 85 + 89 1 0 0 @@ -1286,7 +1334,7 @@ 10 - 86 + 90 1 0 0 @@ -1298,7 +1346,7 @@ 10 - 87 + 91 1 0 0 @@ -1318,7 +1366,7 @@ 0 11 - 88 + 92 1 0 0 @@ -1332,13 +1380,13 @@ Utilities - 0 + 1 0 0 0 12 - 89 + 93 1 0 0 @@ -1350,7 +1398,7 @@ 12 - 90 + 94 1 0 0 @@ -1362,7 +1410,7 @@ 12 - 91 + 95 1 0 0 diff --git a/project.uvprojx b/project.uvprojx index 648857b..acb0b8d 100644 --- a/project.uvprojx +++ b/project.uvprojx @@ -428,21 +428,11 @@ CPlusPlus - - cxx_Mutex.cpp - 8 - rt-thread\components\libc\cplusplus\cxx_Mutex.cpp - cxx_crt.cpp 8 rt-thread\components\libc\cplusplus\cxx_crt.cpp - - cxx_Semaphore.cpp - 8 - rt-thread\components\libc\cplusplus\cxx_Semaphore.cpp - cxx_Thread.cpp 8 @@ -453,6 +443,16 @@ 1 rt-thread\components\libc\cplusplus\cxx_crt_init.c + + cxx_Mutex.cpp + 8 + rt-thread\components\libc\cplusplus\cxx_Mutex.cpp + + + cxx_Semaphore.cpp + 8 + rt-thread\components\libc\cplusplus\cxx_Semaphore.cpp + @@ -528,6 +528,11 @@ 1 rt-thread\components\drivers\ipc\workqueue.c + + adc.c + 1 + rt-thread\components\drivers\misc\adc.c + pin.c 1 @@ -568,6 +573,11 @@ 2 libraries\STM32F4xx_HAL\CMSIS\Device\ST\STM32F4xx\Source\Templates\arm\startup_stm32f413xx.s + + drv_adc.c + 1 + libraries\HAL_Drivers\drv_adc.c + drv_can.c 1 @@ -603,26 +613,26 @@ Fal - - fal_partition.c - 1 - rt-thread\components\fal\src\fal_partition.c - fal_rtt.c 1 rt-thread\components\fal\src\fal_rtt.c - fal_flash.c + fal_partition.c 1 - rt-thread\components\fal\src\fal_flash.c + rt-thread\components\fal\src\fal_partition.c fal.c 1 rt-thread\components\fal\src\fal.c + + fal_flash.c + 1 + rt-thread\components\fal\src\fal_flash.c + @@ -743,6 +753,11 @@ 1 libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ex.c + + stm32f4xx_hal_adc.c + 1 + libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_adc.c + stm32f4xx_hal_uart.c 1 @@ -798,6 +813,11 @@ 1 libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_iwdg.c + + stm32f4xx_hal_adc_ex.c + 1 + libraries\STM32F4xx_HAL\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_adc_ex.c + stm32f4xx_hal_rcc.c 1 diff --git a/rtconfig.h b/rtconfig.h index f8cada8..8397591 100644 --- a/rtconfig.h +++ b/rtconfig.h @@ -85,6 +85,7 @@ #define RT_SERIAL_RB_BUFSZ 64 #define RT_USING_CAN #define RT_USING_PIN +#define RT_USING_ADC #define RT_USING_PWM #define RT_USING_WDT @@ -303,6 +304,8 @@ #define BSP_USING_PWM4_CH2 #define BSP_USING_PWM4_CH3 #define BSP_USING_PWM4_CH4 +#define BSP_USING_ADC +#define BSP_USING_ADC1 #define BSP_USING_ON_CHIP_FLASH /* Board extended module Drivers */