From 6262acb5f9fc3012b3d3492633c5bb6aee93f56e Mon Sep 17 00:00:00 2001 From: ZYH Date: Thu, 11 Oct 2018 10:14:49 +0800 Subject: [PATCH 1/7] [BSP][STM32F1xx-HAL] fix hse when hse no trigger MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复当选择HSE 而HSE不起振时 assert的问题,并优化模拟器参数 --- bsp/stm32f10x-HAL/drivers/board.c | 48 ++++- bsp/stm32f10x-HAL/project.uvprojx | 286 +++++++---------------------- bsp/stm32f10x-HAL/template.uvprojx | 25 +-- 3 files changed, 126 insertions(+), 233 deletions(-) diff --git a/bsp/stm32f10x-HAL/drivers/board.c b/bsp/stm32f10x-HAL/drivers/board.c index 0c880d4746..8039b82759 100644 --- a/bsp/stm32f10x-HAL/drivers/board.c +++ b/bsp/stm32f10x-HAL/drivers/board.c @@ -47,6 +47,7 @@ void HAL_MspInit(void) __HAL_AFIO_REMAP_SWJ_NOJTAG(); } + void SystemClock_Config(void) { rt_err_t ret = RT_EOK; @@ -63,7 +64,19 @@ void SystemClock_Config(void) RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9; ret = HAL_RCC_OscConfig(&RCC_OscInitStruct); - RT_ASSERT(ret == HAL_OK); + if(ret == HAL_TIMEOUT) + { + /* HSE timeout switch to HSI */ + rt_memset(&RCC_OscInitStruct, 0, sizeof(RCC_OscInitStruct)); + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; + RCC_OscInitStruct.HSIState = RCC_HSI_ON; + RCC_OscInitStruct.HSICalibrationValue = 16; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI_DIV2; + RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL16; + ret = HAL_RCC_OscConfig(&RCC_OscInitStruct); + RT_ASSERT(ret == HAL_OK); + } /* Initializes the CPU, AHB and APB busses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | @@ -103,6 +116,38 @@ void SystemClock_Config(void) #endif } +static void m3_m4_delay_us(rt_uint32_t us) +{ + int i = (HAL_RCC_GetHCLKFreq() / 4000000 * us); + while (i) + { + i--; + } +} + +void HAL_Delay(__IO uint32_t Delay) +{ + m3_m4_delay_us(Delay * 10); +} + +extern __IO uint32_t uwTick; +uint32_t HAL_GetTick(void) +{ + HAL_Delay(1); + uwTick ++; + return uwTick; +} + +void HAL_SuspendTick(void) +{ + /* we should not suspend tick */ +} + +void HAL_ResumeTick(void) +{ + /* we should not resume tick */ +} + /** * This is the timer interrupt service routine. * @@ -111,6 +156,7 @@ void SysTick_Handler(void) { /* enter interrupt */ rt_interrupt_enter(); + HAL_IncTick(); rt_tick_increase(); /* leave interrupt */ diff --git a/bsp/stm32f10x-HAL/project.uvprojx b/bsp/stm32f10x-HAL/project.uvprojx index 3f5830884c..ec6814f43a 100644 --- a/bsp/stm32f10x-HAL/project.uvprojx +++ b/bsp/stm32f10x-HAL/project.uvprojx @@ -1,43 +1,46 @@ + 2.1 +
### uVision Project, (C) Keil Software
+ rtthread-stm32 0x4 ARM-ADS - 5060528::V5.06 update 5 (build 528)::ARMCC + 5060750::V5.06 update 6 (build 750)::ARMCC 0 - STM32F103RB + STM32F103RC STMicroelectronics Keil.STM32F1xx_DFP.2.2.0 http://www.keil.com/pack/ - IRAM(0x20000000,0x5000) IROM(0x08000000,0x20000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE - - - UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM)) + IRAM(0x20000000,0xC000) IROM(0x08000000,0x40000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE + + + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_512 -FS08000000 -FL080000 -FP0($$Device:STM32F103RC$Flash\STM32F10x_512.FLM)) 0 - $$Device:STM32F103RB$Device\Include\stm32f10x.h - - - - - - - - - - $$Device:STM32F103RB$SVD\STM32F103xx.svd + $$Device:STM32F103RC$Device\Include\stm32f10x.h + + + + + + + + + + $$Device:STM32F103RC$SVD\STM32F103xx.svd 0 0 - - - - - + + + + + 0 0 @@ -59,8 +62,8 @@ 0 0 - - + + 0 0 0 @@ -69,8 +72,8 @@ 0 0 - - + + 0 0 0 @@ -80,14 +83,14 @@ 1 0 fromelf --bin !L --output rtthread.bin - + 0 0 0 0 0 - + 0 @@ -101,17 +104,17 @@ 0 0 3 - - + + 1 SARMCM3.DLL -REMAP - DCM.DLL - -pCM3 + DARMSTM.DLL + -pSTM32F103RC SARMCM3.DLL - + TCM.DLL -pCM3 @@ -135,11 +138,11 @@ 1 BIN\UL2CM3.DLL - "" () - - - - + + + + + 0 @@ -172,7 +175,7 @@ 0 0 "Cortex-M3" - + 0 0 0 @@ -241,12 +244,12 @@ 0 0x20000000 - 0x5000 + 0xc000 1 0x8000000 - 0x20000 + 0x40000 0 @@ -271,7 +274,7 @@ 1 0x8000000 - 0x20000 + 0x40000 1 @@ -296,7 +299,7 @@ 0 0x20000000 - 0x5000 + 0xc000 0 @@ -304,7 +307,7 @@ 0x0 - + 1 @@ -321,6 +324,7 @@ 0 0 1 + 0 0 1 1 @@ -330,9 +334,9 @@ 0 0 - + STM32F103xB, USE_HAL_DRIVER - + drivers;applications;.;Libraries/CMSIS/Device/ST/STM32F1xx/Include;Libraries/STM32F1xx_HAL_Driver/Inc;Libraries/CMSIS/Include;../../include;../../libcpu/arm/cortex-m3;../../libcpu/arm/common;../../components/drivers/include;../../components/drivers/include;../../components/drivers/include;../../components/finsh @@ -348,10 +352,10 @@ 0 0 - - - - + + + + @@ -363,13 +367,13 @@ 0 0x08000000 0x20000000 - - - - - --keep *.o(.rti_fn.*) --keep *.o(FSymTab) - - + + .\build\rtthread-stm32.sct + + + --keep *.o(.rti_fn.*) --keep *.o(FSymTab) + + @@ -382,22 +386,16 @@ 1 drivers/board.c - - stm32f1xx_it.c 1 drivers/stm32f1xx_it.c - - drv_gpio.c 1 drivers/drv_gpio.c - - drv_usart.c 1 @@ -423,330 +421,236 @@ 1 Libraries/CMSIS/Device/ST/STM32F1xx/Source/Templates/system_stm32f1xx.c - - stm32f1xx_hal_adc.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c - - stm32f1xx_hal_adc_ex.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c - - stm32f1xx_hal_gpio.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c - - stm32f1xx_hal_gpio_ex.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c - - stm32f1xx_hal_flash.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c - - stm32f1xx_hal_flash_ex.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c - - stm32f1xx_hal_dma.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c - - stm32f1xx_hal_cortex.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c - - stm32f1xx_hal_crc.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_crc.c - - stm32f1xx_hal_i2c.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c - - stm32f1xx_hal_irda.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_irda.c - - stm32f1xx_hal_iwdg.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_iwdg.c - - stm32f1xx_hal_pwr.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c - - stm32f1xx_hal_rcc.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c - - stm32f1xx_hal_rcc_ex.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c - - stm32f1xx_hal_rtc.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rtc.c - - stm32f1xx_hal_rtc_ex.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rtc_ex.c - - stm32f1xx_hal_smartcard.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_smartcard.c - - stm32f1xx_hal_spi.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c - - stm32f1xx_hal_spi_ex.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi_ex.c - - stm32f1xx_hal_tim.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c - - stm32f1xx_hal_tim_ex.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c - - stm32f1xx_hal_uart.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c - - stm32f1xx_hal_usart.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_usart.c - - stm32f1xx_hal_wwdg.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_wwdg.c - - stm32f1xx_hal.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c - - stm32f1xx_ll_adc.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_adc.c - - stm32f1xx_ll_crc.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_crc.c - - stm32f1xx_ll_dac.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_dac.c - - stm32f1xx_ll_dma.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_dma.c - - stm32f1xx_ll_exti.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_exti.c - - stm32f1xx_ll_fsmc.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_fsmc.c - - stm32f1xx_ll_gpio.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_gpio.c - - stm32f1xx_ll_i2c.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_i2c.c - - stm32f1xx_ll_pwr.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_pwr.c - - stm32f1xx_ll_rcc.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_rcc.c - - stm32f1xx_ll_rtc.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_rtc.c - - stm32f1xx_ll_sdmmc.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_sdmmc.c - - stm32f1xx_ll_spi.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_spi.c - - stm32f1xx_ll_tim.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_tim.c - - stm32f1xx_ll_usart.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usart.c - - stm32f1xx_ll_usb.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_usb.c - - stm32f1xx_ll_utils.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_ll_utils.c - - stm32f1xx_hal_can.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_can.c - - stm32f1xx_hal_pcd.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd.c - - stm32f1xx_hal_pcd_ex.c 1 Libraries/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pcd_ex.c - - startup_stm32f103xb.s 2 @@ -762,99 +666,71 @@ 1 ../../src/clock.c - - components.c 1 ../../src/components.c - - device.c 1 ../../src/device.c - - idle.c 1 ../../src/idle.c - - ipc.c 1 ../../src/ipc.c - - irq.c 1 ../../src/irq.c - - kservice.c 1 ../../src/kservice.c - - mem.c 1 ../../src/mem.c - - memheap.c 1 ../../src/memheap.c - - mempool.c 1 ../../src/mempool.c - - object.c 1 ../../src/object.c - - scheduler.c 1 ../../src/scheduler.c - - signal.c 1 ../../src/signal.c - - thread.c 1 ../../src/thread.c - - timer.c 1 @@ -870,29 +746,21 @@ 1 ../../libcpu/arm/cortex-m3/cpuport.c - - context_rvds.S 2 ../../libcpu/arm/cortex-m3/context_rvds.S - - backtrace.c 1 ../../libcpu/arm/common/backtrace.c - - div0.c 1 ../../libcpu/arm/common/div0.c - - showmem.c 1 @@ -908,50 +776,36 @@ 1 ../../components/drivers/misc/pin.c - - serial.c 1 ../../components/drivers/serial/serial.c - - completion.c 1 ../../components/drivers/src/completion.c - - dataqueue.c 1 ../../components/drivers/src/dataqueue.c - - pipe.c 1 ../../components/drivers/src/pipe.c - - ringbuffer.c 1 ../../components/drivers/src/ringbuffer.c - - waitqueue.c 1 ../../components/drivers/src/waitqueue.c - - workqueue.c 1 @@ -967,36 +821,26 @@ 1 ../../components/finsh/shell.c - - symbol.c 1 ../../components/finsh/symbol.c - - cmd.c 1 ../../components/finsh/cmd.c - - msh.c 1 ../../components/finsh/msh.c - - msh_cmd.c 1 ../../components/finsh/msh_cmd.c - - msh_file.c 1 @@ -1007,9 +851,11 @@ + - - - + + + +
diff --git a/bsp/stm32f10x-HAL/template.uvprojx b/bsp/stm32f10x-HAL/template.uvprojx index 4559d8f28c..5f542f225b 100644 --- a/bsp/stm32f10x-HAL/template.uvprojx +++ b/bsp/stm32f10x-HAL/template.uvprojx @@ -14,16 +14,16 @@ 0 - STM32F103RB + STM32F103RC STMicroelectronics Keil.STM32F1xx_DFP.2.2.0 http://www.keil.com/pack/ - IRAM(0x20000000,0x5000) IROM(0x08000000,0x20000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE + IRAM(0x20000000,0xC000) IROM(0x08000000,0x40000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE - UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128 -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM)) + UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_512 -FS08000000 -FL080000 -FP0($$Device:STM32F103RC$Flash\STM32F10x_512.FLM)) 0 - $$Device:STM32F103RB$Device\Include\stm32f10x.h + $$Device:STM32F103RC$Device\Include\stm32f10x.h @@ -33,7 +33,7 @@ - $$Device:STM32F103RB$SVD\STM32F103xx.svd + $$Device:STM32F103RC$SVD\STM32F103xx.svd 0 0 @@ -111,8 +111,8 @@ SARMCM3.DLL -REMAP - DCM.DLL - -pCM3 + DARMSTM.DLL + -pSTM32F103RC SARMCM3.DLL TCM.DLL @@ -138,7 +138,7 @@ 1 BIN\UL2CM3.DLL - "" () + @@ -244,12 +244,12 @@ 0 0x20000000 - 0x5000 + 0xc000 1 0x8000000 - 0x20000 + 0x40000 0 @@ -274,7 +274,7 @@ 1 0x8000000 - 0x20000 + 0x40000 1 @@ -299,7 +299,7 @@ 0 0x20000000 - 0x5000 + 0xc000 0 @@ -324,6 +324,7 @@ 0 0 1 + 0 0 1 1 From 6e5751d49bd9541902e13e0f673333af60145608 Mon Sep 17 00:00:00 2001 From: ZYH Date: Thu, 11 Oct 2018 10:18:24 +0800 Subject: [PATCH 2/7] =?UTF-8?q?[BSP][STM32F1xx-HAL]=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=8D=8F=E8=AE=AE=20apache2.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/stm32f10x-HAL/applications/main.c | 8 ++------ bsp/stm32f10x-HAL/drivers/board.c | 9 +++------ bsp/stm32f10x-HAL/drivers/board.h | 9 +++------ bsp/stm32f10x-HAL/drivers/drv_gpio.c | 9 +++------ bsp/stm32f10x-HAL/drivers/drv_gpio.h | 9 +++------ bsp/stm32f10x-HAL/drivers/drv_sdcard.c | 17 ++--------------- bsp/stm32f10x-HAL/drivers/drv_sdcard.h | 17 ++--------------- bsp/stm32f10x-HAL/drivers/drv_spi.c | 9 +++------ bsp/stm32f10x-HAL/drivers/drv_spi.h | 9 +++------ bsp/stm32f10x-HAL/drivers/drv_usart.c | 9 +++------ bsp/stm32f10x-HAL/drivers/drv_usart.h | 9 +++------ bsp/stm32f10x-HAL/drivers/drv_usb.c | 9 +++------ bsp/stm32f10x-HAL/drivers/drv_usb.h | 9 +++------ 13 files changed, 36 insertions(+), 96 deletions(-) diff --git a/bsp/stm32f10x-HAL/applications/main.c b/bsp/stm32f10x-HAL/applications/main.c index 0f5e6000a8..77536078ae 100644 --- a/bsp/stm32f10x-HAL/applications/main.c +++ b/bsp/stm32f10x-HAL/applications/main.c @@ -1,11 +1,7 @@ /* - * File : main.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2009, RT-Thread Development Team + * Copyright (c) 2006-2018, RT-Thread Development Team * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE + * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes diff --git a/bsp/stm32f10x-HAL/drivers/board.c b/bsp/stm32f10x-HAL/drivers/board.c index 8039b82759..7ce0503f90 100644 --- a/bsp/stm32f10x-HAL/drivers/board.c +++ b/bsp/stm32f10x-HAL/drivers/board.c @@ -1,11 +1,8 @@ /* - * File : board.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2009 RT-Thread Develop Team + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE * * Change Logs: * Date Author Notes diff --git a/bsp/stm32f10x-HAL/drivers/board.h b/bsp/stm32f10x-HAL/drivers/board.h index 731dc67a41..2268753677 100644 --- a/bsp/stm32f10x-HAL/drivers/board.h +++ b/bsp/stm32f10x-HAL/drivers/board.h @@ -1,11 +1,8 @@ /* - * File : board.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2009, RT-Thread Development Team + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE * * Change Logs: * Date Author Notes diff --git a/bsp/stm32f10x-HAL/drivers/drv_gpio.c b/bsp/stm32f10x-HAL/drivers/drv_gpio.c index 5c780435c7..7fd20db49a 100644 --- a/bsp/stm32f10x-HAL/drivers/drv_gpio.c +++ b/bsp/stm32f10x-HAL/drivers/drv_gpio.c @@ -1,11 +1,8 @@ /* - * File : drv_gpio.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2015, RT-Thread Development Team + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE * * Change Logs: * Date Author Notes diff --git a/bsp/stm32f10x-HAL/drivers/drv_gpio.h b/bsp/stm32f10x-HAL/drivers/drv_gpio.h index 4d7101da1a..49a6149ff4 100644 --- a/bsp/stm32f10x-HAL/drivers/drv_gpio.h +++ b/bsp/stm32f10x-HAL/drivers/drv_gpio.h @@ -1,11 +1,8 @@ /* - * File : drv_gpio.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2015, RT-Thread Development Team + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE * * Change Logs: * Date Author Notes diff --git a/bsp/stm32f10x-HAL/drivers/drv_sdcard.c b/bsp/stm32f10x-HAL/drivers/drv_sdcard.c index e3486d1959..7e5959f63b 100644 --- a/bsp/stm32f10x-HAL/drivers/drv_sdcard.c +++ b/bsp/stm32f10x-HAL/drivers/drv_sdcard.c @@ -1,21 +1,8 @@ /* - * File : drv_sdcard.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2017, RT-Thread Development Team + * Copyright (c) 2006-2018, RT-Thread Development Team * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * SPDX-License-Identifier: Apache-2.0 * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Change Logs: * Date Author Notes diff --git a/bsp/stm32f10x-HAL/drivers/drv_sdcard.h b/bsp/stm32f10x-HAL/drivers/drv_sdcard.h index beaf1faf2b..133173832f 100644 --- a/bsp/stm32f10x-HAL/drivers/drv_sdcard.h +++ b/bsp/stm32f10x-HAL/drivers/drv_sdcard.h @@ -1,21 +1,8 @@ /* - * File : drv_sdcard.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2017, RT-Thread Development Team + * Copyright (c) 2006-2018, RT-Thread Development Team * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * SPDX-License-Identifier: Apache-2.0 * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Change Logs: * Date Author Notes diff --git a/bsp/stm32f10x-HAL/drivers/drv_spi.c b/bsp/stm32f10x-HAL/drivers/drv_spi.c index 14b24365fb..2262f76caa 100644 --- a/bsp/stm32f10x-HAL/drivers/drv_spi.c +++ b/bsp/stm32f10x-HAL/drivers/drv_spi.c @@ -1,11 +1,8 @@ /* - * File : dev_gpio.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2015, RT-Thread Development Team + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE * * Change Logs: * Date Author Notes diff --git a/bsp/stm32f10x-HAL/drivers/drv_spi.h b/bsp/stm32f10x-HAL/drivers/drv_spi.h index ce88c2be34..90dcbf6b5a 100644 --- a/bsp/stm32f10x-HAL/drivers/drv_spi.h +++ b/bsp/stm32f10x-HAL/drivers/drv_spi.h @@ -1,11 +1,8 @@ /* - * File : gpio.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2015, RT-Thread Development Team + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE * * Change Logs: * Date Author Notes diff --git a/bsp/stm32f10x-HAL/drivers/drv_usart.c b/bsp/stm32f10x-HAL/drivers/drv_usart.c index 771f4d62a1..09fcef32b4 100644 --- a/bsp/stm32f10x-HAL/drivers/drv_usart.c +++ b/bsp/stm32f10x-HAL/drivers/drv_usart.c @@ -1,11 +1,8 @@ /* - * File : drv_usart.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2006-2013, RT-Thread Development Team + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE * * Change Logs: * Date Author Notes diff --git a/bsp/stm32f10x-HAL/drivers/drv_usart.h b/bsp/stm32f10x-HAL/drivers/drv_usart.h index 78b46739e5..a7352914a8 100644 --- a/bsp/stm32f10x-HAL/drivers/drv_usart.h +++ b/bsp/stm32f10x-HAL/drivers/drv_usart.h @@ -1,11 +1,8 @@ /* - * File : usart.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2009, RT-Thread Development Team + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE * * Change Logs: * Date Author Notes diff --git a/bsp/stm32f10x-HAL/drivers/drv_usb.c b/bsp/stm32f10x-HAL/drivers/drv_usb.c index 111fc1b308..b9bf9bb535 100644 --- a/bsp/stm32f10x-HAL/drivers/drv_usb.c +++ b/bsp/stm32f10x-HAL/drivers/drv_usb.c @@ -1,11 +1,8 @@ /* - * File : drv_usb.c - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2015, RT-Thread Development Team + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE * * Change Logs: * Date Author Notes diff --git a/bsp/stm32f10x-HAL/drivers/drv_usb.h b/bsp/stm32f10x-HAL/drivers/drv_usb.h index 37932fae2a..c17204fca9 100644 --- a/bsp/stm32f10x-HAL/drivers/drv_usb.h +++ b/bsp/stm32f10x-HAL/drivers/drv_usb.h @@ -1,11 +1,8 @@ /* - * File : drv_usb.h - * This file is part of RT-Thread RTOS - * COPYRIGHT (C) 2015, RT-Thread Development Team + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rt-thread.org/license/LICENSE * * Change Logs: * Date Author Notes From d154c3e936f5163d96895120c372dcfb95402320 Mon Sep 17 00:00:00 2001 From: chenyong <1521761801@qq.com> Date: Thu, 11 Oct 2018 12:44:14 +0800 Subject: [PATCH 3/7] [net][sal] Add WIZnet chips TCP/IP address family support Signed-off-by: chenyong <1521761801@qq.com> --- components/net/sal_socket/include/sal_socket.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/net/sal_socket/include/sal_socket.h b/components/net/sal_socket/include/sal_socket.h index 477112392c..b5fa5170b9 100644 --- a/components/net/sal_socket/include/sal_socket.h +++ b/components/net/sal_socket/include/sal_socket.h @@ -85,13 +85,15 @@ typedef uint16_t in_port_t; #define AF_INET6 10 #define AF_CAN 29 /* Controller Area Network */ #define AF_AT 45 /* AT socket */ +#define AF_WIZ 46 /* WIZnet socket */ #define PF_INET AF_INET #define PF_INET6 AF_INET6 #define PF_UNSPEC AF_UNSPEC #define PF_CAN AF_CAN #define PF_AT AF_AT +#define PF_WIZ AF_WIZ -#define AF_MAX (AF_AT + 1) /* For now.. */ +#define AF_MAX (AF_WIZ + 1) /* For now.. */ #define IPPROTO_IP 0 #define IPPROTO_ICMP 1 From 0893e542930b1f0c81a4e2cc0893939a08c456bf Mon Sep 17 00:00:00 2001 From: ZYH Date: Thu, 11 Oct 2018 11:38:04 +0800 Subject: [PATCH 4/7] =?UTF-8?q?[bsp][stm32f1xx-hal]=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=BD=93=E5=BC=80=E5=90=AF=E4=BC=98=E5=8C=96=E6=97=B6m3=5Fm4?= =?UTF-8?q?=5Fdelay=5Fus=E5=BB=B6=E6=97=B6=E5=A4=B1=E6=95=88=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/stm32f10x-HAL/drivers/board.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bsp/stm32f10x-HAL/drivers/board.c b/bsp/stm32f10x-HAL/drivers/board.c index 7ce0503f90..5c7e44c4f8 100644 --- a/bsp/stm32f10x-HAL/drivers/board.c +++ b/bsp/stm32f10x-HAL/drivers/board.c @@ -115,11 +115,12 @@ void SystemClock_Config(void) static void m3_m4_delay_us(rt_uint32_t us) { - int i = (HAL_RCC_GetHCLKFreq() / 4000000 * us); - while (i) + __IO uint32_t Delay = us * (SystemCoreClock / 8U / 1000000U); + do { - i--; - } + __NOP(); + } + while (Delay --); } void HAL_Delay(__IO uint32_t Delay) From ffdd7f98adf778f7fdfe46bf48d2845de4f559f4 Mon Sep 17 00:00:00 2001 From: ZYH Date: Thu, 11 Oct 2018 16:47:25 +0800 Subject: [PATCH 5/7] =?UTF-8?q?[Bsp][stm32f4xx-hal]=E4=BF=AE=E5=A4=8DI2C?= =?UTF-8?q?=E5=9C=A8=E5=BC=80=E5=90=AF=E4=BC=98=E5=8C=96=E6=97=B6=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E5=BB=B6=E6=97=B6=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/stm32f4xx-HAL/drivers/drv_i2c.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bsp/stm32f4xx-HAL/drivers/drv_i2c.c b/bsp/stm32f4xx-HAL/drivers/drv_i2c.c index f1e4ca5a5f..4cc04ae292 100644 --- a/bsp/stm32f4xx-HAL/drivers/drv_i2c.c +++ b/bsp/stm32f4xx-HAL/drivers/drv_i2c.c @@ -78,11 +78,12 @@ static rt_int32_t drv_get_scl(void *data) static void drv_udelay(rt_uint32_t us) { - int i = (HAL_RCC_GetHCLKFreq() / 4000000 * us); - while (i) + __IO uint32_t Delay = us * (SystemCoreClock / 8U / 1000000U); + do { - i--; - } + __NOP(); + } + while (Delay --); } static const struct rt_i2c_bit_ops drv_bit_ops = From bcfba031d5f4ddd888719178bbec9cb2ba9a9545 Mon Sep 17 00:00:00 2001 From: ZYH Date: Thu, 11 Oct 2018 18:09:31 +0800 Subject: [PATCH 6/7] =?UTF-8?q?[Bsp][stm32f4xx-hal]=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E4=B8=B2=E5=8F=A3=E5=AE=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/stm32f4xx-HAL/Kconfig | 12 ++++++--- bsp/stm32f4xx-HAL/drivers/drv_usart.c | 35 ++++++++++++++------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/bsp/stm32f4xx-HAL/Kconfig b/bsp/stm32f4xx-HAL/Kconfig index ca66286f50..95ffd73be8 100644 --- a/bsp/stm32f4xx-HAL/Kconfig +++ b/bsp/stm32f4xx-HAL/Kconfig @@ -297,20 +297,24 @@ config RT_HSE_VALUE config RT_HSE_HCLK int "System Clock Value" default 84000000 -config RT_USING_UART1 +config BSP_USING_UART1 bool "Using UART1" + select RT_USING_SERIAL default y -config RT_USING_UART2 +config BSP_USING_UART2 bool "Using UART2" + select RT_USING_SERIAL default n -config RT_USING_UART3 +config BSP_USING_UART3 bool "Using UART3" + select RT_USING_SERIAL default n -config RT_USING_UART6 +config BSP_USING_UART6 bool "Using UART6" + select RT_USING_SERIAL default n if RT_USING_CAN diff --git a/bsp/stm32f4xx-HAL/drivers/drv_usart.c b/bsp/stm32f4xx-HAL/drivers/drv_usart.c index d065d853fc..3bd28d59e2 100644 --- a/bsp/stm32f4xx-HAL/drivers/drv_usart.c +++ b/bsp/stm32f4xx-HAL/drivers/drv_usart.c @@ -147,7 +147,7 @@ static const struct rt_uart_ops drv_uart_ops = drv_getc, }; -#if defined(RT_USING_UART1) +#if defined(BSP_USING_UART1) /* UART1 device driver structure */ static struct drv_uart uart1; struct rt_serial_device serial1; @@ -168,9 +168,9 @@ void USART1_IRQHandler(void) /* leave interrupt */ rt_interrupt_leave(); } -#endif /* RT_USING_UART1 */ +#endif /* BSP_USING_UART1 */ -#if defined(RT_USING_UART2) +#if defined(BSP_USING_UART2) /* UART2 device driver structure */ static struct drv_uart uart2; struct rt_serial_device serial2; @@ -191,9 +191,9 @@ void USART2_IRQHandler(void) /* leave interrupt */ rt_interrupt_leave(); } -#endif /* RT_USING_UART2 */ +#endif /* BSP_USING_UART2 */ -#if defined(RT_USING_UART3) +#if defined(BSP_USING_UART3) /* UART3 device driver structure */ static struct drv_uart uart3; struct rt_serial_device serial3; @@ -214,9 +214,9 @@ void USART3_IRQHandler(void) /* leave interrupt */ rt_interrupt_leave(); } -#endif /* RT_USING_UART3 */ +#endif /* BSP_USING_UART3 */ -#if defined(RT_USING_UART6) +#if defined(BSP_USING_UART6) /* UART6 device driver structure */ static struct drv_uart uart6; struct rt_serial_device serial6; @@ -237,7 +237,7 @@ void USART6_IRQHandler(void) /* leave interrupt */ rt_interrupt_leave(); } -#endif /* RT_USING_UART6 */ +#endif /* BSP_USING_UART6 */ /** * @brief UART MSP Initialization @@ -365,7 +365,7 @@ int hw_usart_init(void) { struct drv_uart *uart; struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT; -#ifdef RT_USING_UART1 +#ifdef BSP_USING_UART1 uart = &uart1; uart->UartHandle.Instance = USART1; uart->irq = USART1_IRQn; @@ -375,8 +375,8 @@ int hw_usart_init(void) rt_hw_serial_register(&serial1, "uart1", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, uart); -#endif /* RT_USING_UART1 */ -#ifdef RT_USING_UART2 +#endif /* BSP_USING_UART1 */ +#ifdef BSP_USING_UART2 uart = &uart2; uart->UartHandle.Instance = USART2; uart->irq = USART2_IRQn; @@ -386,8 +386,8 @@ int hw_usart_init(void) rt_hw_serial_register(&serial2, "uart2", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, uart); -#endif /* RT_USING_UART2 */ -#ifdef RT_USING_UART3 +#endif /* BSP_USING_UART2 */ +#ifdef BSP_USING_UART3 uart = &uart3; uart->UartHandle.Instance = USART3; uart->irq = USART3_IRQn; @@ -397,18 +397,19 @@ int hw_usart_init(void) rt_hw_serial_register(&serial3, "uart3", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, uart); -#endif /* RT_USING_UART3 */ -#ifdef RT_USING_UART6 +#endif /* BSP_USING_UART3 */ +#ifdef BSP_USING_UART6 uart = &uart6; uart->UartHandle.Instance = USART6; uart->irq = USART6_IRQn; serial6.ops = &drv_uart_ops; serial6.config = config; - /* register UART2 device */ + /* register UART6 device */ rt_hw_serial_register(&serial6, "uart6", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, uart); -#endif /* RT_USING_UART6 */ +#endif /* BSP_USING_UART6 */ + return 0; } INIT_BOARD_EXPORT(hw_usart_init); From 743c264285d0d9a76db5e37eee318c7d30d14337 Mon Sep 17 00:00:00 2001 From: ZYH Date: Thu, 11 Oct 2018 18:17:35 +0800 Subject: [PATCH 7/7] =?UTF-8?q?[Bsp][stm32f4xx-hal]=E6=95=B4=E7=90=86?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/stm32f4xx-HAL/rtconfig.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bsp/stm32f4xx-HAL/rtconfig.py b/bsp/stm32f4xx-HAL/rtconfig.py index d8de63dca7..39d157a9dc 100644 --- a/bsp/stm32f4xx-HAL/rtconfig.py +++ b/bsp/stm32f4xx-HAL/rtconfig.py @@ -3,16 +3,15 @@ import os # toolchains options -ARCH='arm' -CPU='cortex-m4' -CROSS_TOOL='gcc' +ARCH = 'arm' +CPU = 'cortex-m4' +CROSS_TOOL = 'gcc' if os.getenv('RTT_CC'): CROSS_TOOL = os.getenv('RTT_CC') #device options - # cross_tool provides the cross compiler # EXEC_PATH is the compiler execute path, for example, CodeSourcery, Keil MDK, IAR if CROSS_TOOL == 'gcc': @@ -44,7 +43,7 @@ if PLATFORM == 'gcc': OBJCPY = PREFIX + 'objcopy' DEVICE = ' -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections' - CFLAGS = DEVICE + ' -std=c99 -Dgcc' # -D' + PART_TYPE + CFLAGS = DEVICE + ' -std=c99' AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -Wa,-mimplicit-it=thumb ' LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=rtthread-stm32.map,-cref,-u,Reset_Handler -T stm32_rom.ld'