Merge pull request #3979 from Dozingfiretruck/master

修复ADC异常
This commit is contained in:
Bernard Xiong 2020-10-28 19:49:00 +08:00 committed by GitHub
commit 06eafe3928
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 64 additions and 75 deletions

View File

@ -58,6 +58,8 @@ STM32 系列 BSP 目前支持情况如下表所示:
| **MP1 系列** | | | **MP1 系列** | |
| [stm32mp157a-st-discovery](stm32mp157a-st-discovery) | ST 官方 STM32MP157A-DK1 开发板 | | [stm32mp157a-st-discovery](stm32mp157a-st-discovery) | ST 官方 STM32MP157A-DK1 开发板 |
| [stm32mp157a-st-ev1](stm32mp157a-st-ev1) | ST 官方 STM32MP157A-EV1 开发板 | | [stm32mp157a-st-ev1](stm32mp157a-st-ev1) | ST 官方 STM32MP157A-EV1 开发板 |
| **WB 系列** | |
| [stm32wb55-st-nucleo](stm32wb55-st-nucleo) | ST 官方 STM32WB55-nucleo 开发板 |
可以通过阅读相应 BSP 下的 README 来快速上手,如果想要使用 BSP 更多功能可参考 docs 文件夹下提供的说明文档,如下表所示: 可以通过阅读相应 BSP 下的 README 来快速上手,如果想要使用 BSP 更多功能可参考 docs 文件夹下提供的说明文档,如下表所示:

View File

