diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_adc.c b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_adc.c index 074d0be182982e6d38fa9232553111b41398155c..12a0239070e7afa0dcf312edbe7b172fc362d406 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_adc.c +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_adc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_adc.h b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_adc.h index 1d700569e0535a57cd670f49f96a919abe20623f..993c53f61b20720d57a0c3e729a1e9019fcea8c8 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_adc.h +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_adc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_can.c b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_can.c index 5bd749f90635ab5816d285eb31e5c0f27f0753a8..2b02447d86d24dec6af6db44487edc622561e9ad 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_can.c +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_can.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_can.h b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_can.h index 4edfcb6b41e7e5db21d96bc8a255e21ee026452a..a38b22be4da0a0b58bf55efa54e79b4c72d2b421 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_can.h +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_can.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_dac.c b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_dac.c index 53414aabbc3a5a8084826aeed21a2d3ea4bb5f09..80fdacf14d6eed04705f9107c6ca6efde71c071f 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_dac.c +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_dac.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_dac.h b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_dac.h index d626fe724f3655622fc26822ebea14de19072195..68bb4407a2eb8ea91e3c1bfa98b47baa6f8c4fd6 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_dac.h +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_dac.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_gpio.c b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_gpio.c index 4495a0c2b1c0c8c272555f96b68cee1d0573c315..32b37fd50681e5821d767ce468a010d7eb820853 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_gpio.c +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_gpio.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_gpio.h b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_gpio.h index 2912d2dd138aab9451c40439e790de98563b0d27..3b866fc497c6c204cf1351b27e25e5e68edd775b 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_gpio.h +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_gpio.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_hwtimer.c b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_hwtimer.c index 4c514c4c712546256ed02b8e8e971e7051b498f0..38432c1083dcafd3ad852e908a4da3632e90f496 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_hwtimer.c +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_hwtimer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -144,8 +144,15 @@ static void ch32_hwtimer_init(struct rt_hwtimer_device *timer, rt_uint32_t state tim = (TIM_HandleTypeDef *)timer->parent.user_data; tim_device = (struct ch32_hwtimer *)timer; +#if defined (SOC_RISCV_SERIES_CH32V2) + if(tim->instance == TIM1) +#elif defined(SOC_RISCV_SERIES_CH32V3) if(tim->instance == TIM1 || tim->instance == TIM8 || tim->instance == TIM9 || tim->instance == TIM10) +#else +#error " unsupported CH32 series! " + if(RT_NULL) +#endif { RCC_APB2PeriphClockCmd(tim->rcc, ENABLE); prescaler_value = (RCC_ClockStruct.PCLK2_Frequency * pclk2_doubler / 10000) - 1; @@ -168,13 +175,13 @@ static void ch32_hwtimer_init(struct rt_hwtimer_device *timer, rt_uint32_t state { tim->init.TIM_CounterMode = TIM_CounterMode_Down; } - +#if defined (SOC_RISCV_SERIES_CH32V3) /* TIM6 and TIM7 only support counter up mode */ if(tim->instance == TIM6 || tim->instance == TIM7) { tim->init.TIM_CounterMode = TIM_CounterMode_Up; } - +#endif TIM_TimeBaseInit(tim->instance, &tim->init); NVIC_InitStruct.NVIC_IRQChannel = tim_device->irqn; @@ -266,8 +273,15 @@ static rt_err_t ch32_hwtimer_control(struct rt_hwtimer_device *timer, rt_uint32_ ch32_get_pclk_doubler(&pclk1_doubler, &pclk2_doubler); RCC_GetClocksFreq(&RCC_ClockStruct); +#if defined (SOC_RISCV_SERIES_CH32V2) + if(tim->instance == TIM1) +#elif defined(SOC_RISCV_SERIES_CH32V3) if(tim->instance == TIM1 || tim->instance == TIM8 || tim->instance == TIM9 || tim->instance == TIM10) +#else +#error " unsupported CH32 series! " + if(RT_NULL) +#endif { val = RCC_ClockStruct.PCLK2_Frequency * pclk2_doubler / freq; } diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_hwtimer.h b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_hwtimer.h index 6949ff0e5046ca740a7dc181d62c11a494d3ab0c..10ed38374649d0d7cf575810b139b49a602469e8 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_hwtimer.h +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_hwtimer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -12,8 +12,12 @@ #define __DRV_HWTIMER_H__ #include - +#if defined(SOC_RISCV_SERIES_CH32V3) #include "ch32v30x_tim.h" +#endif +#if defined(SOC_RISCV_SERIES_CH32V2) +#include "ch32v20x_tim.h" +#endif #ifdef BSP_USING_HWTIMER diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_iwdt.c b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_iwdt.c index 53d350dbcae340e9a4641d6e8b9d4e7ed563ed8f..a74a37d0cb2af197ef1b55d59d7e0430702ec896 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_iwdt.c +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_iwdt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_log.h b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_log.h index e1b61708cc062d0290aeffaf73501b12851b979b..2d44d4e90149ecfef1e1d41df9cb9f6ebb2fba75 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_log.h +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_log.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_pwm.c b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_pwm.c index 2f8274785cccaa1892659f472de2455262a1984a..d58377ec8ac75934a78ff613277d7902fa61bfba 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_pwm.c +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_pwm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_pwm.h b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_pwm.h index 3b7f7c1c11c7838c086ccd4a13bf59e7c67c27b2..086201cc476fede31338cef6c35b8d23f97761b8 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_pwm.h +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_pwm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -13,7 +13,12 @@ #include #ifdef BSP_USING_PWM +#if defined(SOC_RISCV_SERIES_CH32V3) #include "ch32v30x_tim.h" +#endif +#if defined(SOC_RISCV_SERIES_CH32V2) +#include "ch32v20x_tim.h" +#endif #include #include #include diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_rtc.c b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_rtc.c index 5624792ec3f465fc7fad5447009bb6e44c06b427..e3a5d565398aecebb1583ed46dea11eba11a6294 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_rtc.c +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_rtc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_rtc.h b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_rtc.h index 6ae852a7bacaae2bc021bcda89ab2a83fdbc649b..053a9251fdb7cbccdb507a9c8574c002cb2afee6 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_rtc.h +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_rtc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_soft_i2c.c b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_soft_i2c.c index 47dd429b126f6b979a4e80b35102b1fa96db5ff4..ae460ccd2eee3dcb23a4a9279a2d9c6438167728 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_soft_i2c.c +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_soft_i2c.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_soft_i2c.h b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_soft_i2c.h index e775c7ca0a18b55dd628cade839a2be33b80fac2..1f3170cc4c217fca48841262f47540f5e6c92e07 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_soft_i2c.h +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_soft_i2c.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_soft_spi.c b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_soft_spi.c index 3db73dbb06d938d3599f45eef6bae6c4430c7de3..eb123a468637d54295f061b7937c73a48308fb7c 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_soft_spi.c +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_soft_spi.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_soft_spi.h b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_soft_spi.h index 3e38f5b988176d8d35e844c2a977efec04d45edf..4451952dfc68bdab92553f7101ecff62fc768977 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_soft_spi.h +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_soft_spi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_spi.c b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_spi.c index 7b0778f60265ace0299fb7d90729ba62d929a150..d2a48983a239d525ef3e8f80278531efff2a0d13 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_spi.c +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_spi.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_spi.h b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_spi.h index cafb0ae40a06b3505dc781f9466ef37354c6b13e..42ab229e61a51ac52fabd4e583b1a28bcbf85d04 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_spi.h +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_spi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_usart.c b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_usart.c index dd79dda1a3ab1f11ec9c46908447f1db7a4fa847..0d950f7dd30005aea86941462264540faae599d6 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_usart.c +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_usart.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_usart.h b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_usart.h index b002887a194cfdec237c1855a3d7d285fbab7eba..97d2e31626c9fb35cebcfe0ab27a40ab9f01ca67 100644 --- a/bsp/wch/risc-v/Libraries/ch32_drivers/drv_usart.h +++ b/bsp/wch/risc-v/Libraries/ch32_drivers/drv_usart.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch32v30x_libraries/ch32v307_hal/source/ch32v30x_eth.c b/bsp/wch/risc-v/Libraries/ch32v30x_libraries/ch32v307_hal/source/ch32v30x_eth.c index 53c3411372d9af5cab79c85cbdb1ccfd768d570c..602d3c9b30fcfa839bc727dec61fe901a628f3c1 100644 --- a/bsp/wch/risc-v/Libraries/ch32v30x_libraries/ch32v307_hal/source/ch32v30x_eth.c +++ b/bsp/wch/risc-v/Libraries/ch32v30x_libraries/ch32v307_hal/source/ch32v30x_eth.c @@ -1432,7 +1432,7 @@ ITStatus ETH_GetDMAITStatus(uint32_t ETH_DMA_IT) /********************************************************************* * @fn ETH_DMAClearITPendingBit * - * @brief Clears the ETHERNETs DMA IT pending bit. + * @brief Clears the ETHERNET's DMA IT pending bit. * * @param ETH_DMA_IT - specifies the interrupt pending bit to clear. * ETH_DMA_IT_NIS - Normal interrupt summary diff --git a/bsp/wch/risc-v/Libraries/ch32v30x_libraries/ch32v307_hal/source/ch32v30x_fsmc.c b/bsp/wch/risc-v/Libraries/ch32v30x_libraries/ch32v307_hal/source/ch32v30x_fsmc.c index 6da3b53cb14a3369e036218956a5252e6946e4d4..4f7580fddcb154132988f35d55eeb511f2f55a9e 100644 --- a/bsp/wch/risc-v/Libraries/ch32v30x_libraries/ch32v307_hal/source/ch32v30x_fsmc.c +++ b/bsp/wch/risc-v/Libraries/ch32v30x_libraries/ch32v307_hal/source/ch32v30x_fsmc.c @@ -249,7 +249,7 @@ void FSMC_NANDStructInit(FSMC_NANDInitTypeDef *FSMC_NANDInitStruct) * FSMC_Bank1_NORSRAM2 - FSMC Bank1 NOR/SRAM2 * FSMC_Bank1_NORSRAM3 - FSMC Bank1 NOR/SRAM3 * FSMC_Bank1_NORSRAM4 - FSMC Bank1 NOR/SRAM4 - * NewStateENABLE or DISABLE. + * NewState£:ENABLE or DISABLE. * * @return none */ diff --git a/bsp/wch/risc-v/Libraries/ch32v30x_libraries/ch32v307_hal/source/ch32v30x_rng.c b/bsp/wch/risc-v/Libraries/ch32v30x_libraries/ch32v307_hal/source/ch32v30x_rng.c index bd68c07ce83ed106a496a7d6c119f1e83892211c..766a75a2c4604041962251276dee552fcde980f2 100644 --- a/bsp/wch/risc-v/Libraries/ch32v30x_libraries/ch32v307_hal/source/ch32v30x_rng.c +++ b/bsp/wch/risc-v/Libraries/ch32v30x_libraries/ch32v307_hal/source/ch32v30x_rng.c @@ -117,7 +117,7 @@ void RNG_ClearFlag(uint8_t RNG_FLAG) * RNG_IT_CEI - Clock Error Interrupt. * RNG_IT_SEI - Seed Error Interrupt. * - * @return bitstatusSET or RESET. + * @return bitstatus£:SET or RESET. */ ITStatus RNG_GetITStatus(uint8_t RNG_IT) { diff --git a/bsp/wch/risc-v/Libraries/ch32v30x_libraries/ch32v307_hal/source/ch32v30x_sdio.c b/bsp/wch/risc-v/Libraries/ch32v30x_libraries/ch32v307_hal/source/ch32v30x_sdio.c index 7241dd1d0cabea27f49cb53eba5b739080c6c157..0fbed767c820f6d07271b706708199ede02d48c6 100644 --- a/bsp/wch/risc-v/Libraries/ch32v30x_libraries/ch32v307_hal/source/ch32v30x_sdio.c +++ b/bsp/wch/risc-v/Libraries/ch32v30x_libraries/ch32v307_hal/source/ch32v30x_sdio.c @@ -625,7 +625,7 @@ void SDIO_ClearFlag(uint32_t SDIO_FLAG) * SDIO_IT_SDIOIT - SD I/O interrupt received interrupt * SDIO_IT_CEATAEND - CE-ATA command completion signal received for CMD61 interrupt * - * @return ITStatusSET or RESET + * @return ITStatus£:SET or RESET */ ITStatus SDIO_GetITStatus(uint32_t SDIO_IT) { diff --git a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_gpio.c b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_gpio.c index 94c2116d98646f23984bdceb7ea98747e7e77d96..f84c9ff0dbf70ca4a6f83dcd653794da2f82eb55 100644 --- a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_gpio.c +++ b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_gpio.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_gpio.h b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_gpio.h index 2b6af1a5d596df826947bcaa69b75d045daf92b3..6bcd134dde6793c1e1e58aa910e0f8a055c8daee 100644 --- a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_gpio.h +++ b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_gpio.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_pfic.c b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_pfic.c index 9f012640062c4d17e6a4f65b2b2e7eb0f254c9dd..1ecd1fa44b7cc311d7150dee7eea28f03a9b002c 100644 --- a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_pfic.c +++ b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_pfic.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_pfic.h b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_pfic.h index be3c6520746fa153ee76ac6109fa7d6745dbdf90..45d40b4cfdff0bc594ec5c2848246a0326a6f1a7 100644 --- a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_pfic.h +++ b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_pfic.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_pwm.c b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_pwm.c index f9961a495ee12d53dba86dec7de2ec60d4b5d3c6..854fd0d33662becd21410a493fb5414baccedee2 100644 --- a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_pwm.c +++ b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_pwm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_pwm.h b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_pwm.h index cacf019be6d5436795569cee6671e228f32b673e..b151f719c864a051d728ed1c7291566866ed6add 100644 --- a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_pwm.h +++ b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_pwm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_spi.c b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_spi.c index 6ed44f503e4096bc49325243ac744576285f119f..9fb8a30d3d5ff0e2c799832543959704e9f0a982 100644 --- a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_spi.c +++ b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_spi.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_spi.h b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_spi.h index 2d04df692c9ab264f4f9443bfb59b89897650320..b98e714edf31623c190c6b5f2f57907d187d5520 100644 --- a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_spi.h +++ b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_spi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_sys.c b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_sys.c index d9696b6f9ea02ebe3b569fa862e5546c73a8dd7c..eefb2ad643f5b309b032a11fac212a0b40bdcd8b 100644 --- a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_sys.c +++ b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_sys.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_sys.h b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_sys.h index 9405f3c0620d26ceeb27255933169657ed148ab5..1aa8bb2ac04c5556408aa6efaed44b745586d7ad 100644 --- a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_sys.h +++ b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_sys.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_timer.c b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_timer.c index a420e53b4d7671c8bc1ebe86ff12375d6d08b622..b466a10ed046004c350df7009dfd50085085840c 100644 --- a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_timer.c +++ b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_timer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_timer.h b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_timer.h index 63a5ebef139609c51e7cef699cbd3d914e88285e..b42307e888399816a4f30a6f171f4a356010c6c7 100644 --- a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_timer.h +++ b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_timer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_uart.c b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_uart.c index a2c1aec551b2e6cfde1a0ba5d3ccf59e27ffd9cb..496c72f53464cbda22158c064a5bab6641b16c45 100644 --- a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_uart.c +++ b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_uart.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_uart.h b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_uart.h index aaec4e0d73b49225ea4f94c179bbc319aa0dc790..4fb525afa472731ee05d38389d33b4796a0b926f 100644 --- a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_uart.h +++ b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_uart.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_usbd.c b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_usbd.c index 512c19061682dd8d2e62042a89cbb74387226d41..ecd7f3fb680f65119ae0f570cd78265771d50186 100644 --- a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_usbd.c +++ b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_usbd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_usbhs.h b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_usbhs.h index 045ef75eba54aa99111e7ffbdac4474d51eebe00..d42a9e4d29220aed38ab0882891401fffd5653c6 100644 --- a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_usbhs.h +++ b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_usbhs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_wdt.c b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_wdt.c index 200f71b0616376e2bd63eaa38eb0ffda15c2c665..86e419b613fe08741902f846e92a9d3f6bebd49c 100644 --- a/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_wdt.c +++ b/bsp/wch/risc-v/Libraries/ch56x_drivers/ch56x_wdt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch56x_drivers/isr_sp.h b/bsp/wch/risc-v/Libraries/ch56x_drivers/isr_sp.h index 54c33ed942ed4bdb2a1bcbe8c70416b7d6e32dc6..f0ad37e7c2cdd128e1176ca140bf349e0ddc7747 100644 --- a/bsp/wch/risc-v/Libraries/ch56x_drivers/isr_sp.h +++ b/bsp/wch/risc-v/Libraries/ch56x_drivers/isr_sp.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/Libraries/ch56x_drivers/soc.h b/bsp/wch/risc-v/Libraries/ch56x_drivers/soc.h index e5fd9d7853d2975c3a6da9098f7e1211d0ac949d..c86f95d47fe8db8afe7aab3242203fc41d7cf2aa 100644 --- a/bsp/wch/risc-v/Libraries/ch56x_drivers/soc.h +++ b/bsp/wch/risc-v/Libraries/ch56x_drivers/soc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/ch32v208w-r0/.config b/bsp/wch/risc-v/ch32v208w-r0/.config index cb9de74b50645ccb47fdf2f5ae006bc784e236ce..cf3d4a1360752977d4d18ab6ef5cc5fc4a6c35e5 100644 --- a/bsp/wch/risc-v/ch32v208w-r0/.config +++ b/bsp/wch/risc-v/ch32v208w-r0/.config @@ -47,6 +47,7 @@ CONFIG_RT_USING_MESSAGEQUEUE=y # # Memory Management # +CONFIG_RT_PAGE_MAX_ORDER=11 # CONFIG_RT_USING_MEMPOOL is not set CONFIG_RT_USING_SMALL_MEM=y # CONFIG_RT_USING_SLAB is not set @@ -115,17 +116,20 @@ CONFIG_RT_USING_SERIAL_V1=y # CONFIG_RT_SERIAL_USING_DMA is not set CONFIG_RT_SERIAL_RB_BUFSZ=64 # CONFIG_RT_USING_CAN is not set -# CONFIG_RT_USING_HWTIMER is not set +CONFIG_RT_USING_HWTIMER=y # CONFIG_RT_USING_CPUTIME is not set -# CONFIG_RT_USING_I2C is not set +CONFIG_RT_USING_I2C=y +# CONFIG_RT_I2C_DEBUG is not set +CONFIG_RT_USING_I2C_BITOPS=y +# CONFIG_RT_I2C_BITOPS_DEBUG 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_NULL is not set # CONFIG_RT_USING_ZERO is not set # CONFIG_RT_USING_RANDOM is not set -# CONFIG_RT_USING_PWM is not set +CONFIG_RT_USING_PWM=y # CONFIG_RT_USING_MTD_NOR is not set # CONFIG_RT_USING_MTD_NAND is not set # CONFIG_RT_USING_PM is not set @@ -177,7 +181,8 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8 # # Socket is in the 'Network' category # -# CONFIG_RT_USING_CPLUSPLUS is not set +CONFIG_RT_USING_CPLUSPLUS=y +# CONFIG_RT_USING_CPLUSPLUS11 is not set # # Network @@ -194,6 +199,7 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8 # CONFIG_RT_USING_ULOG is not set # CONFIG_RT_USING_UTEST is not set # CONFIG_RT_USING_VAR_EXPORT is not set +# CONFIG_RT_USING_ADT is not set # CONFIG_RT_USING_RT_LINK is not set # CONFIG_RT_USING_VBUS is not set @@ -739,7 +745,20 @@ CONFIG_RT_LIBC_DEFAULT_TIMEZONE=8 # # Arduino libraries # -# CONFIG_PKG_USING_RTDUINO is not set +CONFIG_PKG_USING_RTDUINO=y +CONFIG_PKG_RTDUINO_PATH="/packages/arduino/RTduino" +# CONFIG_RTDUINO_NO_SETUP_LOOP is not set +CONFIG_RTDUINO_THREAD_SIZE=1536 +CONFIG_RTDUINO_THREAD_PRIO=30 +# CONFIG_RTDUINO_TINY_MODE is not set +# CONFIG_RTDUINO_SUPPORT_FLOAT_STRING is not set +# CONFIG_RTDUINO_USING_WIRE is not set +# CONFIG_RTDUINO_USING_SPI is not set +# CONFIG_RTDUINO_USING_SERVO is not set +# CONFIG_RTDUINO_USING_USBSERIAL is not set +# CONFIG_RTDUINO_USING_SHELL_CMD is not set +CONFIG_PKG_USING_RTDUINO_LATEST_VERSION=y +CONFIG_PKG_RTDUINO_VER="latest" # # Projects @@ -948,6 +967,11 @@ CONFIG_SOC_RISCV_SERIES_CH32V2=y # CONFIG_SOC_CH32V208WBU6=y +# +# Onboard Peripheral Drivers +# +# CONFIG_BSP_USING_ARDUINO is not set + # # On-chip Peripheral Drivers # @@ -961,19 +985,45 @@ CONFIG_BSP_USING_UART1=y # CONFIG_BSP_USING_UART6 is not set # CONFIG_BSP_USING_UART7 is not set # CONFIG_BSP_USING_UART8 is not set -# CONFIG_BSP_USING_ADC is not set +CONFIG_BSP_USING_ADC=y +CONFIG_BSP_USING_ADC1=y +# CONFIG_BSP_USING_ADC2 is not set +# CONFIG_ADC_CHANNEL_16 is not set +# CONFIG_ADC_CHANNEL_17 is not set # CONFIG_BSP_USING_DAC is not set -# CONFIG_BSP_USING_SOFT_I2C is not set +CONFIG_BSP_USING_SOFT_I2C=y +CONFIG_BSP_USING_I2C1=y + +# +# Notice: PC7 --> 39; PC6 --> 38 +# +CONFIG_BSP_I2C1_SCL_PIN=38 +CONFIG_BSP_I2C1_SDA_PIN=39 +# CONFIG_BSP_USING_I2C2 is not set # CONFIG_BSP_USING_SPI is not set # CONFIG_BSP_USING_RTC is not set CONFIG_LSI_VALUE=40000 # CONFIG_BSP_USING_IWDT is not set # CONFIG_BSP_USING_CAN is not set -# CONFIG_BSP_USING_TIM is not set - -# -# Onboard Peripheral Drivers -# +CONFIG_BSP_USING_TIM=y +CONFIG_BSP_USING_HWTIMER=y +# CONFIG_BSP_USING_PWM is not set +CONFIG_BSP_USING_TIM1=y +CONFIG_BSP_USING_TIM1_HWTIMER=y +# CONFIG_BSP_USING_TIM1_PWM is not set +# CONFIG_BSP_USING_TIM2 is not set +CONFIG_BSP_USING_TIM3=y +CONFIG_BSP_USING_TIM3_HWTIMER=y +# CONFIG_BSP_USING_TIM3_PWM is not set +CONFIG_BSP_USING_TIM4=y +CONFIG_BSP_USING_TIM4_HWTIMER=y +# CONFIG_BSP_USING_TIM4_PWM is not set +# CONFIG_BSP_USING_TIM5 is not set +# CONFIG_BSP_USING_TIM6 is not set +# CONFIG_BSP_USING_TIM7 is not set +# CONFIG_BSP_USING_TIM8 is not set +# CONFIG_BSP_USING_TIM9 is not set +# CONFIG_BSP_USING_TIM10 is not set # # Board extended module Drivers diff --git a/bsp/wch/risc-v/ch32v208w-r0/SConstruct b/bsp/wch/risc-v/ch32v208w-r0/SConstruct index 1c21f19f0afe6e6c94a9ee767cf67c3ad048257e..cc619ab0c2d070a07c333a28b432e8ebb70e8fac 100644 --- a/bsp/wch/risc-v/ch32v208w-r0/SConstruct +++ b/bsp/wch/risc-v/ch32v208w-r0/SConstruct @@ -24,6 +24,7 @@ env = Environment(tools = ['mingw'], AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS, CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS, AR = rtconfig.AR, ARFLAGS = '-rc', + CXX = rtconfig.CXX, LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS) env.PrependENVPath('PATH', rtconfig.EXEC_PATH) diff --git a/bsp/wch/risc-v/ch32v208w-r0/applications/SConscript b/bsp/wch/risc-v/ch32v208w-r0/applications/SConscript index 9bb9abae897a67a82e373e0aac77bf847dafe1a6..e1c7fa5996235029e77115334bc7f41d19c00f2f 100644 --- a/bsp/wch/risc-v/ch32v208w-r0/applications/SConscript +++ b/bsp/wch/risc-v/ch32v208w-r0/applications/SConscript @@ -1,9 +1,12 @@ from building import * import os -cwd = GetCurrentDir() -src = Glob('*.c') +cwd = GetCurrentDir() CPPPATH = [cwd] +src = Glob('*.c') + +if GetDepend(['PKG_USING_RTDUINO']) and not GetDepend(['RTDUINO_NO_SETUP_LOOP']): + src += ['arduino_main.cpp'] group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH) diff --git a/bsp/wch/risc-v/ch32v208w-r0/applications/arduino_main.cpp b/bsp/wch/risc-v/ch32v208w-r0/applications/arduino_main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b491796946178fd2c0047ef5d81d465068f275cc --- /dev/null +++ b/bsp/wch/risc-v/ch32v208w-r0/applications/arduino_main.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2006-2023, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2023-02-08 WangShun first version + */ + +#include + +void setup(void) + { + /* put your setup code here, to run once: */ + pinMode(8, OUTPUT); + Serial.begin(); + Serial.println("Hello Arduino!"); + } + +void loop(void) +{ + /* put your main code here, to run repeatedly: */ + digitalWrite(8, HIGH); + delay(500); + digitalWrite(8, LOW); + delay(500); +} diff --git a/bsp/wch/risc-v/ch32v208w-r0/applications/arduino_pinout/README.md b/bsp/wch/risc-v/ch32v208w-r0/applications/arduino_pinout/README.md new file mode 100644 index 0000000000000000000000000000000000000000..b843afe7f582f5790059c54d3b5eb01ccc3739f6 --- /dev/null +++ b/bsp/wch/risc-v/ch32v208w-r0/applications/arduino_pinout/README.md @@ -0,0 +1,63 @@ +# CH32V208W-R0 开发板的Arduino生态兼容说明 + +## 1 RTduino - RT-Thread的Arduino生态兼容层 + +CH32V208W-R0开发板已经完整适配了[RTduino软件包](https://github.com/RTduino/RTduino),即RT-Thread的Arduino生态兼容层。用户可以按照Arduino的编程习惯来操作该BSP,并且可以使用大量Arduino社区丰富的库,是对RT-Thread生态的极大增强。更多信息,请参见[RTduino软件包说明文档](https://github.com/RTduino/RTduino)。 + +### 1.1 如何开启针对本BSP的Arduino生态兼容层 + +Env 工具下敲入 menuconfig 命令,或者 RT-Thread Studio IDE 下选择 RT-Thread Settings: + +```Kconfig +Hardware Drivers Config ---> + Onboard Peripheral Drivers ---> + [*] Compatible with Arduino Ecosystem (RTduino) +``` + +## 2 Arduino引脚排布 + +更多引脚布局相关信息参见 [pins_arduino.c](pins_arduino.c) 和 [pins_arduino.h](pins_arduino.h)。 + +![ch32v208w-pinout](ch32v208w-pinout.png) +| Arduino引脚编号 | STM32引脚编号 | 5V容忍 | 备注 | +| ------------------- | --------- | ---- | ------------------------------------------------------------------------- | +| 0 (D0) | PA9 | 是 | Serial2-TX,默认被RT-Thread的UART设备框架uart1接管 | +| 1 (D1) | PB0 | 是 | Serial2-RX,默认被RT-Thread的UART设备框架uart1接管 | +| 2 (D2) | PB4 | 是 | | +| 3 (D3) | PB6 | 是 | PWM4-CH1,默认被RT-Thread的PWM设备框架pwm4接管 | +| 4 (D4) | PB7 | 是 | PWM4-CH2,默认被RT-Thread的PWM设备框架pwm4接管 | +| 5 (D5) | PB8 | 是 | PWM4-CH3,默认被RT-Thread的PWM设备框架pwm4接管 | +| 6 (D6) | PB9 | 是 | PWM4-CH4,默认被RT-Thread的PWM设备框架pwm4接管 | +| 7 (D7) | PA8 | 否 | PWM1-CH1,默认被RT-Thread的PWM设备框架pwm1接管 | +| 8 (D8) | PB1 | 否 | PWM3-CH4,默认被RT-Thread的PWM设备框架pwm3接管 | +| 9 (D9) | PB0 | 否 | PWM3-CH3,默认被RT-Thread的PWM设备框架pwm3接管 | +| 10 (D10) | PB12 | 是 | | +| 11 (D11) | PB15 | 是 | | +| 12 (D12) | PB14 | 是 | | +| 13 (D13) | PB13 | 是 | | +| 14 (D14) | PB11 | 是 | I2C1-SDA,默认被RT-Thread的I2C设备框架i2c1接管 | +| 15 (D15) | PB10 | 是 | I2C1-SCL,默认被RT-Thread的I2C设备框架i2c1接管 | +| 16 (A0) | PA0 | 否 | ADC1-CH0,默认被RT-Thread的ADC设备框架adc1接管 | +| 17 (A1) | PA1 | 否 | ADC1-CH1,默认被RT-Thread的ADC设备框架adc1接管 | +| 18 (A2) | PA2 | 否 | ADC1-CH2,默认被RT-Thread的ADC设备框架adc1接管 | +| 19 (A3) | PA3 | 否 | ADC1-CH3,默认被RT-Thread的ADC设备框架adc1接管 | +| 20 (A4) | PA4 | 否 | ADC1-CH4,默认被RT-Thread的ADC设备框架adc1接管 | +| 21 (A5) | PA5 | 否 | ADC1-CH5,默认被RT-Thread的ADC设备框架adc1接管 | + +> 注意: +> +> 1. 驱动舵机和analogWrite函数要选择不同定时器发生的PWM信号引脚,由于硬件定时器4个通道需要保持相同的频率,如果采用相同的定时器发生的PWM分别驱动舵机和analogWrite,可能会导致舵机失效 + +## 3 通信 + +### 3.1 I2C总线 + +CH32V208W-R0 开发板的I2C总线是板上丝印的 `SCL/D15` 和 `SDA/D14` 引脚,这两个引脚默认是被RT-Thread I2C设备框架接管的,直接引用`#include `(Arduino官方I2C头文件)即可使用。 + +### 3.2 SPI总线 + +目前本BSP不支持使用Arduino的SPI功能。 + +### 3.3 串口 + +本BSP通过 `Serial.` 方法调用 `uart1` 串口设备。详见[例程](https://github.com/RTduino/RTduino/blob/master/examples/Basic/helloworld.cpp)。 \ No newline at end of file diff --git a/bsp/wch/risc-v/ch32v208w-r0/applications/arduino_pinout/Sconscript b/bsp/wch/risc-v/ch32v208w-r0/applications/arduino_pinout/Sconscript new file mode 100644 index 0000000000000000000000000000000000000000..25399290275c4dd5e207b73316583b1ff227c5cc --- /dev/null +++ b/bsp/wch/risc-v/ch32v208w-r0/applications/arduino_pinout/Sconscript @@ -0,0 +1,9 @@ +from building import * + +cwd = GetCurrentDir() +src = Glob('*.c') + Glob('*.cpp') +inc = [cwd] + +group = DefineGroup('RTduino', src, depend = ['PKG_USING_RTDUINO'], CPPPATH = inc) + +Return('group') diff --git a/bsp/wch/risc-v/ch32v208w-r0/applications/arduino_pinout/ch32v208w-pinout.png b/bsp/wch/risc-v/ch32v208w-r0/applications/arduino_pinout/ch32v208w-pinout.png new file mode 100644 index 0000000000000000000000000000000000000000..fc0a5f46d8a7e5df342fe2bf0a88f7eeca319d57 Binary files /dev/null and b/bsp/wch/risc-v/ch32v208w-r0/applications/arduino_pinout/ch32v208w-pinout.png differ diff --git a/bsp/wch/risc-v/ch32v208w-r0/applications/arduino_pinout/pins_arduino.c b/bsp/wch/risc-v/ch32v208w-r0/applications/arduino_pinout/pins_arduino.c new file mode 100644 index 0000000000000000000000000000000000000000..6a7d0c248654cace04295fb761c88da0d67a6580 --- /dev/null +++ b/bsp/wch/risc-v/ch32v208w-r0/applications/arduino_pinout/pins_arduino.c @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2006-2023, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2023-02-08 WangShun first version + */ + +#include +#include +#include "pins_arduino.h" + +/* + * {Arduino Pin, RT-Thread Pin [, Device Name, Channel]} + * [] means optional + * Digital pins must NOT give the device name and channel. + * Analog pins MUST give the device name and channel(ADC, PWM or DAC). + * Arduino Pin must keep in sequence. + */ +const pin_map_t pin_map_table[]= +{ + {D0, GET_PIN(A,9), "uart1"}, /* Serial1-TX */ + {D1, GET_PIN(A,10), "uart1"}, /* Serial1-RX */ + {D2, GET_PIN(B,4)}, + {D3, GET_PIN(B,6), "pwm4", 1}, /* PWM */ + {D4, GET_PIN(B,7), "pwm4", 2}, /* PWM */ + {D5, GET_PIN(B,8), "pwm4", 3}, /* PWM */ + {D6, GET_PIN(B,9), "pwm4", 4}, /* PWM */ + {D7, GET_PIN(A,8), "pwm1", 1}, /* PWM */ + {D8, GET_PIN(B,1), "pwm3", 4}, /* PWM */ + {D9, GET_PIN(B,0), "pwm3", 3}, /* PWM */ + {D10, GET_PIN(B,12)}, + {D11, GET_PIN(B,15)}, + {D12, GET_PIN(B,14)}, + {D13, GET_PIN(B,13)}, + {D14, GET_PIN(B,11), "i2c1"}, /* I2C-SDA (Wire) */ + {D15, GET_PIN(B,10), "i2c1"}, /* I2C-SCL (Wire) */ + {A0, GET_PIN(A,0), "adc1", 0}, /* ADC */ + {A1, GET_PIN(A,1), "adc1", 1}, /* ADC */ + {A2, GET_PIN(A,2), "adc1", 2}, /* ADC */ + {A3, GET_PIN(A,3), "adc1", 3}, /* ADC */ + {A4, GET_PIN(A,4), "adc1", 4}, /* ADC */ + {A5, GET_PIN(A,5), "adc1", 5}, /* ADC */ +}; diff --git a/bsp/wch/risc-v/ch32v208w-r0/applications/arduino_pinout/pins_arduino.h b/bsp/wch/risc-v/ch32v208w-r0/applications/arduino_pinout/pins_arduino.h new file mode 100644 index 0000000000000000000000000000000000000000..eb26bbb40cd98dd61f75b5371ec1bd37513a18e0 --- /dev/null +++ b/bsp/wch/risc-v/ch32v208w-r0/applications/arduino_pinout/pins_arduino.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2006-2023, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2023-02-08 WangShun first version + */ + +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +/* pins alias. Must keep in sequence */ +#define D0 (0) +#define D1 (1) +#define D2 (2) +#define D3 (3) +#define D4 (4) +#define D5 (5) +#define D6 (6) +#define D7 (7) +#define D8 (8) +#define D9 (9) +#define D10 (10) +#define D11 (11) +#define D12 (12) +#define D13 (13) +#define D14 (14) +#define D15 (15) +#define A0 (16) +#define A1 (17) +#define A2 (18) +#define A3 (19) +#define A4 (20) +#define A5 (21) + +#define F_CPU 144000000L /* CPU:144MHz */ + +/* Serial1 : PA9-TX PB0-RX */ +#define RTDUINO_SERIAL2_DEVICE_NAME "uart1" + +#endif /* Pins_Arduino_h */ diff --git a/bsp/wch/risc-v/ch32v208w-r0/applications/main.c b/bsp/wch/risc-v/ch32v208w-r0/applications/main.c index 3246340a93de6c85344b60b9fa04572b3038d476..0b6bd980f64578339dc5dc91da1c63ab34b72462 100644 --- a/bsp/wch/risc-v/ch32v208w-r0/applications/main.c +++ b/bsp/wch/risc-v/ch32v208w-r0/applications/main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/ch32v208w-r0/board/Kconfig b/bsp/wch/risc-v/ch32v208w-r0/board/Kconfig index 59a18a174cf91ccbd3514d98b4358b693201189c..fd74edd2e985dff2d152d10bd9c4037f65ec648f 100644 --- a/bsp/wch/risc-v/ch32v208w-r0/board/Kconfig +++ b/bsp/wch/risc-v/ch32v208w-r0/board/Kconfig @@ -9,6 +9,33 @@ config SOC_CH32V208WBU6 menu "Onboard Peripheral Drivers" + config BSP_USING_ARDUINO + bool "Compatible with Arduino Ecosystem (RTduino)" + select PKG_USING_RTDUINO + select BSP_USING_GPIO + select BSP_USING_ADC + select BSP_USING_ADC1 + select BSP_USING_TIM + select BSP_USING_PWM + select BSP_USING_TIM1 + select BSP_USING_TIM1_PWM + select BSP_USING_TIM1_PWM_CH1 + select BSP_USING_TIM3 + select BSP_USING_TIM3_PWM + select BSP_USING_TIM3_PWM_CH3 + select BSP_USING_TIM3_PWM_CH4 + select BSP_USING_TIM4 + select BSP_USING_TIM4_PWM + select BSP_USING_TIM4_PWM_CH1 + select BSP_USING_TIM4_PWM_CH2 + select BSP_USING_TIM4_PWM_CH3 + select BSP_USING_TIM4_PWM_CH4 + select BSP_USING_SOFT_I2C + select BSP_USING_I2C1 + imply RTDUINO_USING_SERVO + imply RTDUINO_USING_WIRE + default n + endmenu menu "On-chip Peripheral Drivers" diff --git a/bsp/wch/risc-v/ch32v208w-r0/board/board.c b/bsp/wch/risc-v/ch32v208w-r0/board/board.c index 197c3c66ad7a054c846a3af360c6abb4fe3ec5f7..03f33e6c4bfbfb01597db097f468efae4a7b0634 100644 --- a/bsp/wch/risc-v/ch32v208w-r0/board/board.c +++ b/bsp/wch/risc-v/ch32v208w-r0/board/board.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/bsp/wch/risc-v/ch32v208w-r0/board/board.h b/bsp/wch/risc-v/ch32v208w-r0/board/board.h index 9086e24c4e8f3877fe5d11f2da0d69cf340c7e57..7449e15d62357a993bd65cc9352734f521b34e12 100644 --- a/bsp/wch/risc-v/ch32v208w-r0/board/board.h +++ b/bsp/wch/risc-v/ch32v208w-r0/board/board.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2022, RT-Thread Development Team + * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -12,7 +12,10 @@ #ifndef __BOARD_H__ #define __BOARD_H__ +#include #include "ch32v20x.h" +#include "drv_gpio.h" +#include "drv_pwm.h" #define ch32v20x_PIN_NUMBERS 64 /* board configuration */ diff --git a/bsp/wch/risc-v/ch32v208w-r0/board/linker_scripts/link.lds b/bsp/wch/risc-v/ch32v208w-r0/board/linker_scripts/link.lds index cc60a8caaede0965970c54a1c73e00f50d9f0cd6..6c966a5aaee88507a075f5c53ab86ee185f1e699 100644 --- a/bsp/wch/risc-v/ch32v208w-r0/board/linker_scripts/link.lds +++ b/bsp/wch/risc-v/ch32v208w-r0/board/linker_scripts/link.lds @@ -66,6 +66,14 @@ SECTIONS __rtmsymtab_end = .; . = ALIGN(4); + PROVIDE(__ctors_start__ = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array)) + PROVIDE(__ctors_end__ = .); + . = ALIGN(4); + + _etext = .; + } >FLASH AT>FLASH .fini : diff --git a/bsp/wch/risc-v/ch32v208w-r0/rtconfig.h b/bsp/wch/risc-v/ch32v208w-r0/rtconfig.h index bc7ed5be5c79eb8beb21f185b2c25f0489cbc05f..e0f52dc1bc2d468b623b4cd61b0d9c24a38d283d 100644 --- a/bsp/wch/risc-v/ch32v208w-r0/rtconfig.h +++ b/bsp/wch/risc-v/ch32v208w-r0/rtconfig.h @@ -33,6 +33,7 @@ /* Memory Management */ +#define RT_PAGE_MAX_ORDER 11 #define RT_USING_SMALL_MEM #define RT_USING_SMALL_MEM_AS_HEAP #define RT_USING_HEAP @@ -73,7 +74,12 @@ #define RT_USING_SERIAL #define RT_USING_SERIAL_V1 #define RT_SERIAL_RB_BUFSZ 64 +#define RT_USING_HWTIMER +#define RT_USING_I2C +#define RT_USING_I2C_BITOPS #define RT_USING_PIN +#define RT_USING_ADC +#define RT_USING_PWM /* Using USB */ @@ -90,6 +96,7 @@ /* Socket is in the 'Network' category */ +#define RT_USING_CPLUSPLUS /* Network */ @@ -184,6 +191,10 @@ /* Arduino libraries */ +#define PKG_USING_RTDUINO +#define RTDUINO_THREAD_SIZE 1536 +#define RTDUINO_THREAD_PRIO 30 +#define PKG_USING_RTDUINO_LATEST_VERSION /* Projects */ @@ -222,14 +233,32 @@ #define SOC_CH32V208WBU6 +/* Onboard Peripheral Drivers */ + + /* On-chip Peripheral Drivers */ #define BSP_USING_GPIO #define BSP_USING_UART #define BSP_USING_UART1 -#define LSI_VALUE 40000 +#define BSP_USING_ADC +#define BSP_USING_ADC1 +#define BSP_USING_SOFT_I2C +#define BSP_USING_I2C1 -/* Onboard Peripheral Drivers */ +/* Notice: PC7 --> 39; PC6 --> 38 */ + +#define BSP_I2C1_SCL_PIN 38 +#define BSP_I2C1_SDA_PIN 39 +#define LSI_VALUE 40000 +#define BSP_USING_TIM +#define BSP_USING_HWTIMER +#define BSP_USING_TIM1 +#define BSP_USING_TIM1_HWTIMER +#define BSP_USING_TIM3 +#define BSP_USING_TIM3_HWTIMER +#define BSP_USING_TIM4 +#define BSP_USING_TIM4_HWTIMER /* Board extended module Drivers */ diff --git a/bsp/wch/risc-v/ch32v208w-r0/rtconfig.py b/bsp/wch/risc-v/ch32v208w-r0/rtconfig.py index a859931140122a7d96c12230420fff7d815044ca..fee6d63ed17b00f279f1280b20ec11eccfb71740 100644 --- a/bsp/wch/risc-v/ch32v208w-r0/rtconfig.py +++ b/bsp/wch/risc-v/ch32v208w-r0/rtconfig.py @@ -18,8 +18,6 @@ else: if os.getenv('RTT_EXEC_PATH'): EXEC_PATH = os.getenv('RTT_EXEC_PATH') -print(EXEC_PATH) - BUILD = 'debug' #BUILD = 'release'