mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-27 23:38:32 +08:00
[bsp][ch32] add eth driver
This commit is contained in:
@@ -36,6 +36,9 @@ if GetDepend('SOC_RISCV_FAMILY_CH32'):
|
|||||||
if GetDepend('BSP_USING_USBD'):
|
if GetDepend('BSP_USING_USBD'):
|
||||||
src += ['drv_usbd.c']
|
src += ['drv_usbd.c']
|
||||||
|
|
||||||
|
if GetDepend('BSP_USING_ETH'):
|
||||||
|
src += ['drv_eth.c']
|
||||||
|
|
||||||
if GetDepend('BSP_USING_IWDT'):
|
if GetDepend('BSP_USING_IWDT'):
|
||||||
src += ['drv_iwdt.c']
|
src += ['drv_iwdt.c']
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* File : usart.h
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2009, 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
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2021-09-09 WCH the first version
|
||||||
|
*/
|
||||||
|
#ifndef __DRV_ETH_H__
|
||||||
|
#define __DRV_ETH_H__
|
||||||
|
#include "rthw.h"
|
||||||
|
#include "rtthread.h"
|
||||||
|
#include "ch32v30x_eth.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* MII/MDI interface select */
|
||||||
|
#define PHY_ADDRESS 0x01
|
||||||
|
#define USE10BASE_T
|
||||||
|
|
||||||
|
#ifndef USE10BASE_T
|
||||||
|
#define USE_GIGA_MAC
|
||||||
|
#ifndef USE_GIGA_MAC
|
||||||
|
#define USE_FAST_MAC
|
||||||
|
//#define USE_RMII
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ETH_RXBUFNB 6
|
||||||
|
#define ETH_TXBUFNB 6
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
#define USE_LOOP_STRUCT 1
|
||||||
|
#else
|
||||||
|
#define USE_CHAIN_STRUCT 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
u32 length;
|
||||||
|
u32 buffer;
|
||||||
|
ETH_DMADESCTypeDef *descriptor;
|
||||||
|
}FrameTypeDef;
|
||||||
|
|
||||||
|
#endif
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -121,6 +121,13 @@ menu "On-chip Peripheral Drivers"
|
|||||||
default n
|
default n
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
menuconfig BSP_USING_ETH
|
||||||
|
bool "Enable Ethernet"
|
||||||
|
default n
|
||||||
|
select RT_USING_LWIP
|
||||||
|
select RT_USING_NETDEV
|
||||||
|
select RT_USING_SAL
|
||||||
|
|
||||||
config BSP_USING_USBH
|
config BSP_USING_USBH
|
||||||
bool "Enable USB Host"
|
bool "Enable USB Host"
|
||||||
select RT_USING_USB_HOST
|
select RT_USING_USB_HOST
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
#ifndef RT_CONFIG_H__
|
#ifndef RT_CONFIG_H__
|
||||||
#define RT_CONFIG_H__
|
#define RT_CONFIG_H__
|
||||||
|
|
||||||
/* Automatically generated file; DO NOT EDIT. */
|
|
||||||
/* RT-Thread Configuration */
|
|
||||||
|
|
||||||
/* RT-Thread Kernel */
|
/* RT-Thread Kernel */
|
||||||
|
|
||||||
#define RT_NAME_MAX 8
|
#define RT_NAME_MAX 8
|
||||||
@@ -23,7 +20,13 @@
|
|||||||
|
|
||||||
/* kservice optimization */
|
/* kservice optimization */
|
||||||
|
|
||||||
|
/* end of kservice optimization */
|
||||||
|
|
||||||
|
/* klibc optimization */
|
||||||
|
|
||||||
|
/* end of klibc optimization */
|
||||||
#define RT_USING_DEBUG
|
#define RT_USING_DEBUG
|
||||||
|
#define RT_DEBUGING_ASSERT
|
||||||
#define RT_DEBUGING_COLOR
|
#define RT_DEBUGING_COLOR
|
||||||
#define RT_DEBUGING_CONTEXT
|
#define RT_DEBUGING_CONTEXT
|
||||||
|
|
||||||
@@ -34,18 +37,21 @@
|
|||||||
#define RT_USING_EVENT
|
#define RT_USING_EVENT
|
||||||
#define RT_USING_MAILBOX
|
#define RT_USING_MAILBOX
|
||||||
#define RT_USING_MESSAGEQUEUE
|
#define RT_USING_MESSAGEQUEUE
|
||||||
|
/* end of Inter-Thread communication */
|
||||||
|
|
||||||
/* Memory Management */
|
/* Memory Management */
|
||||||
|
|
||||||
#define RT_USING_SMALL_MEM
|
#define RT_USING_SMALL_MEM
|
||||||
#define RT_USING_SMALL_MEM_AS_HEAP
|
#define RT_USING_SMALL_MEM_AS_HEAP
|
||||||
#define RT_USING_HEAP
|
#define RT_USING_HEAP
|
||||||
|
/* end of Memory Management */
|
||||||
#define RT_USING_DEVICE
|
#define RT_USING_DEVICE
|
||||||
#define RT_USING_CONSOLE
|
#define RT_USING_CONSOLE
|
||||||
#define RT_CONSOLEBUF_SIZE 128
|
#define RT_CONSOLEBUF_SIZE 128
|
||||||
#define RT_CONSOLE_DEVICE_NAME "uart1"
|
#define RT_CONSOLE_DEVICE_NAME "uart1"
|
||||||
#define RT_VER_NUM 0x50100
|
#define RT_VER_NUM 0x50200
|
||||||
#define RT_BACKTRACE_LEVEL_MAX_NR 32
|
#define RT_BACKTRACE_LEVEL_MAX_NR 32
|
||||||
|
/* end of RT-Thread Kernel */
|
||||||
#define RT_USING_HW_ATOMIC
|
#define RT_USING_HW_ATOMIC
|
||||||
#define ARCH_RISCV
|
#define ARCH_RISCV
|
||||||
|
|
||||||
@@ -59,8 +65,8 @@
|
|||||||
#define RT_USING_FINSH
|
#define RT_USING_FINSH
|
||||||
#define FINSH_USING_MSH
|
#define FINSH_USING_MSH
|
||||||
#define FINSH_THREAD_NAME "tshell"
|
#define FINSH_THREAD_NAME "tshell"
|
||||||
#define FINSH_THREAD_PRIORITY 20
|
#define FINSH_THREAD_PRIORITY 11
|
||||||
#define FINSH_THREAD_STACK_SIZE 1024
|
#define FINSH_THREAD_STACK_SIZE 2048
|
||||||
#define FINSH_USING_HISTORY
|
#define FINSH_USING_HISTORY
|
||||||
#define FINSH_HISTORY_LINES 5
|
#define FINSH_HISTORY_LINES 5
|
||||||
#define FINSH_USING_SYMTAB
|
#define FINSH_USING_SYMTAB
|
||||||
@@ -72,6 +78,7 @@
|
|||||||
|
|
||||||
/* DFS: device virtual file system */
|
/* DFS: device virtual file system */
|
||||||
|
|
||||||
|
/* end of DFS: device virtual file system */
|
||||||
|
|
||||||
/* Device Drivers */
|
/* Device Drivers */
|
||||||
|
|
||||||
@@ -81,9 +88,7 @@
|
|||||||
#define RT_USING_SERIAL_V1
|
#define RT_USING_SERIAL_V1
|
||||||
#define RT_SERIAL_RB_BUFSZ 64
|
#define RT_SERIAL_RB_BUFSZ 64
|
||||||
#define RT_USING_PIN
|
#define RT_USING_PIN
|
||||||
|
/* end of Device Drivers */
|
||||||
/* Using USB */
|
|
||||||
|
|
||||||
|
|
||||||
/* C/C++ and POSIX layer */
|
/* C/C++ and POSIX layer */
|
||||||
|
|
||||||
@@ -95,6 +100,8 @@
|
|||||||
#define RT_LIBC_TZ_DEFAULT_HOUR 8
|
#define RT_LIBC_TZ_DEFAULT_HOUR 8
|
||||||
#define RT_LIBC_TZ_DEFAULT_MIN 0
|
#define RT_LIBC_TZ_DEFAULT_MIN 0
|
||||||
#define RT_LIBC_TZ_DEFAULT_SEC 0
|
#define RT_LIBC_TZ_DEFAULT_SEC 0
|
||||||
|
/* end of Timezone and Daylight Saving Time */
|
||||||
|
/* end of ISO-ANSI C layer */
|
||||||
|
|
||||||
/* POSIX (Portable Operating System Interface) layer */
|
/* POSIX (Portable Operating System Interface) layer */
|
||||||
|
|
||||||
@@ -104,18 +111,30 @@
|
|||||||
|
|
||||||
/* Socket is in the 'Network' category */
|
/* Socket is in the 'Network' category */
|
||||||
|
|
||||||
|
/* end of Interprocess Communication (IPC) */
|
||||||
|
/* end of POSIX (Portable Operating System Interface) layer */
|
||||||
|
/* end of C/C++ and POSIX layer */
|
||||||
|
|
||||||
/* Network */
|
/* Network */
|
||||||
|
|
||||||
|
/* end of Network */
|
||||||
|
|
||||||
/* Memory protection */
|
/* Memory protection */
|
||||||
|
|
||||||
|
/* end of Memory protection */
|
||||||
|
|
||||||
/* Utilities */
|
/* Utilities */
|
||||||
|
|
||||||
|
/* end of Utilities */
|
||||||
|
|
||||||
|
/* Using USB legacy version */
|
||||||
|
|
||||||
|
/* end of Using USB legacy version */
|
||||||
|
/* end of RT-Thread Components */
|
||||||
|
|
||||||
/* RT-Thread Utestcases */
|
/* RT-Thread Utestcases */
|
||||||
|
|
||||||
|
/* end of RT-Thread Utestcases */
|
||||||
|
|
||||||
/* RT-Thread online packages */
|
/* RT-Thread online packages */
|
||||||
|
|
||||||
@@ -126,57 +145,78 @@
|
|||||||
|
|
||||||
/* Marvell WiFi */
|
/* Marvell WiFi */
|
||||||
|
|
||||||
|
/* end of Marvell WiFi */
|
||||||
|
|
||||||
/* Wiced WiFi */
|
/* Wiced WiFi */
|
||||||
|
|
||||||
|
/* end of Wiced WiFi */
|
||||||
|
|
||||||
/* CYW43012 WiFi */
|
/* CYW43012 WiFi */
|
||||||
|
|
||||||
|
/* end of CYW43012 WiFi */
|
||||||
|
|
||||||
/* BL808 WiFi */
|
/* BL808 WiFi */
|
||||||
|
|
||||||
|
/* end of BL808 WiFi */
|
||||||
|
|
||||||
/* CYW43439 WiFi */
|
/* CYW43439 WiFi */
|
||||||
|
|
||||||
|
/* end of CYW43439 WiFi */
|
||||||
|
/* end of Wi-Fi */
|
||||||
|
|
||||||
/* IoT Cloud */
|
/* IoT Cloud */
|
||||||
|
|
||||||
|
/* end of IoT Cloud */
|
||||||
|
/* end of IoT - internet of things */
|
||||||
|
|
||||||
/* security packages */
|
/* security packages */
|
||||||
|
|
||||||
|
/* end of security packages */
|
||||||
|
|
||||||
/* language packages */
|
/* language packages */
|
||||||
|
|
||||||
/* JSON: JavaScript Object Notation, a lightweight data-interchange format */
|
/* JSON: JavaScript Object Notation, a lightweight data-interchange format */
|
||||||
|
|
||||||
|
/* end of JSON: JavaScript Object Notation, a lightweight data-interchange format */
|
||||||
|
|
||||||
/* XML: Extensible Markup Language */
|
/* XML: Extensible Markup Language */
|
||||||
|
|
||||||
|
/* end of XML: Extensible Markup Language */
|
||||||
|
/* end of language packages */
|
||||||
|
|
||||||
/* multimedia packages */
|
/* multimedia packages */
|
||||||
|
|
||||||
/* LVGL: powerful and easy-to-use embedded GUI library */
|
/* LVGL: powerful and easy-to-use embedded GUI library */
|
||||||
|
|
||||||
|
/* end of LVGL: powerful and easy-to-use embedded GUI library */
|
||||||
|
|
||||||
/* u8g2: a monochrome graphic library */
|
/* u8g2: a monochrome graphic library */
|
||||||
|
|
||||||
|
/* end of u8g2: a monochrome graphic library */
|
||||||
|
/* end of multimedia packages */
|
||||||
|
|
||||||
/* tools packages */
|
/* tools packages */
|
||||||
|
|
||||||
|
/* end of tools packages */
|
||||||
|
|
||||||
/* system packages */
|
/* system packages */
|
||||||
|
|
||||||
/* enhanced kernel services */
|
/* enhanced kernel services */
|
||||||
|
|
||||||
|
/* end of enhanced kernel services */
|
||||||
|
|
||||||
/* acceleration: Assembly language or algorithmic acceleration packages */
|
/* acceleration: Assembly language or algorithmic acceleration packages */
|
||||||
|
|
||||||
|
/* end of acceleration: Assembly language or algorithmic acceleration packages */
|
||||||
|
|
||||||
/* CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */
|
/* CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */
|
||||||
|
|
||||||
|
/* end of CMSIS: ARM Cortex-M Microcontroller Software Interface Standard */
|
||||||
|
|
||||||
/* Micrium: Micrium software products porting for RT-Thread */
|
/* Micrium: Micrium software products porting for RT-Thread */
|
||||||
|
|
||||||
|
/* end of Micrium: Micrium software products porting for RT-Thread */
|
||||||
|
/* end of system packages */
|
||||||
|
|
||||||
/* peripheral libraries and drivers */
|
/* peripheral libraries and drivers */
|
||||||
|
|
||||||
@@ -184,66 +224,94 @@
|
|||||||
|
|
||||||
/* STM32 HAL & SDK Drivers */
|
/* STM32 HAL & SDK Drivers */
|
||||||
|
|
||||||
|
/* end of STM32 HAL & SDK Drivers */
|
||||||
|
|
||||||
|
/* Infineon HAL Packages */
|
||||||
|
|
||||||
|
/* end of Infineon HAL Packages */
|
||||||
|
|
||||||
/* Kendryte SDK */
|
/* Kendryte SDK */
|
||||||
|
|
||||||
|
/* end of Kendryte SDK */
|
||||||
|
/* end of HAL & SDK Drivers */
|
||||||
|
|
||||||
/* sensors drivers */
|
/* sensors drivers */
|
||||||
|
|
||||||
|
/* end of sensors drivers */
|
||||||
|
|
||||||
/* touch drivers */
|
/* touch drivers */
|
||||||
|
|
||||||
|
/* end of touch drivers */
|
||||||
|
/* end of peripheral libraries and drivers */
|
||||||
|
|
||||||
/* AI packages */
|
/* AI packages */
|
||||||
|
|
||||||
|
/* end of AI packages */
|
||||||
|
|
||||||
/* Signal Processing and Control Algorithm Packages */
|
/* Signal Processing and Control Algorithm Packages */
|
||||||
|
|
||||||
|
/* end of Signal Processing and Control Algorithm Packages */
|
||||||
|
|
||||||
/* miscellaneous packages */
|
/* miscellaneous packages */
|
||||||
|
|
||||||
/* project laboratory */
|
/* project laboratory */
|
||||||
|
|
||||||
|
/* end of project laboratory */
|
||||||
|
|
||||||
/* samples: kernel and components samples */
|
/* samples: kernel and components samples */
|
||||||
|
|
||||||
|
/* end of samples: kernel and components samples */
|
||||||
|
|
||||||
/* entertainment: terminal games and other interesting software packages */
|
/* entertainment: terminal games and other interesting software packages */
|
||||||
|
|
||||||
|
/* end of entertainment: terminal games and other interesting software packages */
|
||||||
|
/* end of miscellaneous packages */
|
||||||
|
|
||||||
/* Arduino libraries */
|
/* Arduino libraries */
|
||||||
|
|
||||||
|
|
||||||
/* Projects and Demos */
|
/* Projects and Demos */
|
||||||
|
|
||||||
|
/* end of Projects and Demos */
|
||||||
|
|
||||||
/* Sensors */
|
/* Sensors */
|
||||||
|
|
||||||
|
/* end of Sensors */
|
||||||
|
|
||||||
/* Display */
|
/* Display */
|
||||||
|
|
||||||
|
/* end of Display */
|
||||||
|
|
||||||
/* Timing */
|
/* Timing */
|
||||||
|
|
||||||
|
/* end of Timing */
|
||||||
|
|
||||||
/* Data Processing */
|
/* Data Processing */
|
||||||
|
|
||||||
|
/* end of Data Processing */
|
||||||
|
|
||||||
/* Data Storage */
|
/* Data Storage */
|
||||||
|
|
||||||
/* Communication */
|
/* Communication */
|
||||||
|
|
||||||
|
/* end of Communication */
|
||||||
|
|
||||||
/* Device Control */
|
/* Device Control */
|
||||||
|
|
||||||
|
/* end of Device Control */
|
||||||
|
|
||||||
/* Other */
|
/* Other */
|
||||||
|
|
||||||
|
/* end of Other */
|
||||||
|
|
||||||
/* Signal IO */
|
/* Signal IO */
|
||||||
|
|
||||||
|
/* end of Signal IO */
|
||||||
|
|
||||||
/* Uncategorized */
|
/* Uncategorized */
|
||||||
|
|
||||||
|
/* end of Arduino libraries */
|
||||||
|
/* end of RT-Thread online packages */
|
||||||
#define SOC_RISCV_FAMILY_CH32
|
#define SOC_RISCV_FAMILY_CH32
|
||||||
#define SOC_RISCV_SERIES_CH32V3
|
#define SOC_RISCV_SERIES_CH32V3
|
||||||
|
|
||||||
@@ -253,6 +321,7 @@
|
|||||||
|
|
||||||
/* Onboard Peripheral Drivers */
|
/* Onboard Peripheral Drivers */
|
||||||
|
|
||||||
|
/* end of Onboard Peripheral Drivers */
|
||||||
|
|
||||||
/* On-chip Peripheral Drivers */
|
/* On-chip Peripheral Drivers */
|
||||||
|
|
||||||
@@ -260,8 +329,10 @@
|
|||||||
#define BSP_USING_UART
|
#define BSP_USING_UART
|
||||||
#define BSP_USING_UART1
|
#define BSP_USING_UART1
|
||||||
#define LSI_VALUE 40000
|
#define LSI_VALUE 40000
|
||||||
|
/* end of On-chip Peripheral Drivers */
|
||||||
|
|
||||||
/* Board extended module Drivers */
|
/* Board extended module Drivers */
|
||||||
|
|
||||||
|
/* end of Hardware Drivers Config */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ if PLATFORM == 'gcc':
|
|||||||
LPATH = ''
|
LPATH = ''
|
||||||
|
|
||||||
if BUILD == 'debug':
|
if BUILD == 'debug':
|
||||||
CFLAGS += ' -O0 -g3'
|
CFLAGS += ' -Os -g3'
|
||||||
AFLAGS += ' -g3'
|
AFLAGS += ' -g3'
|
||||||
else:
|
else:
|
||||||
CFLAGS += ' -O2'
|
CFLAGS += ' -O2'
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ rt_hw_interrupt_enable:
|
|||||||
.globl rt_hw_context_switch_to
|
.globl rt_hw_context_switch_to
|
||||||
rt_hw_context_switch_to:
|
rt_hw_context_switch_to:
|
||||||
la t0, __rt_rvstack
|
la t0, __rt_rvstack
|
||||||
|
#ifdef SOC_RISCV_FAMILY_CH32
|
||||||
|
addi t0, t0, -512 // for ch32
|
||||||
|
#endif /* SOC_RISCV_FAMILY_CH32 */
|
||||||
csrw mscratch,t0
|
csrw mscratch,t0
|
||||||
|
|
||||||
LOAD sp, (a0)
|
LOAD sp, (a0)
|
||||||
|
|||||||
Reference in New Issue
Block a user