[RTduino][ch32v208w-r0]ch32v208w-r0适配RTduino (#6917)
This commit is contained in:
parent
20459ec4d3
commit
7c6c12cbff
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 <rtthread.h>
|
||||
|
||||
#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
|
||||
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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 <rtthread.h>
|
||||
#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 <drivers/rt_drv_pwm.h>
|
||||
#include <drivers/hwtimer.h>
|
||||
#include <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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -1432,7 +1432,7 @@ ITStatus ETH_GetDMAITStatus(uint32_t ETH_DMA_IT)
|
|||
/*********************************************************************
|
||||
* @fn ETH_DMAClearITPendingBit
|
||||
*
|
||||
* @brief Clears the ETHERNET’s 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
|
||||
|
|
|
@ -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
|
||||
* NewState:ENABLE or DISABLE.
|
||||
* NewState£:ENABLE or DISABLE.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
|
|
|
@ -117,7 +117,7 @@ void RNG_ClearFlag(uint8_t RNG_FLAG)
|
|||
* RNG_IT_CEI - Clock Error Interrupt.
|
||||
* RNG_IT_SEI - Seed Error Interrupt.
|
||||
*
|
||||
* @return bitstatus:SET or RESET.
|
||||
* @return bitstatus£:SET or RESET.
|
||||
*/
|
||||
ITStatus RNG_GetITStatus(uint8_t RNG_IT)
|
||||
{
|
||||
|
|
|
@ -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 ITStatus:SET or RESET
|
||||
* @return ITStatus£:SET or RESET
|
||||
*/
|
||||
ITStatus SDIO_GetITStatus(uint32_t SDIO_IT)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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 <Arduino.h>
|
||||
|
||||
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);
|
||||
}
|
|
@ -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 <Wire.h>`(Arduino官方I2C头文件)即可使用。
|
||||
|
||||
### 3.2 SPI总线
|
||||
|
||||
目前本BSP不支持使用Arduino的SPI功能。
|
||||
|
||||
### 3.3 串口
|
||||
|
||||
本BSP通过 `Serial.` 方法调用 `uart1` 串口设备。详见[例程](https://github.com/RTduino/RTduino/blob/master/examples/Basic/helloworld.cpp)。
|
|
@ -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')
|
Binary file not shown.
After Width: | Height: | Size: 786 KiB |
|
@ -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 <Arduino.h>
|
||||
#include <board.h>
|
||||
#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 */
|
||||
};
|
|
@ -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 */
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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 <rtthread.h>
|
||||
#include "ch32v20x.h"
|
||||
#include "drv_gpio.h"
|
||||
#include "drv_pwm.h"
|
||||
|
||||
#define ch32v20x_PIN_NUMBERS 64
|
||||
/* board configuration */
|
||||
|
|
|
@ -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 :
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
Loading…
Reference in New Issue