@ -193,7 +193,7 @@ static rt_err_t stm32_get_adc_value(struct rt_adc_device *device, rt_uint32_t ch
return -RT_ERROR; return -RT_ERROR;
} }
#if defined(SOC_SERIES_STM32MP1) || defined (SOC_SERIES_STM32H7) #if defined(SOC_SERIES_STM32MP1) || defined (SOC_SERIES_STM32H7) || defined (SOC_SERIES_STM32WB)
ADC_ChanConf.Rank = ADC_REGULAR_RANK_1; ADC_ChanConf.Rank = ADC_REGULAR_RANK_1;
#else #else
ADC_ChanConf.Rank = 1; ADC_ChanConf.Rank = 1;
@ -205,22 +205,24 @@ static rt_err_t stm32_get_adc_value(struct rt_adc_device *device, rt_uint32_t ch
ADC_ChanConf.SamplingTime = ADC_SAMPLETIME_55CYCLES_5; ADC_ChanConf.SamplingTime = ADC_SAMPLETIME_55CYCLES_5;
#elif defined(SOC_SERIES_STM32F2) || defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7) #elif defined(SOC_SERIES_STM32F2) || defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7)
ADC_ChanConf.SamplingTime = ADC_SAMPLETIME_112CYCLES; ADC_ChanConf.SamplingTime = ADC_SAMPLETIME_112CYCLES;
#elif defined(SOC_SERIES_STM32L4) || defined (SOC_SERIES_STM32WB) #elif defined(SOC_SERIES_STM32L4)
ADC_ChanConf.SamplingTime = ADC_SAMPLETIME_247CYCLES_5; ADC_ChanConf.SamplingTime = ADC_SAMPLETIME_247CYCLES_5;
#elif defined(SOC_SERIES_STM32MP1) #elif defined(SOC_SERIES_STM32MP1)
ADC_ChanConf.SamplingTime = ADC_SAMPLETIME_810CYCLES_5; ADC_ChanConf.SamplingTime = ADC_SAMPLETIME_810CYCLES_5;
#elif defined(SOC_SERIES_STM32H7) #elif defined(SOC_SERIES_STM32H7)
ADC_ChanConf.SamplingTime = ADC_SAMPLETIME_64CYCLES_5; ADC_ChanConf.SamplingTime = ADC_SAMPLETIME_64CYCLES_5;
#elif defined (SOC_SERIES_STM32WB)
ADC_ChanConf.SamplingTime = ADC_SAMPLETIME_2CYCLES_5;
#endif #endif
#if defined(SOC_SERIES_STM32F2) || defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7) || defined(SOC_SERIES_STM32L4) || defined (SOC_SERIES_STM32WB) #if defined(SOC_SERIES_STM32F2) || defined(SOC_SERIES_STM32F4) || defined(SOC_SERIES_STM32F7) || defined(SOC_SERIES_STM32L4) || defined (SOC_SERIES_STM32WB)
ADC_ChanConf.Offset = 0; ADC_ChanConf.Offset = 0;
#endif #endif
#if defined(SOC_SERIES_STM32L4) || defined (SOC_SERIES_STM32WB) #if defined(SOC_SERIES_STM32L4)
ADC_ChanConf.OffsetNumber = ADC_OFFSET_NONE; ADC_ChanConf.OffsetNumber = ADC_OFFSET_NONE;
ADC_ChanConf.SingleDiff = LL_ADC_SINGLE_ENDED; ADC_ChanConf.SingleDiff = LL_ADC_SINGLE_ENDED;
#elif defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7) #elif defined(SOC_SERIES_STM32MP1) || defined(SOC_SERIES_STM32H7) || defined (SOC_SERIES_STM32WB)
ADC_ChanConf.OffsetNumber = ADC_OFFSET_NONE; /* ADC channel affected to offset number */ ADC_ChanConf.OffsetNumber = ADC_OFFSET_NONE; /* ADC channel affected to offset number */
ADC_ChanConf.Offset = 0; ADC_ChanConf.Offset = 0;
ADC_ChanConf.SingleDiff = ADC_SINGLE_ENDED; /* ADC channel differential mode */ ADC_ChanConf.SingleDiff = ADC_SINGLE_ENDED; /* ADC channel differential mode */

View File

@ -8,73 +8,73 @@ cwd = GetCurrentDir()
src = Split(''' src = Split('''
CMSIS/Device/ST/STM32WBxx/Source/Templates/system_stm32wbxx.c CMSIS/Device/ST/STM32WBxx/Source/Templates/system_stm32wbxx.c
STM32WBxx_HAL_Driver/Src/STM32wbxx_hal.c STM32WBxx_HAL_Driver/Src/stm32wbxx_hal.c
STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_comp.c STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_comp.c
STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_cortex.c STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_cortex.c
STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_crc.c STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_crc.c
STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_crc_ex.c STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_crc_ex.c
STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_cryp.c STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_cryp.c
STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_cryp_ex.c STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_cryp_ex.c
STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_dma.c STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_dma.c
STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_dma_ex.c STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_dma_ex.c
STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_exti.c STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_exti.c
STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_pwr.c STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_pwr.c
STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_pwr_ex.c STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_pwr_ex.c
STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_rcc.c STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_rcc.c
STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_rcc_ex.c STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_rcc_ex.c
STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_rng.c STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_rng.c
STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_gpio.c STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_gpio.c
''') ''')
if GetDepend(['RT_USING_SERIAL']): if GetDepend(['RT_USING_SERIAL']):
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_uart.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_uart.c']
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_uart_ex.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_uart_ex.c']
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_usart.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_usart.c']
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_usart_ex.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_usart_ex.c']
if GetDepend(['RT_USING_I2C']): if GetDepend(['RT_USING_I2C']):
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_i2c.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_i2c.c']
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_i2c_ex.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_i2c_ex.c']
if GetDepend(['RT_USING_SPI']): if GetDepend(['RT_USING_SPI']):
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_spi.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_spi.c']
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_spi_ex.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_spi_ex.c']
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_qspi.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_qspi.c']
if GetDepend(['RT_USING_USB_HOST']) or GetDepend(['RT_USING_USB_DEVICE']): if GetDepend(['RT_USING_USB_HOST']) or GetDepend(['RT_USING_USB_DEVICE']):
# src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_hcd.c'] # src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_hcd.c']
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_pcd.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_pcd.c']
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_pcd_ex.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_pcd_ex.c']
# src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_ll_usb.c'] # src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_ll_usb.c']
if GetDepend(['RT_USING_HWTIMER']) or GetDepend(['RT_USING_PWM']): if GetDepend(['RT_USING_HWTIMER']) or GetDepend(['RT_USING_PWM']):
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_lptim.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_lptim.c']
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_tim.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_tim.c']
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_tim_ex.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_tim_ex.c']
if GetDepend(['RT_USING_ADC']): if GetDepend(['RT_USING_ADC']):
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_adc.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_adc.c']
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_adc_ex.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_adc_ex.c']
if GetDepend(['RT_USING_RTC']): if GetDepend(['RT_USING_RTC']):
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_rtc.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_rtc.c']
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_rtc_ex.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_rtc_ex.c']
if GetDepend(['RT_USING_WDT']): if GetDepend(['RT_USING_WDT']):
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_iwdg.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_iwdg.c']
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_wwdg.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_wwdg.c']
if GetDepend(['RT_USING_AUDIO']): if GetDepend(['RT_USING_AUDIO']):
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_sai.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_sai.c']
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_sai_ex.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_sai_ex.c']
if GetDepend(['RT_USING_PM']): if GetDepend(['RT_USING_PM']):
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_lptim.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_lptim.c']
if GetDepend(['BSP_USING_ON_CHIP_FLASH']): if GetDepend(['BSP_USING_ON_CHIP_FLASH']):
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_flash.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_flash.c']
src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_flash_ex.c'] src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_flash_ex.c']
# src += ['STM32WBxx_HAL_Driver/Src/STM32wbxx_hal_flash_ramfunc.c'] # src += ['STM32WBxx_HAL_Driver/Src/stm32wbxx_hal_flash_ramfunc.c']

View File

