[RTduino][ch32v208w-r0]ch32v208w-r0适配RTduino (#6917)

This commit is contained in:
Yaochenger
2023-02-09 12:01:20 +08:00
committed by GitHub
parent 20459ec4d3
commit 7c6c12cbff
63 changed files with 403 additions and 72 deletions

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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>

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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

View File

@@ -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
*/

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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
*

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

Some files were not shown because too many files have changed in this diff Show More