mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
fix stm32 support for f1
This commit is contained in:
parent
214f20b482
commit
524bbf4329
@ -152,7 +152,7 @@ static rt_err_t stm32_adc_get_channel(rt_int8_t rt_channel, uint32_t *stm32_chan
|
||||
#define ADCx_CLK_ENABLE __HAL_RCC_ADC1_CLK_ENABLE
|
||||
|
||||
static void adcx_clock_enable(ADC_HandleTypeDef *adch) {
|
||||
#if defined(STM32F0) || defined(STM32F4) || defined(STM32F7) || defined(STM32L1)
|
||||
#if defined(STM32F0) || defined(STM32F1) || defined(STM32F4) || defined(STM32F7) || defined(STM32L1)
|
||||
ADCx_CLK_ENABLE();
|
||||
#elif defined(STM32H7A3xx) || defined(STM32H7A3xxQ) || defined(STM32H7B3xx) || defined(STM32H7B3xxQ)
|
||||
__HAL_RCC_ADC12_CLK_ENABLE();
|
||||
@ -340,7 +340,7 @@ static rt_int16_t stm32_adc_get_vref (struct rt_adc_device *device)
|
||||
|
||||
static void adc_wait_for_eoc_or_timeout(ADC_HandleTypeDef *adcHandle, int32_t timeout) {
|
||||
uint32_t tickstart = HAL_GetTick();
|
||||
#if defined(STM32F4) || defined(STM32F7) || defined(STM32L1)
|
||||
#if defined(STM32F4) || defined(STM32F1) || defined(STM32F7) || defined(STM32L1)
|
||||
while ((adcHandle->Instance->SR & ADC_FLAG_EOC) != ADC_FLAG_EOC) {
|
||||
#elif defined(STM32F0) || defined(STM32G0) || defined(STM32G4) || defined(STM32H5) || defined(STM32H7) || defined(STM32L4) || defined(STM32WB)
|
||||
while (READ_BIT(adcHandle->Instance->ISR, ADC_FLAG_EOC) != ADC_FLAG_EOC) {
|
||||
|
@ -24,6 +24,16 @@
|
||||
//#define LOG_TAG "drv.dac"
|
||||
//#include <drv_log.h>
|
||||
|
||||
#ifndef DAC1_CONFIG
|
||||
#undef BSP_USING_DAC1
|
||||
#endif
|
||||
|
||||
#ifndef DAC2_CONFIG
|
||||
#undef BSP_USING_DAC2
|
||||
#endif
|
||||
|
||||
#if defined(BSP_USING_DAC1) || defined(BSP_USING_DAC2)
|
||||
|
||||
static DAC_HandleTypeDef dac_config[] =
|
||||
{
|
||||
#ifdef BSP_USING_DAC1
|
||||
@ -386,4 +396,6 @@ int pika_hal_platform_DAC_ioctl_disable(pika_dev* dev) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* BSP_USING_DAC */
|
||||
|
@ -17,6 +17,9 @@ void mp_hal_gpio_clock_enable(GPIO_TypeDef *gpio) {
|
||||
#if defined(STM32F0) || defined(STM32L1)
|
||||
#define AHBxENR AHBENR
|
||||
#define AHBxENR_GPIOAEN_Pos RCC_AHBENR_GPIOAEN_Pos
|
||||
#elif defined(STM32F1)
|
||||
#define AHBxENR APB2ENR
|
||||
#define AHBxENR_GPIOAEN_Pos RCC_APB2ENR_IOPAEN
|
||||
#elif defined(STM32F4) || defined(STM32F7)
|
||||
#define AHBxENR AHB1ENR
|
||||
#define AHBxENR_GPIOAEN_Pos RCC_AHB1ENR_GPIOAEN_Pos
|
||||
|
@ -12,35 +12,53 @@
|
||||
#define CHIP_FAMILY_STM32
|
||||
#define SOC_FAMILY_STM32
|
||||
#define RT_USING_DEVICE_OPS
|
||||
|
||||
#define SERIES_OF(_start) (defined(_start##xx) || defined(_start##x8) || \
|
||||
defined(_start##xB) || defined(_start##xC) || \
|
||||
defined(_start##xD) || defined(_start##xE) || defined(_start##xG))
|
||||
|
||||
#if defined(STM32H750xx) || defined(STM32H743xx) || defined(STM32H753xx) || defined(STM32H755xx) || defined(STM32H757xx)
|
||||
/* auto select HAL header */
|
||||
#if SERIES_OF(STM32H750) || SERIES_OF(STM32H743) || SERIES_OF(STM32H753) || \
|
||||
SERIES_OF(STM32H755) || SERIES_OF(STM32H757)
|
||||
#define SOC_SERIES_STM32H7
|
||||
#define CHIP_SERIES_STM32H7
|
||||
#include "stm32h7xx_hal.h"
|
||||
#elif defined(STM32F103xx) || defined(STM32F101xx) || defined(STM32F102xx)
|
||||
|
||||
#elif SERIES_OF(STM32F103) || SERIES_OF(STM32F102) || SERIES_OF(STM32F101)
|
||||
#define SOC_SERIES_STM32F1
|
||||
#define CHIP_SERIES_STM32F1
|
||||
#include "stm32f1xx_hal.h"
|
||||
#elif defined(STM32G030xx) || defined(STM32G031xx) || defined(STM32G041xx) || defined(STM32G070xx) || defined(STM32G071xx) || defined(STM32G081xx)
|
||||
|
||||
#elif SERIES_OF(STM32G030) || SERIES_OF(STM32G031) || SERIES_OF(STM32G041) || \
|
||||
SERIES_OF(STM32G070) || SERIES_OF(STM32G071) || SERIES_OF(STM32G081)
|
||||
#define SOC_SERIES_STM32G0
|
||||
#define CHIP_SERIES_STM32G0
|
||||
#include "stm32g0xx_hal.h"
|
||||
#elif defined(STM32F030xx) || defined(STM32F031xx) || defined(STM32F051xx) || defined(STM32F070xx) || defined(STM32F042xx)
|
||||
|
||||
#elif SERIES_OF(STM32F030) || SERIES_OF(STM32F031) || SERIES_OF(STM32F051) || \
|
||||
SERIES_OF(STM32F070) || SERIES_OF(STM32F042)
|
||||
#define SOC_SERIES_STM32F0
|
||||
#define CHIP_SERIES_STM32F0
|
||||
#include "stm32f0xx_hal.h"
|
||||
#elif defined(STM32F401xx) || defined(STM32F405xx) || defined(STM32F407xx) || defined(STM32F411xx)
|
||||
|
||||
#elif SERIES_OF(STM32F401) || SERIES_OF(STM32F405) || SERIES_OF(STM32F407) || \
|
||||
SERIES_OF(STM32F411)
|
||||
#define SOC_SERIES_STM32F4
|
||||
#define CHIP_SERIES_STM32F4
|
||||
#include "stm32f4xx_hal.h"
|
||||
#elif defined(STM32U585xx) || defined(STM32U575xx)
|
||||
|
||||
#elif SERIES_OF(STM32U585) || SERIES_OF(STM32U575)
|
||||
#define SOC_SERIES_STM32U5
|
||||
#define CHIP_SERIES_STM32U5
|
||||
#include "stm32u5xx_hal.h"
|
||||
#elif defined(STM32L451xx) || defined(STM32L452xx) || defined(STM32L462xx) || defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)
|
||||
|
||||
#elif SERIES_OF(STM32L451) || SERIES_OF(STM32L452) || SERIES_OF(STM32L462) || \
|
||||
SERIES_OF(STM32L471) || SERIES_OF(STM32L475) || SERIES_OF(STM32L476) || \
|
||||
SERIES_OF(STM32L485) || SERIES_OF(STM32L486)
|
||||
#define SOC_SERIES_STM32L4
|
||||
#define CHIP_SERIES_STM32L4
|
||||
#include "stm32l4xx_hal.h"
|
||||
|
||||
#else
|
||||
#error "Unsupported STM32 series"
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user