@ -65,7 +65,7 @@ CONFIG_RT_USING_DEVICE=y
# CONFIG_RT_USING_INTERRUPT_INFO is not set # CONFIG_RT_USING_INTERRUPT_INFO is not set
CONFIG_RT_USING_CONSOLE=y CONFIG_RT_USING_CONSOLE=y
CONFIG_RT_CONSOLEBUF_SIZE=128 CONFIG_RT_CONSOLEBUF_SIZE=128
CONFIG_RT_CONSOLE_DEVICE_NAME="uart" CONFIG_RT_CONSOLE_DEVICE_NAME="uart1"
CONFIG_RT_VER_NUM=0x40003 CONFIG_RT_VER_NUM=0x40003
CONFIG_ARCH_ARM=y CONFIG_ARCH_ARM=y
CONFIG_RT_USING_CPU_FFS=y CONFIG_RT_USING_CPU_FFS=y
@ -108,18 +108,7 @@ CONFIG_FINSH_ARG_MAX=10
# #
# Device virtual file system # Device virtual file system
# #
CONFIG_RT_USING_DFS=y # CONFIG_RT_USING_DFS is not set
CONFIG_DFS_USING_WORKDIR=y
CONFIG_DFS_FILESYSTEMS_MAX=2
CONFIG_DFS_FILESYSTEM_TYPES_MAX=2
CONFIG_DFS_FD_MAX=16
# CONFIG_RT_USING_DFS_MNTTABLE is not set
# CONFIG_RT_USING_DFS_ELMFAT is not set
CONFIG_RT_USING_DFS_DEVFS=y
# CONFIG_RT_USING_DFS_ROMFS is not set
# CONFIG_RT_USING_DFS_RAMFS is not set
# CONFIG_RT_USING_DFS_UFFS is not set
# CONFIG_RT_USING_DFS_JFFS2 is not set
# #
# Device Drivers # Device Drivers
@ -164,11 +153,7 @@ CONFIG_RT_USING_PIN=y
# #
CONFIG_RT_USING_LIBC=y CONFIG_RT_USING_LIBC=y
# CONFIG_RT_USING_PTHREADS is not set # CONFIG_RT_USING_PTHREADS is not set
CONFIG_RT_USING_POSIX=y
# CONFIG_RT_USING_POSIX_MMAP is not set
# CONFIG_RT_USING_POSIX_TERMIOS is not set
# CONFIG_RT_USING_POSIX_GETLINE is not set
# CONFIG_RT_USING_POSIX_AIO is not set
# CONFIG_RT_USING_MODULE is not set # CONFIG_RT_USING_MODULE is not set
# #

View File

@ -5,7 +5,7 @@
/* Program Entry, set to mark it as "used" and avoid gc */ /* Program Entry, set to mark it as "used" and avoid gc */
MEMORY MEMORY
{ {
ROM (rx) : ORIGIN = 0x08000000, LENGTH = 1024 /* 1024KB flash */ ROM (rx) : ORIGIN = 0x08000000, LENGTH = 1024k /* 1024KB flash */
RAM (rw) : ORIGIN = 0x20000000, LENGTH = 192k /* 192KB sram */ RAM (rw) : ORIGIN = 0x20000000, LENGTH = 192k /* 192KB sram */
} }
ENTRY(Reset_Handler) ENTRY(Reset_Handler)
@ -153,4 +153,10 @@ SECTIONS
.debug_funcnames 0 : { *(.debug_funcnames) } .debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) } .debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) } .debug_varnames 0 : { *(.debug_varnames) }
.ARM.attributes 0 : { *(.ARM.attributes) }
MAPPING_TABLE (NOLOAD) : { *(MAPPING_TABLE) } >RAM_SHARED
MB_MEM1 (NOLOAD) : { *(MB_MEM1) } >RAM_SHARED
MB_MEM2 (NOLOAD) : { _sMB_MEM2 = . ; *(MB_MEM2) ; _eMB_MEM2 = . ; } >RAM_SHARED
} }

View File

@ -40,7 +40,7 @@
#define RT_USING_DEVICE #define RT_USING_DEVICE
#define RT_USING_CONSOLE #define RT_USING_CONSOLE
#define RT_CONSOLEBUF_SIZE 128 #define RT_CONSOLEBUF_SIZE 128
#define RT_CONSOLE_DEVICE_NAME "uart" #define RT_CONSOLE_DEVICE_NAME "uart1"
#define RT_VER_NUM 0x40003 #define RT_VER_NUM 0x40003
#define ARCH_ARM #define ARCH_ARM
#define RT_USING_CPU_FFS #define RT_USING_CPU_FFS
@ -74,12 +74,6 @@
/* Device virtual file system */ /* Device virtual file system */
#define RT_USING_DFS
#define DFS_USING_WORKDIR
#define DFS_FILESYSTEMS_MAX 2
#define DFS_FILESYSTEM_TYPES_MAX 2
#define DFS_FD_MAX 16
#define RT_USING_DFS_DEVFS
/* Device Drivers */ /* Device Drivers */
@ -96,7 +90,7 @@
/* POSIX layer and C standard library */ /* POSIX layer and C standard library */
#define RT_USING_LIBC #define RT_USING_LIBC
#define RT_USING_POSIX
/* Network */ /* Network */