fix osc
This commit is contained in:
@@ -29,8 +29,8 @@ void SystemClock_Config (void)
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
RCC_OscInitStruct.PLL.PLLM = 4;
|
||||
RCC_OscInitStruct.PLL.PLLN = 168;
|
||||
RCC_OscInitStruct.PLL.PLLM = 8;
|
||||
RCC_OscInitStruct.PLL.PLLN = 192;
|
||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
|
||||
RCC_OscInitStruct.PLL.PLLQ = 4;
|
||||
HAL_RCC_OscConfig(&RCC_OscInitStruct);
|
||||
@@ -42,7 +42,7 @@ void SystemClock_Config (void)
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
|
||||
|
||||
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);
|
||||
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3);
|
||||
}
|
||||
|
||||
#elif defined(STM32F411xE)||defined(STM32F401xC)
|
||||
|
||||
+74
-5
@@ -182,7 +182,7 @@ CONFIG_RT_USING_DEVICE=y
|
||||
CONFIG_RT_USING_CONSOLE=y
|
||||
CONFIG_RT_CONSOLEBUF_SIZE=128
|
||||
CONFIG_RT_CONSOLE_DEVICE_NAME="uart2"
|
||||
CONFIG_RT_VER_NUM=0x50201
|
||||
CONFIG_RT_VER_NUM=0x50202
|
||||
# CONFIG_RT_USING_STDC_ATOMIC is not set
|
||||
CONFIG_RT_BACKTRACE_LEVEL_MAX_NR=32
|
||||
# end of RT-Thread Kernel
|
||||
@@ -286,7 +286,60 @@ CONFIG_RT_USING_WDT=y
|
||||
CONFIG_RT_USING_PIN=y
|
||||
# CONFIG_RT_USING_KTIME is not set
|
||||
CONFIG_RT_USING_HWTIMER=y
|
||||
# CONFIG_RT_USING_CHERRYUSB is not set
|
||||
CONFIG_RT_USING_CHERRYUSB=y
|
||||
CONFIG_RT_CHERRYUSB_DEVICE=y
|
||||
CONFIG_RT_CHERRYUSB_DEVICE_SPEED_FS=y
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_SPEED_HS is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_SPEED_AUTO is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_CUSTOM is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_FSDEV_ST is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_FSDEV_CUSTOM is not set
|
||||
CONFIG_RT_CHERRYUSB_DEVICE_DWC2_ST=y
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_ESP is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_KENDRYTE is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_AT is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_HC is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_NATION is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_GD is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_CUSTOM is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_MUSB_ES is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_MUSB_SUNXI is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_MUSB_BK is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_MUSB_SIFLI is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_MUSB_CUSTOM is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_CHIPIDEA_MCX is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_CHIPIDEA_CUSTOM is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_KINETIS_MCX is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_KINETIS_MM32 is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_KINETIS_CUSTOM is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_BL is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_HPM is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_AIC is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_RP2040 is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_CH32 is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_PUSB2 is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_NRF5X is not set
|
||||
CONFIG_RT_CHERRYUSB_DEVICE_CDC_ACM=y
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_HID is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_MSC is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_AUDIO is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_VIDEO is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_CDC_RNDIS is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_CDC_ECM is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_CDC_NCM is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_MTP is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_ADB is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_DFU is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_CDC_ACM_CHARDEV is not set
|
||||
CONFIG_CONFIG_USBDEV_REQUEST_BUFFER_LEN=512
|
||||
CONFIG_CONFIG_USBDEV_MSC_MAX_BUFSIZE=512
|
||||
# CONFIG_CONFIG_USBDEV_RNDIS_USING_LWIP is not set
|
||||
# CONFIG_CONFIG_USBDEV_CDC_ECM_USING_LWIP is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_TEMPLATE_NONE is not set
|
||||
CONFIG_RT_CHERRYUSB_DEVICE_TEMPLATE_CDC_ACM=y
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_TEMPLATE_WINUSBV1 is not set
|
||||
# CONFIG_RT_CHERRYUSB_DEVICE_TEMPLATE_WINUSBV2_CDC is not set
|
||||
# CONFIG_RT_CHERRYUSB_HOST is not set
|
||||
# end of Device Drivers
|
||||
|
||||
#
|
||||
@@ -367,8 +420,25 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
|
||||
#
|
||||
# Using USB legacy version
|
||||
#
|
||||
CONFIG_RT_USING_USB=y
|
||||
# CONFIG_RT_USING_USB_HOST is not set
|
||||
# CONFIG_RT_USING_USB_DEVICE is not set
|
||||
CONFIG_RT_USING_USB_DEVICE=y
|
||||
CONFIG_RT_USBD_THREAD_STACK_SZ=4096
|
||||
CONFIG_USB_VENDOR_ID=0x0483
|
||||
CONFIG_USB_PRODUCT_ID=0x5740
|
||||
CONFIG_RT_USB_DEVICE_COMPOSITE=y
|
||||
CONFIG_RT_USB_DEVICE_CDC=y
|
||||
CONFIG_RT_USB_DEVICE_NONE=y
|
||||
# CONFIG_RT_USB_DEVICE_MSTORAGE is not set
|
||||
# CONFIG_RT_USB_DEVICE_HID is not set
|
||||
# CONFIG_RT_USB_DEVICE_WINUSB is not set
|
||||
# CONFIG_RT_USB_DEVICE_AUDIO is not set
|
||||
CONFIG_RT_VCOM_TASK_STK_SIZE=512
|
||||
CONFIG_RT_CDC_RX_BUFSIZE=128
|
||||
# CONFIG_RT_VCOM_TX_USE_DMA is not set
|
||||
CONFIG_RT_VCOM_SERNO="32021919830108"
|
||||
CONFIG_RT_VCOM_SER_LEN=14
|
||||
CONFIG_RT_VCOM_TX_TIMEOUT=1000
|
||||
# end of Using USB legacy version
|
||||
|
||||
# CONFIG_RT_USING_FDT is not set
|
||||
@@ -1450,8 +1520,7 @@ CONFIG_BSP_USING_I2C1=y
|
||||
CONFIG_BSP_USING_I2C2=y
|
||||
CONFIG_BSP_USING_I2C3=y
|
||||
CONFIG_BSP_USING_I2C4=y
|
||||
CONFIG_BSP_USING_CAN=y
|
||||
CONFIG_BSP_USING_CAN1=y
|
||||
# CONFIG_BSP_USING_CAN is not set
|
||||
# CONFIG_BSP_USING_ADC is not set
|
||||
# CONFIG_BSP_USING_ONCHIP_RTC is not set
|
||||
CONFIG_BSP_USING_WDT=y
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "chrg_can.h"
|
||||
|
||||
#define LOG_TAG "chrg.can"
|
||||
#define DBG_LEVEL DBG_LOG
|
||||
#include <rtdbg.h>
|
||||
|
||||
struct chrg_can_t chrgcan[TOTAL_CAN] = {
|
||||
[IDX_CAN_1] = {
|
||||
.dev = RT_NULL,
|
||||
.name = DEV_NAME_CAN,
|
||||
.index = IDX_CAN_1,
|
||||
}
|
||||
};
|
||||
|
||||
rt_err_t chrg_can1_write (rt_uint8_t id, rt_uint8_t *data, rt_uint16_t len)
|
||||
{
|
||||
rt_size_t size = 0;
|
||||
struct rt_can_msg msg;
|
||||
struct chrg_can_t *pCAN = &chrgcan[IDX_CAN_1];
|
||||
|
||||
msg.id = id;
|
||||
msg.ide = RT_CAN_STDID;
|
||||
msg.rtr = RT_CAN_DTR;
|
||||
|
||||
if (len <= 8) {
|
||||
msg.len = len;
|
||||
memcpy(msg.data, data, len);
|
||||
} else {
|
||||
return RT_EINVAL;
|
||||
}
|
||||
|
||||
size = rt_device_write(pCAN->dev, 0, &msg, sizeof(msg));
|
||||
if (0 == size) {
|
||||
rt_kprintf("dev '%s' write failed.\r\n", pCAN->name);
|
||||
return RT_ERROR;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
|
||||
static rt_err_t chrg_can1_rx_callback(rt_device_t dev, rt_size_t size)
|
||||
{
|
||||
|
||||
rt_sem_release(&chrgcan[IDX_CAN_1].rx_sem);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static void chrg_can_rx_thread (void *data)
|
||||
{
|
||||
int i = 0;
|
||||
struct rt_can_msg rxmsg = {0};
|
||||
struct chrg_can_t *pCAN = (struct chrg_can_t *)data;
|
||||
|
||||
if (RT_NULL == pCAN) {
|
||||
return ;
|
||||
}
|
||||
|
||||
if (IDX_CAN_1 == pCAN->index) {
|
||||
rt_device_set_rx_indicate(pCAN->dev, chrg_can1_rx_callback);
|
||||
} else {
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
while (1) {
|
||||
//rxmsg.hdr = -1; // 直接从 uselist 链表读取数据
|
||||
|
||||
rt_sem_take(&pCAN->rx_sem, RT_WAITING_FOREVER);
|
||||
|
||||
rt_device_read(pCAN->dev, 0, &rxmsg, sizeof(rxmsg));
|
||||
|
||||
rt_kprintf("ID : %02x ", rxmsg.id);
|
||||
for (i = 0; i < 8; i++) {
|
||||
rt_kprintf("%02X ", rxmsg.data[i]);
|
||||
}
|
||||
rt_kprintf("\r\n", rxmsg.id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static int chrg_can_init (void)
|
||||
{
|
||||
int i = 0;
|
||||
rt_err_t ret = 0;
|
||||
rt_thread_t tid;
|
||||
|
||||
struct chrg_can_t *pCAN = RT_NULL;
|
||||
|
||||
for (i = 0; i < TOTAL_CAN; i++) {
|
||||
pCAN = &chrgcan[i];
|
||||
|
||||
pCAN->dev = rt_device_find(pCAN->name);
|
||||
if (RT_NULL == pCAN->dev) {
|
||||
rt_kprintf("dev '%s' not found.\r\n", pCAN->name);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
rt_sem_init(&pCAN->rx_sem, pCAN->name, 0, RT_IPC_FLAG_FIFO);
|
||||
|
||||
ret = rt_device_open(pCAN->dev, RT_DEVICE_FLAG_INT_TX | RT_DEVICE_FLAG_INT_RX);
|
||||
if (RT_EOK != ret) {
|
||||
rt_kprintf("open '%s' failed.\r\n", pCAN->name);
|
||||
continue;
|
||||
}
|
||||
|
||||
tid = rt_thread_create(pCAN->name, chrg_can_rx_thread, pCAN, 1024, 25, 10);
|
||||
if (tid != RT_NULL) {
|
||||
rt_thread_startup(tid);
|
||||
} else {
|
||||
rt_kprintf("create thread '%s' failed.\r\n", pCAN->name);
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
INIT_APP_EXPORT(chrg_can_init);
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
#ifndef __CHRG_CAN_H__
|
||||
#define __CHRG_CAN_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
#define DEV_NAME_CAN "can1"
|
||||
|
||||
typedef enum {
|
||||
IDX_CAN_1 = 0, // 0
|
||||
|
||||
TOTAL_CAN
|
||||
} eIDX_CAN;
|
||||
|
||||
struct chrg_can_t {
|
||||
rt_device_t dev;
|
||||
struct rt_semaphore rx_sem;
|
||||
|
||||
const char *name;
|
||||
eIDX_CAN index;
|
||||
|
||||
};
|
||||
|
||||
extern struct chrg_can_t chrgcan[TOTAL_CAN];
|
||||
|
||||
extern rt_err_t chrg_can1_write (rt_uint8_t id, rt_uint8_t *data, rt_uint16_t len);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@ int main(void)
|
||||
finsh_set_prompt("chrg ");
|
||||
#endif
|
||||
|
||||
extern void cdc_acm_init(uint8_t busid, uintptr_t reg_base);
|
||||
cdc_acm_init(0, USB_OTG_FS_PERIPH_BASE);
|
||||
|
||||
while (1) {
|
||||
rt_thread_mdelay(1000);
|
||||
chrg_wdt_feed();
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
/* #define HAL_IRDA_MODULE_ENABLED */
|
||||
/* #define HAL_SMARTCARD_MODULE_ENABLED */
|
||||
/* #define HAL_WWDG_MODULE_ENABLED */
|
||||
/* #define HAL_PCD_MODULE_ENABLED */
|
||||
#define HAL_PCD_MODULE_ENABLED
|
||||
/* #define HAL_HCD_MODULE_ENABLED */
|
||||
/* #define HAL_DSI_MODULE_ENABLED */
|
||||
/* #define HAL_QSPI_MODULE_ENABLED */
|
||||
|
||||
@@ -357,54 +357,6 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CAN MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
* @param hcan: CAN handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan)
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
if(hcan->Instance==CAN1) {
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_CAN1_CLK_ENABLE();
|
||||
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
/**CAN1 GPIO Configuration
|
||||
PA11 ------> CAN1_RX
|
||||
PA12 ------> CAN1_TX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF9_CAN1;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CAN MSP De-Initialization
|
||||
* This function freeze the hardware resources used in this example
|
||||
* @param hcan: CAN handle pointer
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan)
|
||||
{
|
||||
if(hcan->Instance==CAN1){
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_CAN1_CLK_DISABLE();
|
||||
|
||||
/**CAN1 GPIO Configuration
|
||||
PA11 ------> CAN1_RX
|
||||
PA12 ------> CAN1_TX
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -17,15 +17,15 @@ void SystemClock_Config(void)
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
RCC_OscInitStruct.PLL.PLLM = 4;
|
||||
RCC_OscInitStruct.PLL.PLLN = 168;
|
||||
RCC_OscInitStruct.PLL.PLLM = 8;
|
||||
RCC_OscInitStruct.PLL.PLLN = 192;
|
||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
|
||||
RCC_OscInitStruct.PLL.PLLQ = 4;
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/**Initializes the CPU, AHB and APB busses clocks
|
||||
/**Initializes the CPU, AHB and APB buses clocks
|
||||
*/
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
||||
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
||||
@@ -34,8 +34,10 @@ void SystemClock_Config(void)
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
|
||||
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,324 @@
|
||||
/*
|
||||
* Copyright (c) 2022, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef CHERRYUSB_CONFIG_H
|
||||
#define CHERRYUSB_CONFIG_H
|
||||
|
||||
/* ================ USB common Configuration ================ */
|
||||
|
||||
#ifdef __RTTHREAD__
|
||||
#include <rtthread.h>
|
||||
|
||||
#define CONFIG_USB_PRINTF(...) rt_kprintf(__VA_ARGS__)
|
||||
#else
|
||||
#define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USB_DBG_LEVEL
|
||||
#define CONFIG_USB_DBG_LEVEL USB_DBG_INFO
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_EP_NUM
|
||||
#define CONFIG_USBDEV_EP_NUM 4
|
||||
#endif
|
||||
|
||||
/* Enable print with color */
|
||||
#define CONFIG_USB_PRINTF_COLOR_ENABLE
|
||||
|
||||
// #define CONFIG_USB_DCACHE_ENABLE
|
||||
|
||||
/* data align size when use dma or use dcache */
|
||||
#ifdef CONFIG_USB_DCACHE_ENABLE
|
||||
#define CONFIG_USB_ALIGN_SIZE 32 // 32 or 64
|
||||
#else
|
||||
#define CONFIG_USB_ALIGN_SIZE 4
|
||||
#endif
|
||||
|
||||
/* attribute data into no cache ram */
|
||||
#define USB_NOCACHE_RAM_SECTION __attribute__((section(".noncacheable")))
|
||||
|
||||
/* use usb_memcpy default for high performance but cost more flash memory.
|
||||
* And, arm libc has a bug that memcpy() may cause data misalignment when the size is not a multiple of 4.
|
||||
*/
|
||||
// #define CONFIG_USB_MEMCPY_DISABLE
|
||||
|
||||
/* ================= USB Device Stack Configuration ================ */
|
||||
|
||||
/* Ep0 in and out transfer buffer */
|
||||
#ifndef CONFIG_USBDEV_REQUEST_BUFFER_LEN
|
||||
#define CONFIG_USBDEV_REQUEST_BUFFER_LEN 512
|
||||
#endif
|
||||
|
||||
/* Send ep0 in data from user buffer instead of copying into ep0 reqdata
|
||||
* Please note that user buffer must be aligned with CONFIG_USB_ALIGN_SIZE
|
||||
*/
|
||||
// #define CONFIG_USBDEV_EP0_INDATA_NO_COPY
|
||||
|
||||
/* Check if the input descriptor is correct */
|
||||
// #define CONFIG_USBDEV_DESC_CHECK
|
||||
|
||||
/* Enable test mode */
|
||||
// #define CONFIG_USBDEV_TEST_MODE
|
||||
|
||||
/* enable advance desc register api */
|
||||
#define CONFIG_USBDEV_ADVANCE_DESC
|
||||
|
||||
/* move ep0 setup handler from isr to thread */
|
||||
// #define CONFIG_USBDEV_EP0_THREAD
|
||||
|
||||
#ifndef CONFIG_USBDEV_EP0_PRIO
|
||||
#define CONFIG_USBDEV_EP0_PRIO 4
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_EP0_STACKSIZE
|
||||
#define CONFIG_USBDEV_EP0_STACKSIZE 2048
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_MSC_MAX_LUN
|
||||
#define CONFIG_USBDEV_MSC_MAX_LUN 1
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_MSC_MAX_BUFSIZE
|
||||
#define CONFIG_USBDEV_MSC_MAX_BUFSIZE 512
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_MSC_MANUFACTURER_STRING
|
||||
#define CONFIG_USBDEV_MSC_MANUFACTURER_STRING ""
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_MSC_PRODUCT_STRING
|
||||
#define CONFIG_USBDEV_MSC_PRODUCT_STRING ""
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_MSC_VERSION_STRING
|
||||
#define CONFIG_USBDEV_MSC_VERSION_STRING "0.01"
|
||||
#endif
|
||||
|
||||
/* move msc read & write from isr to while(1), you should call usbd_msc_polling in while(1) */
|
||||
// #define CONFIG_USBDEV_MSC_POLLING
|
||||
|
||||
/* move msc read & write from isr to thread */
|
||||
// #define CONFIG_USBDEV_MSC_THREAD
|
||||
|
||||
#ifndef CONFIG_USBDEV_MSC_PRIO
|
||||
#define CONFIG_USBDEV_MSC_PRIO 4
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_MSC_STACKSIZE
|
||||
#define CONFIG_USBDEV_MSC_STACKSIZE 2048
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_MTP_MAX_BUFSIZE
|
||||
#define CONFIG_USBDEV_MTP_MAX_BUFSIZE 2048
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_MTP_MAX_OBJECTS
|
||||
#define CONFIG_USBDEV_MTP_MAX_OBJECTS 256
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_MTP_MAX_PATHNAME
|
||||
#define CONFIG_USBDEV_MTP_MAX_PATHNAME 256
|
||||
#endif
|
||||
|
||||
#define CONFIG_USBDEV_MTP_THREAD
|
||||
|
||||
#ifndef CONFIG_USBDEV_MTP_PRIO
|
||||
#define CONFIG_USBDEV_MTP_PRIO 4
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_MTP_STACKSIZE
|
||||
#define CONFIG_USBDEV_MTP_STACKSIZE 4096
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE
|
||||
#define CONFIG_USBDEV_RNDIS_RESP_BUFFER_SIZE 156
|
||||
#endif
|
||||
|
||||
/* rndis transfer buffer size, must be a multiple of (1536 + 44)*/
|
||||
#ifndef CONFIG_USBDEV_RNDIS_ETH_MAX_FRAME_SIZE
|
||||
#define CONFIG_USBDEV_RNDIS_ETH_MAX_FRAME_SIZE 1580
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_RNDIS_VENDOR_ID
|
||||
#define CONFIG_USBDEV_RNDIS_VENDOR_ID 0x0000ffff
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_RNDIS_VENDOR_DESC
|
||||
#define CONFIG_USBDEV_RNDIS_VENDOR_DESC "CherryUSB"
|
||||
#endif
|
||||
|
||||
#define CONFIG_USBDEV_RNDIS_USING_LWIP
|
||||
#define CONFIG_USBDEV_CDC_ECM_USING_LWIP
|
||||
|
||||
/* ================ USB HOST Stack Configuration ================== */
|
||||
|
||||
#define CONFIG_USBHOST_MAX_RHPORTS 1
|
||||
#define CONFIG_USBHOST_MAX_EXTHUBS 1
|
||||
#define CONFIG_USBHOST_MAX_EHPORTS 4
|
||||
#define CONFIG_USBHOST_MAX_INTERFACES 8
|
||||
#define CONFIG_USBHOST_MAX_INTF_ALTSETTINGS 2
|
||||
#define CONFIG_USBHOST_MAX_ENDPOINTS 4
|
||||
|
||||
#define CONFIG_USBHOST_MAX_CDC_ACM_CLASS 4
|
||||
#define CONFIG_USBHOST_MAX_HID_CLASS 4
|
||||
#define CONFIG_USBHOST_MAX_MSC_CLASS 2
|
||||
#define CONFIG_USBHOST_MAX_AUDIO_CLASS 1
|
||||
#define CONFIG_USBHOST_MAX_VIDEO_CLASS 1
|
||||
|
||||
#define CONFIG_USBHOST_DEV_NAMELEN 16
|
||||
|
||||
#ifndef CONFIG_USBHOST_PSC_PRIO
|
||||
#define CONFIG_USBHOST_PSC_PRIO 0
|
||||
#endif
|
||||
#ifndef CONFIG_USBHOST_PSC_STACKSIZE
|
||||
#define CONFIG_USBHOST_PSC_STACKSIZE 2048
|
||||
#endif
|
||||
|
||||
//#define CONFIG_USBHOST_GET_STRING_DESC
|
||||
|
||||
// #define CONFIG_USBHOST_MSOS_ENABLE
|
||||
#ifndef CONFIG_USBHOST_MSOS_VENDOR_CODE
|
||||
#define CONFIG_USBHOST_MSOS_VENDOR_CODE 0x00
|
||||
#endif
|
||||
|
||||
/* Ep0 max transfer buffer */
|
||||
#ifndef CONFIG_USBHOST_REQUEST_BUFFER_LEN
|
||||
#define CONFIG_USBHOST_REQUEST_BUFFER_LEN 512
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT
|
||||
#define CONFIG_USBHOST_CONTROL_TRANSFER_TIMEOUT 500
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBHOST_MSC_TIMEOUT
|
||||
#define CONFIG_USBHOST_MSC_TIMEOUT 5000
|
||||
#endif
|
||||
|
||||
/* This parameter affects usb performance, and depends on (TCP_WND)tcp eceive windows size,
|
||||
* you can change to 2K ~ 16K and must be larger than TCP RX windows size in order to avoid being overflow.
|
||||
*/
|
||||
#ifndef CONFIG_USBHOST_RNDIS_ETH_MAX_RX_SIZE
|
||||
#define CONFIG_USBHOST_RNDIS_ETH_MAX_RX_SIZE (2048)
|
||||
#endif
|
||||
|
||||
/* Because lwip do not support multi pbuf at a time, so increasing this variable has no performance improvement */
|
||||
#ifndef CONFIG_USBHOST_RNDIS_ETH_MAX_TX_SIZE
|
||||
#define CONFIG_USBHOST_RNDIS_ETH_MAX_TX_SIZE (2048)
|
||||
#endif
|
||||
|
||||
/* This parameter affects usb performance, and depends on (TCP_WND)tcp eceive windows size,
|
||||
* you can change to 2K ~ 16K and must be larger than TCP RX windows size in order to avoid being overflow.
|
||||
*/
|
||||
#ifndef CONFIG_USBHOST_CDC_NCM_ETH_MAX_RX_SIZE
|
||||
#define CONFIG_USBHOST_CDC_NCM_ETH_MAX_RX_SIZE (2048)
|
||||
#endif
|
||||
/* Because lwip do not support multi pbuf at a time, so increasing this variable has no performance improvement */
|
||||
#ifndef CONFIG_USBHOST_CDC_NCM_ETH_MAX_TX_SIZE
|
||||
#define CONFIG_USBHOST_CDC_NCM_ETH_MAX_TX_SIZE (2048)
|
||||
#endif
|
||||
|
||||
/* This parameter affects usb performance, and depends on (TCP_WND)tcp eceive windows size,
|
||||
* you can change to 2K ~ 16K and must be larger than TCP RX windows size in order to avoid being overflow.
|
||||
*/
|
||||
#ifndef CONFIG_USBHOST_ASIX_ETH_MAX_RX_SIZE
|
||||
#define CONFIG_USBHOST_ASIX_ETH_MAX_RX_SIZE (2048)
|
||||
#endif
|
||||
/* Because lwip do not support multi pbuf at a time, so increasing this variable has no performance improvement */
|
||||
#ifndef CONFIG_USBHOST_ASIX_ETH_MAX_TX_SIZE
|
||||
#define CONFIG_USBHOST_ASIX_ETH_MAX_TX_SIZE (2048)
|
||||
#endif
|
||||
|
||||
/* This parameter affects usb performance, and depends on (TCP_WND)tcp eceive windows size,
|
||||
* you can change to 2K ~ 16K and must be larger than TCP RX windows size in order to avoid being overflow.
|
||||
*/
|
||||
#ifndef CONFIG_USBHOST_RTL8152_ETH_MAX_RX_SIZE
|
||||
#define CONFIG_USBHOST_RTL8152_ETH_MAX_RX_SIZE (2048)
|
||||
#endif
|
||||
/* Because lwip do not support multi pbuf at a time, so increasing this variable has no performance improvement */
|
||||
#ifndef CONFIG_USBHOST_RTL8152_ETH_MAX_TX_SIZE
|
||||
#define CONFIG_USBHOST_RTL8152_ETH_MAX_TX_SIZE (2048)
|
||||
#endif
|
||||
|
||||
#define CONFIG_USBHOST_BLUETOOTH_HCI_H4
|
||||
// #define CONFIG_USBHOST_BLUETOOTH_HCI_LOG
|
||||
|
||||
#ifndef CONFIG_USBHOST_BLUETOOTH_TX_SIZE
|
||||
#define CONFIG_USBHOST_BLUETOOTH_TX_SIZE 2048
|
||||
#endif
|
||||
#ifndef CONFIG_USBHOST_BLUETOOTH_RX_SIZE
|
||||
#define CONFIG_USBHOST_BLUETOOTH_RX_SIZE 2048
|
||||
#endif
|
||||
|
||||
/* ================ USB Device Port Configuration ================*/
|
||||
|
||||
#ifndef CONFIG_USBDEV_MAX_BUS
|
||||
#define CONFIG_USBDEV_MAX_BUS 1
|
||||
#endif
|
||||
|
||||
// #define CONFIG_USBDEV_SOF_ENABLE
|
||||
|
||||
/* ---------------- FSDEV Configuration ---------------- */
|
||||
//#define CONFIG_USBDEV_FSDEV_PMA_ACCESS 2 // maybe 1 or 2, many chips may have a difference
|
||||
|
||||
/* ---------------- DWC2 Configuration ---------------- */
|
||||
/* enable dwc2 buffer dma mode for device
|
||||
* in xxx32 chips, only pb14/pb15 can support dma mode, pa11/pa12 is not supported(only a few supports, but we ignore them)
|
||||
*/
|
||||
// #define CONFIG_USB_DWC2_DMA_ENABLE
|
||||
|
||||
/* ---------------- MUSB Configuration ---------------- */
|
||||
#define CONFIG_USB_MUSB_EP_NUM 8
|
||||
// #define CONFIG_USB_MUSB_SUNXI
|
||||
|
||||
/* ================ USB Host Port Configuration ==================*/
|
||||
#ifndef CONFIG_USBHOST_MAX_BUS
|
||||
#define CONFIG_USBHOST_MAX_BUS 1
|
||||
#endif
|
||||
|
||||
/* ---------------- EHCI Configuration ---------------- */
|
||||
|
||||
#define CONFIG_USB_EHCI_HCCR_OFFSET (0x0)
|
||||
#define CONFIG_USB_EHCI_FRAME_LIST_SIZE 1024
|
||||
#define CONFIG_USB_EHCI_QH_NUM 10
|
||||
#define CONFIG_USB_EHCI_QTD_NUM (CONFIG_USB_EHCI_QH_NUM * 3)
|
||||
#define CONFIG_USB_EHCI_ITD_NUM 4
|
||||
// #define CONFIG_USB_EHCI_HCOR_RESERVED_DISABLE
|
||||
// #define CONFIG_USB_EHCI_CONFIGFLAG
|
||||
// #define CONFIG_USB_EHCI_ISO
|
||||
// #define CONFIG_USB_EHCI_WITH_OHCI
|
||||
// #define CONFIG_USB_EHCI_DESC_DCACHE_ENABLE
|
||||
|
||||
/* ---------------- OHCI Configuration ---------------- */
|
||||
#define CONFIG_USB_OHCI_HCOR_OFFSET (0x0)
|
||||
#define CONFIG_USB_OHCI_ED_NUM 10
|
||||
#define CONFIG_USB_OHCI_TD_NUM 3
|
||||
// #define CONFIG_USB_OHCI_DESC_DCACHE_ENABLE
|
||||
|
||||
/* ---------------- XHCI Configuration ---------------- */
|
||||
#define CONFIG_USB_XHCI_HCCR_OFFSET (0x0)
|
||||
|
||||
/* ---------------- DWC2 Configuration ---------------- */
|
||||
// nothing to define
|
||||
|
||||
/* ---------------- MUSB Configuration ---------------- */
|
||||
#define CONFIG_USB_MUSB_PIPE_NUM 8
|
||||
// #define CONFIG_USB_MUSB_SUNXI
|
||||
|
||||
/* When your chip hardware supports high-speed and wants to initialize it in high-speed mode,
|
||||
* the relevant IP will configure the internal or external high-speed PHY according to CONFIG_USB_HS.
|
||||
*
|
||||
* in xxx32 chips, only pb14/pb15 can support hs mode, pa11/pa12 is not supported(only a few supports, but we ignore them).
|
||||
*/
|
||||
// #define CONFIG_USB_HS
|
||||
|
||||
#ifndef usb_phyaddr2ramaddr
|
||||
#define usb_phyaddr2ramaddr(addr) (addr)
|
||||
#endif
|
||||
|
||||
#ifndef usb_ramaddr2phyaddr
|
||||
#define usb_ramaddr2phyaddr(addr) (addr)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+237
-152
@@ -10,8 +10,8 @@
|
||||
<TargetName>chrg</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARMCC</pCCUsed>
|
||||
<uAC6>0</uAC6>
|
||||
<pCCUsed>6160000::V6.16::ARMCLANG</pCCUsed>
|
||||
<uAC6>1</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>STM32F405RG</Device>
|
||||
@@ -183,7 +183,7 @@
|
||||
<hadIRAM>1</hadIRAM>
|
||||
<hadXRAM>0</hadXRAM>
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>1</RvdsVP>
|
||||
<RvdsVP>2</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<RvdsCdeCp>0</RvdsCdeCp>
|
||||
<hadIRAM2>1</hadIRAM2>
|
||||
@@ -313,7 +313,7 @@
|
||||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
<Optim>0</Optim>
|
||||
<Optim>2</Optim>
|
||||
<oTime>0</oTime>
|
||||
<SplitLS>0</SplitLS>
|
||||
<OneElfS>1</OneElfS>
|
||||
@@ -322,14 +322,14 @@
|
||||
<PlainCh>0</PlainCh>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<wLevel>2</wLevel>
|
||||
<wLevel>3</wLevel>
|
||||
<uThumb>0</uThumb>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<uC99>1</uC99>
|
||||
<uGnu>0</uGnu>
|
||||
<useXO>0</useXO>
|
||||
<v6Lang>1</v6Lang>
|
||||
<v6LangP>1</v6LangP>
|
||||
<v6Lang>3</v6Lang>
|
||||
<v6LangP>3</v6LangP>
|
||||
<vShortEn>1</vShortEn>
|
||||
<vShortWch>1</vShortWch>
|
||||
<v6Lto>0</v6Lto>
|
||||
@@ -337,9 +337,9 @@
|
||||
<v6Rtti>0</v6Rtti>
|
||||
<VariousControls>
|
||||
<MiscControls></MiscControls>
|
||||
<Define>STM32F405xx, RT_USING_ARMLIBC, __CLK_TCK=RT_TICK_PER_SECOND, USE_HAL_DRIVER, __STDC_LIMIT_MACROS, __RTTHREAD__, RT_USING_LIBC</Define>
|
||||
<Define>STM32F405xx, __CLK_TCK=RT_TICK_PER_SECOND, USE_HAL_DRIVER, __STDC_LIMIT_MACROS, RT_USING_LIBC, __RTTHREAD__, RT_USING_ARMLIBC</Define>
|
||||
<Undefine></Undefine>
|
||||
<IncludePath>..\..\rt-thread\components\libc\posix\io\eventfd;board\ports;..\..\libs\cmsis-core\Include;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers;..\..\rt-thread\components\finsh;..\..\rt-thread\components\libc\compilers\common\extension;..\..\rt-thread\components\libc\compilers\common\include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\include;..\..\libs\stm32f4\STM32F4_HAL\Inc\Legacy;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\config;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers;..\..\rt-thread\libcpu\arm\common;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\drv_flash;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\posix\ipc;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\phy;applications\utils;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\include;applications\thread;applications\bsp;applications;..\..\rt-thread\include;board;..\..\rt-thread\libcpu\arm\cortex-m4;..\..\rt-thread\components\libc\posix\io\epoll;..\..\rt-thread\components\drivers\include;.;..\..\libs\stm32f4\STM32F4_CMSIS\Include;..\..\rt-thread\components\drivers\smp_call;..\..\rt-thread\components\libc\compilers\common\extension\fcntl\octal;..\..\rt-thread\components\drivers\include;..\..\libs\stm32f4\STM32F4_HAL\Inc;..\..\rt-thread\components\libc\posix\io\poll;..\..\rt-thread\components\fal\inc;board\CubeMX_Config\Inc;..\..\rt-thread\components\drivers\include</IncludePath>
|
||||
<IncludePath>..\..\rt-thread\components\drivers\usb\cherryusb\common;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers;board;..\..\rt-thread\components\finsh;..\..\rt-thread\components\drivers\usb\cherryusb\class\wireless;..\..\rt-thread\components\drivers\usb\cherryusb\class\cdc;..\..\rt-thread\components\drivers\usb\cherryusb\class\vendor\net;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers;..\..\rt-thread\components\libc\posix\ipc;..\..\rt-thread\components\drivers\usb\cherryusb\core;..\..\rt-thread\components\drivers\include;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\drv_flash;..\..\rt-thread\components\fal\inc;.;..\..\rt-thread\components\libc\compilers\common\include;applications\utils;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\usb\cherryusb\class\dfu;..\..\rt-thread\components\drivers\usb\cherryusb\class\video;..\..\rt-thread\components\drivers\usb\cherryusb\class\hid;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\compilers\common\extension;..\..\rt-thread\components\drivers\include;applications\thread;..\..\rt-thread\components\drivers\usb\cherryusb\class\vendor\wifi;..\..\rt-thread\components\libc\posix\io\epoll;..\..\rt-thread\components\drivers\usb\cherryusb\class\hub;..\..\rt-thread\components\drivers\usb\cherryusb;..\..\rt-thread\components\drivers\usb\cherryusb\class\vendor\serial;applications\bsp;..\..\rt-thread\components\drivers\phy;applications;..\..\rt-thread\components\drivers\usb\cherryusb\class\midi;..\..\rt-thread\components\libc\posix\io\eventfd;..\..\rt-thread\components\libc\compilers\common\extension\fcntl\octal;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\include;board\CubeMX_Config\Inc;..\..\libs\stm32f4\STM32F4_HAL\Inc\Legacy;..\..\rt-thread\components\drivers\usb\cherryusb\osal;board\ports;..\..\rt-thread\include;..\..\rt-thread\components\libc\posix\io\poll;..\..\libs\stm32f4\STM32F4_HAL\Inc;..\..\rt-thread\components\drivers\usb\cherryusb\class\msc;..\..\libs\cmsis-core\Include;..\..\rt-thread\libcpu\arm\common;..\..\rt-thread\components\drivers\usb\cherryusb\class\adb;..\..\libs\stm32f4\STM32F4_CMSIS\Include;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\config;..\..\rt-thread\components\drivers\usb\cherryusb\class\audio;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\libcpu\arm\cortex-m4;..\..\rt-thread\components\drivers\smp_call;..\..\rt-thread\components\legacy\usb\usbdevice</IncludePath>
|
||||
</VariousControls>
|
||||
</Cads>
|
||||
<Aads>
|
||||
@@ -393,21 +393,6 @@
|
||||
<Group>
|
||||
<GroupName>Applications/bsp</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>chrg_pin.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\bsp\chrg_pin.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_clk.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\bsp\chrg_clk.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_switch.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\bsp\chrg_switch.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_i2c.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -419,14 +404,14 @@
|
||||
<FilePath>applications\bsp\chrg_fal.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_tmr.c</FileName>
|
||||
<FileName>chrg_clk.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\bsp\chrg_tmr.c</FilePath>
|
||||
<FilePath>applications\bsp\chrg_clk.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_can.c</FileName>
|
||||
<FileName>chrg_pin.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\bsp\chrg_can.c</FilePath>
|
||||
<FilePath>applications\bsp\chrg_pin.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_intr.c</FileName>
|
||||
@@ -434,24 +419,34 @@
|
||||
<FilePath>applications\bsp\chrg_intr.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_tty.c</FileName>
|
||||
<FileName>chrg_tmr.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\bsp\chrg_tty.c</FilePath>
|
||||
<FilePath>applications\bsp\chrg_tmr.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_wdt.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\bsp\chrg_wdt.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_tty.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\bsp\chrg_tty.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_switch.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\bsp\chrg_switch.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Applications/thread</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>chrg_north.c</FileName>
|
||||
<FileName>chrg_lcd.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\thread\chrg_north.c</FilePath>
|
||||
<FilePath>applications\thread\chrg_lcd.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_roll.c</FileName>
|
||||
@@ -463,16 +458,16 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\thread\chrg_south.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_north.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\thread\chrg_north.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_comm.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\thread\chrg_comm.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_lcd.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\thread\chrg_lcd.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
@@ -483,6 +478,11 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\utils\chrg_source.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_pkg.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\utils\chrg_pkg.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_pcf8574.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -493,11 +493,6 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\utils\chrg_utils.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_pkg.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>applications\utils\chrg_pkg.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>chrg_sink.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -505,6 +500,51 @@
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>CherryUSB</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>usb_check.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\drivers\usb\cherryusb\platform\rtthread\usb_check.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>usbd_cdc_acm.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\drivers\usb\cherryusb\class\cdc\usbd_cdc_acm.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>usbd_core.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\drivers\usb\cherryusb\core\usbd_core.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>usb_glue_st.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\drivers\usb\cherryusb\port\dwc2\usb_glue_st.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>usb_msh.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\drivers\usb\cherryusb\platform\rtthread\usb_msh.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>usb_osal_rtthread.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\drivers\usb\cherryusb\osal\usb_osal_rtthread.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>cdc_acm_template.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\drivers\usb\cherryusb\demo\cdc_acm_template.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>usb_dc_dwc2.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\drivers\usb\cherryusb\port\dwc2\usb_dc_dwc2.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>Compiler</GroupName>
|
||||
<Files>
|
||||
@@ -1621,11 +1661,6 @@
|
||||
<Group>
|
||||
<GroupName>Fal</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>fal_partition.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\fal\src\fal_partition.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>fal.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -1636,6 +1671,11 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\fal\src\fal_flash.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>fal_partition.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\fal\src\fal_partition.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>fal_rtt.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -1647,9 +1687,9 @@
|
||||
<GroupName>Finsh</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>cmd.c</FileName>
|
||||
<FileName>shell.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\finsh\cmd.c</FilePath>
|
||||
<FilePath>..\..\rt-thread\components\finsh\shell.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>msh.c</FileName>
|
||||
@@ -1662,9 +1702,9 @@
|
||||
<FilePath>..\..\rt-thread\components\finsh\msh_parse.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>shell.c</FileName>
|
||||
<FileName>cmd.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\finsh\shell.c</FilePath>
|
||||
<FilePath>..\..\rt-thread\components\finsh\cmd.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
@@ -2516,6 +2556,11 @@
|
||||
<Group>
|
||||
<GroupName>klibc</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>kstring.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\src\klibc\kstring.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>kstdio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -2531,11 +2576,6 @@
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\src\klibc\kerrno.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>kstring.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\src\klibc\kstring.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>rt_vsnprintf_tiny.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -2573,6 +2613,26 @@
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>rt_usbd</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>usbdevice.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\legacy\usb\usbdevice\core\usbdevice.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>usbdevice_core.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\legacy\usb\usbdevice\core\usbdevice_core.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>cdc_vcom.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\rt-thread\components\legacy\usb\usbdevice\class\cdc_vcom.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
<GroupName>STM32F4-CMSIS</GroupName>
|
||||
<Files>
|
||||
@@ -2591,116 +2651,146 @@
|
||||
<Group>
|
||||
<GroupName>STM32F4-HAL</GroupName>
|
||||
<Files>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_gpio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_gpio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_lptim.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_lptim.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_flash_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_can.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_can.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_cryp.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_rcc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_rng.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rng.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_dma_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_tim.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_tim.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_flash.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_pwr.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_cortex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cortex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_iwdg.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_iwdg.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_dma.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_uart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_uart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_cryp_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_rcc_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_i2c_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_i2c_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_usart.c</FileName>
|
||||
<FileName>stm32f4xx_hal_tim.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_usart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_crc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_crc.c</FilePath>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_tim.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_tim_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_tim_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_lptim.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_lptim.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_rcc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_uart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_uart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_cryp.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_pcd.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pcd.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_ll_usb.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_ll_usb.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_cec.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cec.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_pcd_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pcd_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_rcc_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_gpio.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_gpio.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_usart.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_usart.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_pwr.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_crc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_crc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_cortex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cortex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_flash_ramfunc.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ramfunc.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_dma.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_flash.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_pwr_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_flash_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_rng.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rng.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_can.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_can.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_cryp_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp_ex.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_wwdg.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_wwdg.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_hcd.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_hcd.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_i2c.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
@@ -2712,19 +2802,14 @@
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_pwr_ex.c</FileName>
|
||||
<FileName>stm32f4xx_hal_pccard.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr_ex.c</FilePath>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pccard.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_wwdg.c</FileName>
|
||||
<FileName>stm32f4xx_hal_dma_ex.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_wwdg.c</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>stm32f4xx_hal_cec.c</FileName>
|
||||
<FileType>1</FileType>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cec.c</FilePath>
|
||||
<FilePath>..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma_ex.c</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
CONFIG_RT_NAME_MAX=16
|
||||
# CONFIG_RT_USING_TIMER_SOFT is not set
|
||||
CONFIG_RT_USING_CPU_USAGE_TRACER=y
|
||||
CONFIG_RT_USING_MEMHEAP_AS_HEAP=y
|
||||
CONFIG_RT_CONSOLE_DEVICE_NAME="uart2"
|
||||
# CONFIG_RT_USING_DFS is not set
|
||||
CONFIG_RT_USING_FAL=y
|
||||
# CONFIG_FAL_USING_DEBUG is not set
|
||||
CONFIG_RT_USING_SYSTEM_WORKQUEUE=y
|
||||
CONFIG_RT_USING_CHERRYUSB=y
|
||||
CONFIG_RT_CHERRYUSB_DEVICE=y
|
||||
CONFIG_RT_CHERRYUSB_DEVICE_DWC2_ST=y
|
||||
CONFIG_RT_CHERRYUSB_DEVICE_CDC_ACM=y
|
||||
CONFIG_RT_CHERRYUSB_DEVICE_TEMPLATE_CDC_ACM=y
|
||||
CONFIG_RT_USING_USB_DEVICE=y
|
||||
CONFIG_USB_VENDOR_ID=0x0483
|
||||
CONFIG_USB_PRODUCT_ID=0x5740
|
||||
CONFIG_RT_USB_DEVICE_COMPOSITE=y
|
||||
CONFIG_RT_USB_DEVICE_CDC=y
|
||||
CONFIG_BSP_UART3_RX_USING_DMA=y
|
||||
CONFIG_BSP_UART3_TX_USING_DMA=y
|
||||
# CONFIG_BSP_USING_UART4 is not set
|
||||
CONFIG_BSP_UART6_RX_USING_DMA=y
|
||||
CONFIG_BSP_UART6_TX_USING_DMA=y
|
||||
CONFIG_BSP_USING_I2C=y
|
||||
CONFIG_BSP_USING_I2C1=y
|
||||
CONFIG_BSP_USING_I2C2=y
|
||||
CONFIG_BSP_USING_I2C3=y
|
||||
CONFIG_BSP_USING_I2C4=y
|
||||
CONFIG_BSP_USING_CAN=y
|
||||
CONFIG_BSP_USING_CAN1=y
|
||||
CONFIG_BSP_USING_WDT=y
|
||||
CONFIG_BSP_USING_ON_CHIP_FLASH=y
|
||||
CONFIG_BSP_USING_TIM=y
|
||||
CONFIG_BSP_USING_TIM2=y
|
||||
+22
-3
@@ -107,7 +107,7 @@
|
||||
#define RT_USING_CONSOLE
|
||||
#define RT_CONSOLEBUF_SIZE 128
|
||||
#define RT_CONSOLE_DEVICE_NAME "uart2"
|
||||
#define RT_VER_NUM 0x50201
|
||||
#define RT_VER_NUM 0x50202
|
||||
#define RT_BACKTRACE_LEVEL_MAX_NR 32
|
||||
/* end of RT-Thread Kernel */
|
||||
#define RT_USING_HW_ATOMIC
|
||||
@@ -163,6 +163,14 @@
|
||||
#define RT_USING_WDT
|
||||
#define RT_USING_PIN
|
||||
#define RT_USING_HWTIMER
|
||||
#define RT_USING_CHERRYUSB
|
||||
#define RT_CHERRYUSB_DEVICE
|
||||
#define RT_CHERRYUSB_DEVICE_SPEED_FS
|
||||
#define RT_CHERRYUSB_DEVICE_DWC2_ST
|
||||
#define RT_CHERRYUSB_DEVICE_CDC_ACM
|
||||
#define CONFIG_USBDEV_REQUEST_BUFFER_LEN 512
|
||||
#define CONFIG_USBDEV_MSC_MAX_BUFSIZE 512
|
||||
#define RT_CHERRYUSB_DEVICE_TEMPLATE_CDC_ACM
|
||||
/* end of Device Drivers */
|
||||
|
||||
/* C/C++ and POSIX layer */
|
||||
@@ -204,6 +212,19 @@
|
||||
|
||||
/* Using USB legacy version */
|
||||
|
||||
#define RT_USING_USB
|
||||
#define RT_USING_USB_DEVICE
|
||||
#define RT_USBD_THREAD_STACK_SZ 4096
|
||||
#define USB_VENDOR_ID 0x0483
|
||||
#define USB_PRODUCT_ID 0x5740
|
||||
#define RT_USB_DEVICE_COMPOSITE
|
||||
#define RT_USB_DEVICE_CDC
|
||||
#define RT_USB_DEVICE_NONE
|
||||
#define RT_VCOM_TASK_STK_SIZE 512
|
||||
#define RT_CDC_RX_BUFSIZE 128
|
||||
#define RT_VCOM_SERNO "32021919830108"
|
||||
#define RT_VCOM_SER_LEN 14
|
||||
#define RT_VCOM_TX_TIMEOUT 1000
|
||||
/* end of Using USB legacy version */
|
||||
/* end of RT-Thread Components */
|
||||
|
||||
@@ -439,8 +460,6 @@
|
||||
#define BSP_USING_I2C2
|
||||
#define BSP_USING_I2C3
|
||||
#define BSP_USING_I2C4
|
||||
#define BSP_USING_CAN
|
||||
#define BSP_USING_CAN1
|
||||
#define BSP_USING_WDT
|
||||
#define BSP_USING_ON_CHIP_FLASH
|
||||
#define BSP_USING_TIM
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<TargetName>chrg</TargetName>
|
||||
<ToolsetNumber>0x4</ToolsetNumber>
|
||||
<ToolsetName>ARM-ADS</ToolsetName>
|
||||
<uAC6>0</uAC6>
|
||||
<uAC6>1</uAC6>
|
||||
<TargetOption>
|
||||
<TargetCommonOption>
|
||||
<Device>STM32F405RG</Device>
|
||||
@@ -182,7 +182,7 @@
|
||||
<hadIRAM>1</hadIRAM>
|
||||
<hadXRAM>0</hadXRAM>
|
||||
<uocXRam>0</uocXRam>
|
||||
<RvdsVP>1</RvdsVP>
|
||||
<RvdsVP>2</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<RvdsCdeCp>0</RvdsCdeCp>
|
||||
<hadIRAM2>1</hadIRAM2>
|
||||
@@ -312,7 +312,7 @@
|
||||
</ArmAdsMisc>
|
||||
<Cads>
|
||||
<interw>1</interw>
|
||||
<Optim>1</Optim>
|
||||
<Optim>2</Optim>
|
||||
<oTime>0</oTime>
|
||||
<SplitLS>0</SplitLS>
|
||||
<OneElfS>1</OneElfS>
|
||||
@@ -321,14 +321,14 @@
|
||||
<PlainCh>0</PlainCh>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<wLevel>2</wLevel>
|
||||
<wLevel>3</wLevel>
|
||||
<uThumb>0</uThumb>
|
||||
<uSurpInc>0</uSurpInc>
|
||||
<uC99>1</uC99>
|
||||
<uGnu>0</uGnu>
|
||||
<useXO>0</useXO>
|
||||
<v6Lang>1</v6Lang>
|
||||
<v6LangP>1</v6LangP>
|
||||
<v6Lang>3</v6Lang>
|
||||
<v6LangP>3</v6LangP>
|
||||
<vShortEn>1</vShortEn>
|
||||
<vShortWch>1</vShortWch>
|
||||
<v6Lto>0</v6Lto>
|
||||
@@ -360,11 +360,11 @@
|
||||
</VariousControls>
|
||||
</Aads>
|
||||
<LDads>
|
||||
<umfTarg>1</umfTarg>
|
||||
<umfTarg>0</umfTarg>
|
||||
<Ropi>0</Ropi>
|
||||
<Rwpi>0</Rwpi>
|
||||
<noStLib>0</noStLib>
|
||||
<RepFail>1</RepFail>
|
||||
<RepFail>0</RepFail>
|
||||
<useFile>0</useFile>
|
||||
<TextAddressRange>0x08000000</TextAddressRange>
|
||||
<DataAddressRange>0x20000000</DataAddressRange>
|
||||
|
||||
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 128 KiB |
@@ -48,7 +48,7 @@
|
||||
#include "stm32f4xx.h"
|
||||
|
||||
#if !defined (HSE_VALUE)
|
||||
#define HSE_VALUE ((uint32_t)25000000) /*!< Default value of the External oscillator in Hz */
|
||||
#define HSE_VALUE ((uint32_t)8000000) /*!< Default value of the External oscillator in Hz */
|
||||
#endif /* HSE_VALUE */
|
||||
|
||||
#if !defined (HSI_VALUE)
|
||||
|
||||
+5
-4
@@ -9,12 +9,13 @@
|
||||
|
||||
<project>
|
||||
<PathAndName>..\apps\boot\boot.uvprojx</PathAndName>
|
||||
</project>
|
||||
|
||||
<project>
|
||||
<PathAndName>..\apps\chrg\chrg.uvprojx</PathAndName>
|
||||
<NodeIsActive>1</NodeIsActive>
|
||||
<NodeIsExpanded>1</NodeIsExpanded>
|
||||
</project>
|
||||
|
||||
<project>
|
||||
<PathAndName>..\apps\chrg\chrg.uvprojx</PathAndName>
|
||||
<NodeIsExpanded>1</NodeIsExpanded>
|
||||
</project>
|
||||
|
||||
</ProjectWorkspace>
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
build
|
||||
Debug
|
||||
.vs
|
||||
rtthread
|
||||
settings
|
||||
documentation/html
|
||||
*~
|
||||
|
||||
@@ -18,4 +18,5 @@
|
||||
#define CHERRYUSB_VERSION 0x010502
|
||||
#define CHERRYUSB_VERSION_STR "v1.5.2"
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
#define CDC_OUT_EP 0x02
|
||||
#define CDC_INT_EP 0x83
|
||||
|
||||
#define USBD_VID 0xFFFF
|
||||
#define USBD_PID 0xFFFF
|
||||
#define USBD_VID 0x483
|
||||
#define USBD_PID 0x5740
|
||||
#define USBD_MAX_POWER 100
|
||||
#define USBD_LANGID_STRING 1033
|
||||
|
||||
@@ -276,4 +276,5 @@ void cdc_acm_data_send_with_dtr_test(uint8_t busid)
|
||||
while (ep_tx_busy_flag) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -221,4 +221,4 @@ void *usb_osal_malloc(size_t size)
|
||||
void usb_osal_free(void *ptr)
|
||||
{
|
||||
rt_free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2022 ~ 2025, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "rtthread.h"
|
||||
#include "usb_config.h"
|
||||
|
||||
#if defined(PKG_CHERRYUSB_HOST) || defined(RT_CHERRYUSB_HOST)
|
||||
|
||||
#ifndef RT_USING_TIMER_SOFT
|
||||
#error must enable RT_USING_TIMER_SOFT to support timer callback in thread
|
||||
#endif
|
||||
|
||||
#if RT_TIMER_THREAD_STACK_SIZE < 1024
|
||||
#error "RT_TIMER_THREAD_STACK_SIZE must be >= 1024"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(ARCH_ARM_CORTEX_M7) || \
|
||||
defined(SOC_HPM6000) || defined(SOC_HPM6E00) || defined(SOC_HPM6P00) || \
|
||||
defined(BSP_USING_BL61X) || defined(BSP_USING_BL808)
|
||||
#ifndef RT_USING_CACHE
|
||||
#error RT_USING_CACHE must be enabled in this chip
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_CACHE
|
||||
#ifndef CONFIG_USB_DCACHE_ENABLE
|
||||
#warning CONFIG_USB_DCACHE_ENABLE must be enabled if you do not config nocache ram
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2024, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "rtthread.h"
|
||||
|
||||
#if defined(PKG_CHERRYUSB_HOST) || defined(RT_CHERRYUSB_HOST)
|
||||
|
||||
#include "usbh_core.h"
|
||||
|
||||
int usbh_init(int argc, char **argv)
|
||||
{
|
||||
uint8_t busid;
|
||||
uint32_t reg_base;
|
||||
|
||||
if (argc < 3) {
|
||||
USB_LOG_ERR("please input correct command: usbh_init <busid> <reg_base>\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
busid = atoi(argv[1]);
|
||||
reg_base = strtoll(argv[2], NULL, 16);
|
||||
usbh_initialize(busid, reg_base);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int usbh_deinit(int argc, char **argv)
|
||||
{
|
||||
uint8_t busid;
|
||||
|
||||
if (argc < 2) {
|
||||
USB_LOG_ERR("please input correct command: usbh_deinit <busid>\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
busid = atoi(argv[1]);
|
||||
usbh_deinitialize(busid);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
MSH_CMD_EXPORT(usbh_init, init usb host);
|
||||
MSH_CMD_EXPORT(usbh_deinit, deinit usb host);
|
||||
MSH_CMD_EXPORT(lsusb, ls usb devices);
|
||||
#endif
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright (c) 2025, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
#include "usbd_core.h"
|
||||
#include "usbd_adb.h"
|
||||
|
||||
#ifndef CONFIG_USBDEV_SHELL_RX_BUFSIZE
|
||||
#define CONFIG_USBDEV_SHELL_RX_BUFSIZE (2048)
|
||||
#endif
|
||||
|
||||
struct usbd_adb_shell {
|
||||
struct rt_device parent;
|
||||
usb_osal_sem_t tx_done;
|
||||
struct rt_ringbuffer rx_rb;
|
||||
rt_uint8_t rx_rb_buffer[CONFIG_USBDEV_SHELL_RX_BUFSIZE];
|
||||
} g_usbd_adb_shell;
|
||||
|
||||
void usbd_adb_notify_shell_read(uint8_t *data, uint32_t len)
|
||||
{
|
||||
rt_ringbuffer_put(&g_usbd_adb_shell.rx_rb, data, len);
|
||||
|
||||
if (g_usbd_adb_shell.parent.rx_indicate) {
|
||||
g_usbd_adb_shell.parent.rx_indicate(&g_usbd_adb_shell.parent, len);
|
||||
}
|
||||
}
|
||||
|
||||
void usbd_adb_notify_write_done(void)
|
||||
{
|
||||
if (g_usbd_adb_shell.tx_done) {
|
||||
usb_osal_sem_give(g_usbd_adb_shell.tx_done);
|
||||
}
|
||||
}
|
||||
|
||||
static rt_err_t usbd_adb_shell_open(struct rt_device *dev, rt_uint16_t oflag)
|
||||
{
|
||||
while (!usb_device_is_configured(0)) {
|
||||
rt_thread_mdelay(10);
|
||||
}
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t usbd_adb_shell_close(struct rt_device *dev)
|
||||
{
|
||||
if (g_usbd_adb_shell.tx_done) {
|
||||
usb_osal_sem_give(g_usbd_adb_shell.tx_done);
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_ssize_t usbd_adb_shell_read(struct rt_device *dev,
|
||||
rt_off_t pos,
|
||||
void *buffer,
|
||||
rt_size_t size)
|
||||
{
|
||||
return rt_ringbuffer_get(&g_usbd_adb_shell.rx_rb, (rt_uint8_t *)buffer, size);
|
||||
}
|
||||
|
||||
static rt_ssize_t usbd_adb_shell_write(struct rt_device *dev,
|
||||
rt_off_t pos,
|
||||
const void *buffer,
|
||||
rt_size_t size)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
if (!usb_device_is_configured(0)) {
|
||||
return size;
|
||||
}
|
||||
|
||||
if (usbd_adb_can_write() && size) {
|
||||
usb_osal_sem_reset(g_usbd_adb_shell.tx_done);
|
||||
usbd_abd_write(ADB_SHELL_LOALID, buffer, size);
|
||||
usb_osal_sem_take(g_usbd_adb_shell.tx_done, 0xffffffff);
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
const static struct rt_device_ops usbd_adb_shell_ops = {
|
||||
NULL,
|
||||
usbd_adb_shell_open,
|
||||
usbd_adb_shell_close,
|
||||
usbd_adb_shell_read,
|
||||
usbd_adb_shell_write,
|
||||
NULL
|
||||
};
|
||||
#endif
|
||||
|
||||
void usbd_adb_shell_init(uint8_t in_ep, uint8_t out_ep)
|
||||
{
|
||||
rt_err_t ret;
|
||||
struct rt_device *device;
|
||||
|
||||
device = &(g_usbd_adb_shell.parent);
|
||||
|
||||
device->type = RT_Device_Class_Char;
|
||||
device->rx_indicate = RT_NULL;
|
||||
device->tx_complete = RT_NULL;
|
||||
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
device->ops = &usbd_adb_shell_ops;
|
||||
#else
|
||||
device->init = NULL;
|
||||
device->open = usbd_adb_shell_open;
|
||||
device->close = usbd_adb_shell_close;
|
||||
device->read = usbd_adb_shell_read;
|
||||
device->write = usbd_adb_shell_write;
|
||||
device->control = NULL;
|
||||
#endif
|
||||
device->user_data = NULL;
|
||||
|
||||
/* register a character device */
|
||||
ret = rt_device_register(device, "adb-sh", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_REMOVABLE);
|
||||
|
||||
#ifdef RT_USING_POSIX_DEVIO
|
||||
/* set fops */
|
||||
device->fops = NULL;
|
||||
#endif
|
||||
|
||||
g_usbd_adb_shell.tx_done = usb_osal_sem_create(0);
|
||||
rt_ringbuffer_init(&g_usbd_adb_shell.rx_rb, g_usbd_adb_shell.rx_rb_buffer, sizeof(g_usbd_adb_shell.rx_rb_buffer));
|
||||
}
|
||||
|
||||
static int adb_enter(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
finsh_set_device("adb-sh");
|
||||
rt_console_set_device("adb-sh");
|
||||
|
||||
return 0;
|
||||
}
|
||||
MSH_CMD_EXPORT(adb_enter, adb_enter);
|
||||
|
||||
static int adb_exit(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
usbd_adb_close(ADB_SHELL_LOALID);
|
||||
|
||||
finsh_set_device(RT_CONSOLE_DEVICE_NAME);
|
||||
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
||||
|
||||
return 0;
|
||||
}
|
||||
MSH_CMD_EXPORT(adb_exit, adb_exit);
|
||||
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
* Copyright (c) 2025, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
#include "usbd_core.h"
|
||||
#include "usbd_cdc_acm.h"
|
||||
|
||||
#define DEV_FORMAT_CDC_ACM "usb-acm%d"
|
||||
|
||||
#ifndef CONFIG_USBDEV_MAX_CDC_ACM_CLASS
|
||||
#define CONFIG_USBDEV_MAX_CDC_ACM_CLASS (4)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBDEV_SERIAL_RX_BUFSIZE
|
||||
#define CONFIG_USBDEV_SERIAL_RX_BUFSIZE (2048)
|
||||
#endif
|
||||
|
||||
struct usbd_serial {
|
||||
struct rt_device parent;
|
||||
uint8_t busid;
|
||||
uint8_t in_ep;
|
||||
uint8_t out_ep;
|
||||
struct usbd_interface intf_ctrl;
|
||||
struct usbd_interface intf_data;
|
||||
usb_osal_sem_t tx_done;
|
||||
uint8_t minor;
|
||||
char name[32];
|
||||
struct rt_ringbuffer rx_rb;
|
||||
rt_uint8_t rx_rb_buffer[CONFIG_USBDEV_SERIAL_RX_BUFSIZE];
|
||||
};
|
||||
|
||||
static uint32_t g_devinuse = 0;
|
||||
|
||||
static USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_usbd_serial_cdc_acm_rx_buf[CONFIG_USBDEV_MAX_CDC_ACM_CLASS][USB_ALIGN_UP(512, CONFIG_USB_ALIGN_SIZE)];
|
||||
|
||||
static struct usbd_serial g_usbd_serial_cdc_acm[CONFIG_USBDEV_MAX_CDC_ACM_CLASS];
|
||||
|
||||
static struct usbd_serial *usbd_serial_alloc(void)
|
||||
{
|
||||
uint8_t devno;
|
||||
struct usbd_serial *serial;
|
||||
|
||||
for (devno = 0; devno < CONFIG_USBDEV_MAX_CDC_ACM_CLASS; devno++) {
|
||||
if ((g_devinuse & (1U << devno)) == 0) {
|
||||
g_devinuse |= (1U << devno);
|
||||
|
||||
serial = &g_usbd_serial_cdc_acm[devno];
|
||||
memset(serial, 0, sizeof(struct usbd_serial));
|
||||
serial->minor = devno;
|
||||
snprintf(serial->name, CONFIG_USBHOST_DEV_NAMELEN, DEV_FORMAT_CDC_ACM, serial->minor);
|
||||
return serial;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void usbd_serial_free(struct usbd_serial *serial)
|
||||
{
|
||||
uint8_t devno = serial->minor;
|
||||
|
||||
if (devno < 32) {
|
||||
g_devinuse &= ~(1U << devno);
|
||||
}
|
||||
memset(serial, 0, sizeof(struct usbd_serial));
|
||||
}
|
||||
|
||||
static rt_err_t usbd_serial_open(struct rt_device *dev, rt_uint16_t oflag)
|
||||
{
|
||||
struct usbd_serial *serial;
|
||||
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
serial = (struct usbd_serial *)dev;
|
||||
|
||||
if (!usb_device_is_configured(serial->busid)) {
|
||||
USB_LOG_ERR("USB device is not configured\n");
|
||||
return -RT_EPERM;
|
||||
}
|
||||
|
||||
usbd_ep_start_read(serial->busid, serial->out_ep,
|
||||
g_usbd_serial_cdc_acm_rx_buf[serial->minor],
|
||||
usbd_get_ep_mps(serial->busid, serial->out_ep));
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_ssize_t usbd_serial_read(struct rt_device *dev,
|
||||
rt_off_t pos,
|
||||
void *buffer,
|
||||
rt_size_t size)
|
||||
{
|
||||
struct usbd_serial *serial;
|
||||
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
serial = (struct usbd_serial *)dev;
|
||||
|
||||
if (!usb_device_is_configured(serial->busid)) {
|
||||
return -RT_EPERM;
|
||||
}
|
||||
|
||||
return rt_ringbuffer_get(&serial->rx_rb, (rt_uint8_t *)buffer, size);
|
||||
}
|
||||
|
||||
static rt_ssize_t usbd_serial_write(struct rt_device *dev,
|
||||
rt_off_t pos,
|
||||
const void *buffer,
|
||||
rt_size_t size)
|
||||
{
|
||||
struct usbd_serial *serial;
|
||||
int ret = 0;
|
||||
rt_uint8_t *align_buf;
|
||||
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
serial = (struct usbd_serial *)dev;
|
||||
|
||||
if (!usb_device_is_configured(serial->busid)) {
|
||||
return -RT_EPERM;
|
||||
}
|
||||
align_buf = (rt_uint8_t *)buffer;
|
||||
|
||||
#ifdef CONFIG_USB_DCACHE_ENABLE
|
||||
if ((uint32_t)buffer & (CONFIG_USB_ALIGN_SIZE - 1)) {
|
||||
align_buf = rt_malloc_align(size, CONFIG_USB_ALIGN_SIZE);
|
||||
if (!align_buf) {
|
||||
USB_LOG_ERR("serial get align buf failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
usb_memcpy(align_buf, buffer, size);
|
||||
}
|
||||
#endif
|
||||
usb_osal_sem_reset(serial->tx_done);
|
||||
usbd_ep_start_write(serial->busid, serial->in_ep, align_buf, size);
|
||||
ret = usb_osal_sem_take(serial->tx_done, 3000);
|
||||
if (ret < 0) {
|
||||
USB_LOG_ERR("serial write timeout\n");
|
||||
ret = -RT_ETIMEOUT;
|
||||
} else {
|
||||
ret = size;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_USB_DCACHE_ENABLE
|
||||
if ((uint32_t)buffer & (CONFIG_USB_ALIGN_SIZE - 1)) {
|
||||
rt_free_align(align_buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
const static struct rt_device_ops usbd_serial_ops = {
|
||||
NULL,
|
||||
usbd_serial_open,
|
||||
NULL,
|
||||
usbd_serial_read,
|
||||
usbd_serial_write,
|
||||
NULL
|
||||
};
|
||||
#endif
|
||||
|
||||
rt_err_t usbd_serial_register(struct usbd_serial *serial,
|
||||
void *data)
|
||||
{
|
||||
rt_err_t ret;
|
||||
struct rt_device *device;
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
|
||||
device = &(serial->parent);
|
||||
|
||||
device->type = RT_Device_Class_Char;
|
||||
device->rx_indicate = RT_NULL;
|
||||
device->tx_complete = RT_NULL;
|
||||
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
device->ops = &usbd_serial_ops;
|
||||
#else
|
||||
device->init = NULL;
|
||||
device->open = usbd_serial_open;
|
||||
device->close = NULL;
|
||||
device->read = usbd_serial_read;
|
||||
device->write = usbd_serial_write;
|
||||
device->control = NULL;
|
||||
#endif
|
||||
device->user_data = data;
|
||||
|
||||
/* register a character device */
|
||||
ret = rt_device_register(device, serial->name, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_REMOVABLE);
|
||||
|
||||
#ifdef RT_USING_POSIX_DEVIO
|
||||
/* set fops */
|
||||
device->fops = NULL;
|
||||
#endif
|
||||
rt_ringbuffer_init(&serial->rx_rb, serial->rx_rb_buffer, sizeof(serial->rx_rb_buffer));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void usbd_cdc_acm_bulk_out(uint8_t busid, uint8_t ep, uint32_t nbytes)
|
||||
{
|
||||
struct usbd_serial *serial;
|
||||
|
||||
for (uint8_t devno = 0; devno < CONFIG_USBDEV_MAX_CDC_ACM_CLASS; devno++) {
|
||||
serial = &g_usbd_serial_cdc_acm[devno];
|
||||
if (serial->out_ep == ep) {
|
||||
rt_ringbuffer_put(&serial->rx_rb, g_usbd_serial_cdc_acm_rx_buf[serial->minor], nbytes);
|
||||
usbd_ep_start_read(serial->busid, serial->out_ep,
|
||||
g_usbd_serial_cdc_acm_rx_buf[serial->minor],
|
||||
usbd_get_ep_mps(serial->busid, serial->out_ep));
|
||||
|
||||
if (serial->parent.rx_indicate) {
|
||||
serial->parent.rx_indicate(&serial->parent, nbytes);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void usbd_cdc_acm_bulk_in(uint8_t busid, uint8_t ep, uint32_t nbytes)
|
||||
{
|
||||
struct usbd_serial *serial;
|
||||
|
||||
if ((nbytes % usbd_get_ep_mps(busid, ep)) == 0 && nbytes) {
|
||||
/* send zlp */
|
||||
usbd_ep_start_write(busid, ep, NULL, 0);
|
||||
} else {
|
||||
for (uint8_t devno = 0; devno < CONFIG_USBDEV_MAX_CDC_ACM_CLASS; devno++) {
|
||||
serial = &g_usbd_serial_cdc_acm[devno];
|
||||
if ((serial->in_ep == ep) && serial->tx_done) {
|
||||
usb_osal_sem_give(serial->tx_done);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void usbd_cdc_acm_serial_init(uint8_t busid, uint8_t in_ep, uint8_t out_ep)
|
||||
{
|
||||
struct usbd_serial *serial;
|
||||
|
||||
struct usbd_endpoint cdc_out_ep = {
|
||||
.ep_addr = out_ep,
|
||||
.ep_cb = usbd_cdc_acm_bulk_out
|
||||
};
|
||||
|
||||
struct usbd_endpoint cdc_in_ep = {
|
||||
.ep_addr = in_ep,
|
||||
.ep_cb = usbd_cdc_acm_bulk_in
|
||||
};
|
||||
|
||||
serial = usbd_serial_alloc();
|
||||
if (serial == NULL) {
|
||||
USB_LOG_ERR("No more serial device available\n");
|
||||
return;
|
||||
}
|
||||
|
||||
serial->busid = busid;
|
||||
serial->in_ep = in_ep;
|
||||
serial->out_ep = out_ep;
|
||||
serial->tx_done = usb_osal_sem_create(0);
|
||||
|
||||
usbd_add_interface(busid, usbd_cdc_acm_init_intf(busid, &serial->intf_ctrl));
|
||||
usbd_add_interface(busid, usbd_cdc_acm_init_intf(busid, &serial->intf_data));
|
||||
usbd_add_endpoint(busid, &cdc_out_ep);
|
||||
usbd_add_endpoint(busid, &cdc_in_ep);
|
||||
|
||||
if (usbd_serial_register(serial, NULL) != RT_EOK) {
|
||||
USB_LOG_ERR("Failed to register serial device\n");
|
||||
usbd_serial_free(serial);
|
||||
return;
|
||||
}
|
||||
|
||||
USB_LOG_INFO("USB CDC ACM Serial Device %s initialized\n", serial->name);
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Copyright (c) 2024, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "usbh_core.h"
|
||||
#include "usbh_msc.h"
|
||||
|
||||
#include "rtthread.h"
|
||||
#include <dfs_fs.h>
|
||||
|
||||
#define DEV_FORMAT "/dev/sd%c"
|
||||
|
||||
#ifndef RT_USING_DFS_ELMFAT
|
||||
#error "RT_USING_DFS_ELMFAT must be enabled to use USB mass storage device"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USB_DFS_MOUNT_POINT
|
||||
#define CONFIG_USB_DFS_MOUNT_POINT "/"
|
||||
#endif
|
||||
|
||||
static rt_err_t rt_udisk_init(rt_device_t dev)
|
||||
{
|
||||
struct usbh_msc *msc_class = (struct usbh_msc *)dev->user_data;
|
||||
|
||||
if (usbh_msc_scsi_init(msc_class) < 0) {
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_ssize_t rt_udisk_read(rt_device_t dev, rt_off_t pos, void *buffer,
|
||||
rt_size_t size)
|
||||
{
|
||||
struct usbh_msc *msc_class = (struct usbh_msc *)dev->user_data;
|
||||
int ret;
|
||||
rt_uint8_t *align_buf;
|
||||
|
||||
align_buf = (rt_uint8_t *)buffer;
|
||||
#ifdef CONFIG_USB_DCACHE_ENABLE
|
||||
if ((uint32_t)buffer & (CONFIG_USB_ALIGN_SIZE - 1)) {
|
||||
align_buf = rt_malloc_align(size * msc_class->blocksize, CONFIG_USB_ALIGN_SIZE);
|
||||
if (!align_buf) {
|
||||
rt_kprintf("msc get align buf failed\n");
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
#endif
|
||||
ret = usbh_msc_scsi_read10(msc_class, pos, (uint8_t *)align_buf, size);
|
||||
if (ret < 0) {
|
||||
rt_kprintf("usb mass_storage read failed\n");
|
||||
return 0;
|
||||
}
|
||||
#ifdef CONFIG_USB_DCACHE_ENABLE
|
||||
if ((uint32_t)buffer & (CONFIG_USB_ALIGN_SIZE - 1)) {
|
||||
usb_memcpy(buffer, align_buf, size * msc_class->blocksize);
|
||||
rt_free_align(align_buf);
|
||||
}
|
||||
#endif
|
||||
return size;
|
||||
}
|
||||
|
||||
static rt_ssize_t rt_udisk_write(rt_device_t dev, rt_off_t pos, const void *buffer,
|
||||
rt_size_t size)
|
||||
{
|
||||
struct usbh_msc *msc_class = (struct usbh_msc *)dev->user_data;
|
||||
int ret;
|
||||
rt_uint8_t *align_buf;
|
||||
|
||||
align_buf = (rt_uint8_t *)buffer;
|
||||
#ifdef CONFIG_USB_DCACHE_ENABLE
|
||||
if ((uint32_t)buffer & (CONFIG_USB_ALIGN_SIZE - 1)) {
|
||||
align_buf = rt_malloc_align(size * msc_class->blocksize, CONFIG_USB_ALIGN_SIZE);
|
||||
if (!align_buf) {
|
||||
rt_kprintf("msc get align buf failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
usb_memcpy(align_buf, buffer, size * msc_class->blocksize);
|
||||
}
|
||||
#endif
|
||||
ret = usbh_msc_scsi_write10(msc_class, pos, (uint8_t *)align_buf, size);
|
||||
if (ret < 0) {
|
||||
rt_kprintf("usb mass_storage write failed\n");
|
||||
return 0;
|
||||
}
|
||||
#ifdef CONFIG_USB_DCACHE_ENABLE
|
||||
if ((uint32_t)buffer & (CONFIG_USB_ALIGN_SIZE - 1)) {
|
||||
rt_free_align(align_buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static rt_err_t rt_udisk_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
/* check parameter */
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
struct usbh_msc *msc_class = (struct usbh_msc *)dev->user_data;
|
||||
|
||||
if (cmd == RT_DEVICE_CTRL_BLK_GETGEOME) {
|
||||
struct rt_device_blk_geometry *geometry;
|
||||
|
||||
geometry = (struct rt_device_blk_geometry *)args;
|
||||
if (geometry == RT_NULL)
|
||||
return -RT_ERROR;
|
||||
|
||||
geometry->bytes_per_sector = msc_class->blocksize;
|
||||
geometry->block_size = msc_class->blocksize;
|
||||
geometry->sector_count = msc_class->blocknum;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
const static struct rt_device_ops udisk_device_ops = {
|
||||
rt_udisk_init,
|
||||
RT_NULL,
|
||||
RT_NULL,
|
||||
rt_udisk_read,
|
||||
rt_udisk_write,
|
||||
rt_udisk_control
|
||||
};
|
||||
#endif
|
||||
|
||||
static void usbh_msc_thread(CONFIG_USB_OSAL_THREAD_SET_ARGV)
|
||||
{
|
||||
struct usbh_msc *msc_class = (struct usbh_msc *)CONFIG_USB_OSAL_THREAD_GET_ARGV;
|
||||
char name[CONFIG_USBHOST_DEV_NAMELEN];
|
||||
char mount_point[CONFIG_USBHOST_DEV_NAMELEN];
|
||||
int ret;
|
||||
|
||||
snprintf(name, CONFIG_USBHOST_DEV_NAMELEN, DEV_FORMAT, msc_class->sdchar);
|
||||
snprintf(mount_point, CONFIG_USBHOST_DEV_NAMELEN, CONFIG_USB_DFS_MOUNT_POINT, msc_class->sdchar);
|
||||
|
||||
ret = dfs_mount(name, mount_point, "elm", 0, 0);
|
||||
if (ret == 0) {
|
||||
rt_kprintf("udisk: %s mount successfully\n", name);
|
||||
} else {
|
||||
rt_kprintf("udisk: %s mount failed, ret = %d\n", name, ret);
|
||||
}
|
||||
|
||||
usb_osal_thread_delete(NULL);
|
||||
}
|
||||
|
||||
void usbh_msc_run(struct usbh_msc *msc_class)
|
||||
{
|
||||
struct rt_device *dev;
|
||||
char name[CONFIG_USBHOST_DEV_NAMELEN];
|
||||
|
||||
dev = rt_malloc(sizeof(struct rt_device));
|
||||
memset(dev, 0, sizeof(struct rt_device));
|
||||
|
||||
snprintf(name, CONFIG_USBHOST_DEV_NAMELEN, DEV_FORMAT, msc_class->sdchar);
|
||||
|
||||
dev->type = RT_Device_Class_Block;
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
dev->ops = &udisk_device_ops;
|
||||
#else
|
||||
dev->init = rt_udisk_init;
|
||||
dev->read = rt_udisk_read;
|
||||
dev->write = rt_udisk_write;
|
||||
dev->control = rt_udisk_control;
|
||||
#endif
|
||||
dev->user_data = msc_class;
|
||||
|
||||
rt_device_register(dev, name, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_REMOVABLE | RT_DEVICE_FLAG_STANDALONE);
|
||||
|
||||
usb_osal_thread_create("usbh_msc", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_msc_thread, msc_class);
|
||||
}
|
||||
|
||||
void usbh_msc_stop(struct usbh_msc *msc_class)
|
||||
{
|
||||
struct rt_device *dev;
|
||||
|
||||
char name[CONFIG_USBHOST_DEV_NAMELEN];
|
||||
char mount_point[CONFIG_USBHOST_DEV_NAMELEN];
|
||||
|
||||
snprintf(name, CONFIG_USBHOST_DEV_NAMELEN, DEV_FORMAT, msc_class->sdchar);
|
||||
snprintf(mount_point, CONFIG_USBHOST_DEV_NAMELEN, CONFIG_USB_DFS_MOUNT_POINT, msc_class->sdchar);
|
||||
|
||||
dfs_unmount(mount_point);
|
||||
dev = rt_device_find(name);
|
||||
if (dev) {
|
||||
rt_device_unregister(dev);
|
||||
rt_free(dev);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,461 @@
|
||||
/*
|
||||
* Copyright (c) 2024, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "netif/etharp.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/tcpip.h"
|
||||
#if LWIP_DHCP
|
||||
#include "lwip/dhcp.h"
|
||||
#include "lwip/prot/dhcp.h"
|
||||
#endif
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include <netif/ethernetif.h>
|
||||
|
||||
#include "usbh_core.h"
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#ifndef RT_USING_LWIP212
|
||||
#error must enable RT_USING_LWIP212
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_NO_RX_THREAD
|
||||
#error must enable LWIP_NO_RX_THREAD, we do not use rtthread eth rx thread
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_NO_TX_THREAD
|
||||
#warning suggest you to enable LWIP_NO_TX_THREAD, we do not use rtthread eth tx thread
|
||||
#endif
|
||||
|
||||
#if LWIP_TCPIP_CORE_LOCKING_INPUT != 1
|
||||
#warning suggest you to set LWIP_TCPIP_CORE_LOCKING_INPUT to 1, usb handles eth input with own thread
|
||||
#endif
|
||||
|
||||
#if LWIP_TCPIP_CORE_LOCKING != 1
|
||||
#error must set LWIP_TCPIP_CORE_LOCKING to 1
|
||||
#endif
|
||||
|
||||
#if PBUF_POOL_BUFSIZE < 1600
|
||||
#error PBUF_POOL_BUFSIZE must be larger than 1600
|
||||
#endif
|
||||
|
||||
#if RT_LWIP_TCPTHREAD_STACKSIZE < 2048
|
||||
#error RT_LWIP_TCPTHREAD_STACKSIZE must be >= 2048
|
||||
#endif
|
||||
|
||||
// #define CONFIG_USBHOST_PLATFORM_CDC_ECM
|
||||
// #define CONFIG_USBHOST_PLATFORM_CDC_RNDIS
|
||||
// #define CONFIG_USBHOST_PLATFORM_CDC_NCM
|
||||
// #define CONFIG_USBHOST_PLATFORM_ASIX
|
||||
// #define CONFIG_USBHOST_PLATFORM_RTL8152
|
||||
|
||||
void usbh_lwip_eth_output_common(struct pbuf *p, uint8_t *buf)
|
||||
{
|
||||
struct pbuf *q;
|
||||
uint8_t *buffer;
|
||||
|
||||
buffer = buf;
|
||||
for (q = p; q != NULL; q = q->next) {
|
||||
usb_memcpy(buffer, q->payload, q->len);
|
||||
buffer += q->len;
|
||||
}
|
||||
}
|
||||
|
||||
void usbh_lwip_eth_input_common(struct netif *netif, uint8_t *buf, uint32_t len)
|
||||
{
|
||||
#if LWIP_TCPIP_CORE_LOCKING_INPUT
|
||||
pbuf_type type = PBUF_REF;
|
||||
#else
|
||||
pbuf_type type = PBUF_POOL;
|
||||
#endif
|
||||
err_t err;
|
||||
struct pbuf *p;
|
||||
|
||||
p = pbuf_alloc(PBUF_RAW, len, type);
|
||||
if (p != NULL) {
|
||||
#if LWIP_TCPIP_CORE_LOCKING_INPUT
|
||||
p->payload = buf;
|
||||
#else
|
||||
usb_memcpy(p->payload, buf, len);
|
||||
#endif
|
||||
err = netif->input(p, netif);
|
||||
if (err != ERR_OK) {
|
||||
pbuf_free(p);
|
||||
}
|
||||
} else {
|
||||
USB_LOG_ERR("No memory to alloc pbuf\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_USBHOST_PLATFORM_CDC_ECM
|
||||
#include "usbh_cdc_ecm.h"
|
||||
|
||||
static struct eth_device g_cdc_ecm_dev;
|
||||
|
||||
static rt_err_t rt_usbh_cdc_ecm_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
struct usbh_cdc_ecm *cdc_ecm_class = (struct usbh_cdc_ecm *)dev->user_data;
|
||||
|
||||
switch (cmd) {
|
||||
case NIOCTL_GADDR:
|
||||
|
||||
/* get mac address */
|
||||
if (args)
|
||||
rt_memcpy(args, cdc_ecm_class->mac, 6);
|
||||
else
|
||||
return -RT_ERROR;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t rt_usbh_cdc_ecm_eth_tx(rt_device_t dev, struct pbuf *p)
|
||||
{
|
||||
int ret;
|
||||
(void)dev;
|
||||
|
||||
usbh_lwip_eth_output_common(p, usbh_cdc_ecm_get_eth_txbuf());
|
||||
ret = usbh_cdc_ecm_eth_output(p->tot_len);
|
||||
if (ret < 0) {
|
||||
return -RT_ERROR;
|
||||
} else {
|
||||
return RT_EOK;
|
||||
}
|
||||
}
|
||||
|
||||
void usbh_cdc_ecm_eth_input(uint8_t *buf, uint32_t buflen)
|
||||
{
|
||||
usbh_lwip_eth_input_common(g_cdc_ecm_dev.netif, buf, buflen);
|
||||
}
|
||||
|
||||
void usbh_cdc_ecm_run(struct usbh_cdc_ecm *cdc_ecm_class)
|
||||
{
|
||||
memset(&g_cdc_ecm_dev, 0, sizeof(struct eth_device));
|
||||
|
||||
g_cdc_ecm_dev.parent.control = rt_usbh_cdc_ecm_control;
|
||||
g_cdc_ecm_dev.eth_rx = NULL;
|
||||
g_cdc_ecm_dev.eth_tx = rt_usbh_cdc_ecm_eth_tx;
|
||||
g_cdc_ecm_dev.parent.user_data = cdc_ecm_class;
|
||||
|
||||
eth_device_init(&g_cdc_ecm_dev, "u0");
|
||||
eth_device_linkchange(&g_cdc_ecm_dev, RT_TRUE);
|
||||
|
||||
usb_osal_thread_create("usbh_cdc_ecm_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_cdc_ecm_rx_thread, NULL);
|
||||
}
|
||||
|
||||
void usbh_cdc_ecm_stop(struct usbh_cdc_ecm *cdc_ecm_class)
|
||||
{
|
||||
(void)cdc_ecm_class;
|
||||
|
||||
eth_device_deinit(&g_cdc_ecm_dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USBHOST_PLATFORM_CDC_RNDIS
|
||||
#include "usbh_rndis.h"
|
||||
|
||||
static struct eth_device g_rndis_dev;
|
||||
|
||||
static rt_timer_t keep_timer = RT_NULL;
|
||||
|
||||
static void rndis_dev_keepalive_timeout(void *parameter)
|
||||
{
|
||||
struct usbh_rndis *rndis_class = (struct usbh_rndis *)parameter;
|
||||
usbh_rndis_keepalive(rndis_class);
|
||||
}
|
||||
|
||||
static void timer_init(struct usbh_rndis *rndis_class)
|
||||
{
|
||||
keep_timer = rt_timer_create("keep",
|
||||
rndis_dev_keepalive_timeout,
|
||||
rndis_class,
|
||||
5000,
|
||||
RT_TIMER_FLAG_PERIODIC |
|
||||
RT_TIMER_FLAG_SOFT_TIMER);
|
||||
|
||||
rt_timer_start(keep_timer);
|
||||
}
|
||||
|
||||
static rt_err_t rt_usbh_rndis_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
struct usbh_rndis *rndis_class = (struct usbh_rndis *)dev->user_data;
|
||||
|
||||
switch (cmd) {
|
||||
case NIOCTL_GADDR:
|
||||
|
||||
/* get mac address */
|
||||
if (args)
|
||||
rt_memcpy(args, rndis_class->mac, 6);
|
||||
else
|
||||
return -RT_ERROR;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t rt_usbh_rndis_eth_tx(rt_device_t dev, struct pbuf *p)
|
||||
{
|
||||
int ret;
|
||||
(void)dev;
|
||||
|
||||
usbh_lwip_eth_output_common(p, usbh_rndis_get_eth_txbuf());
|
||||
ret = usbh_rndis_eth_output(p->tot_len);
|
||||
if (ret < 0) {
|
||||
return -RT_ERROR;
|
||||
} else {
|
||||
return RT_EOK;
|
||||
}
|
||||
}
|
||||
|
||||
void usbh_rndis_eth_input(uint8_t *buf, uint32_t buflen)
|
||||
{
|
||||
usbh_lwip_eth_input_common(g_rndis_dev.netif, buf, buflen);
|
||||
}
|
||||
|
||||
void usbh_rndis_run(struct usbh_rndis *rndis_class)
|
||||
{
|
||||
memset(&g_rndis_dev, 0, sizeof(struct eth_device));
|
||||
|
||||
g_rndis_dev.parent.control = rt_usbh_rndis_control;
|
||||
g_rndis_dev.eth_rx = NULL;
|
||||
g_rndis_dev.eth_tx = rt_usbh_rndis_eth_tx;
|
||||
g_rndis_dev.parent.user_data = rndis_class;
|
||||
|
||||
eth_device_init(&g_rndis_dev, "u2");
|
||||
eth_device_linkchange(&g_rndis_dev, RT_TRUE);
|
||||
|
||||
usb_osal_thread_create("usbh_rndis_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_rndis_rx_thread, NULL);
|
||||
//timer_init(rndis_class);
|
||||
}
|
||||
|
||||
void usbh_rndis_stop(struct usbh_rndis *rndis_class)
|
||||
{
|
||||
(void)rndis_class;
|
||||
|
||||
eth_device_deinit(&g_rndis_dev);
|
||||
// rt_timer_stop(keep_timer);
|
||||
// rt_timer_delete(keep_timer);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USBHOST_PLATFORM_CDC_NCM
|
||||
#include "usbh_cdc_ncm.h"
|
||||
|
||||
static struct eth_device g_cdc_ncm_dev;
|
||||
|
||||
static rt_err_t rt_usbh_cdc_ncm_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
struct usbh_cdc_ncm *cdc_ncm_class = (struct usbh_cdc_ncm *)dev->user_data;
|
||||
|
||||
switch (cmd) {
|
||||
case NIOCTL_GADDR:
|
||||
|
||||
/* get mac address */
|
||||
if (args)
|
||||
rt_memcpy(args, cdc_ncm_class->mac, 6);
|
||||
else
|
||||
return -RT_ERROR;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t rt_usbh_cdc_ncm_eth_tx(rt_device_t dev, struct pbuf *p)
|
||||
{
|
||||
int ret;
|
||||
(void)dev;
|
||||
|
||||
usbh_lwip_eth_output_common(p, usbh_cdc_ncm_get_eth_txbuf());
|
||||
ret = usbh_cdc_ncm_eth_output(p->tot_len);
|
||||
if (ret < 0) {
|
||||
return -RT_ERROR;
|
||||
} else {
|
||||
return RT_EOK;
|
||||
}
|
||||
}
|
||||
|
||||
void usbh_cdc_ncm_eth_input(uint8_t *buf, uint32_t buflen)
|
||||
{
|
||||
usbh_lwip_eth_input_common(g_cdc_ncm_dev.netif, buf, buflen);
|
||||
}
|
||||
|
||||
void usbh_cdc_ncm_run(struct usbh_cdc_ncm *cdc_ncm_class)
|
||||
{
|
||||
memset(&g_cdc_ncm_dev, 0, sizeof(struct eth_device));
|
||||
|
||||
g_cdc_ncm_dev.parent.control = rt_usbh_cdc_ncm_control;
|
||||
g_cdc_ncm_dev.eth_rx = NULL;
|
||||
g_cdc_ncm_dev.eth_tx = rt_usbh_cdc_ncm_eth_tx;
|
||||
g_cdc_ncm_dev.parent.user_data = cdc_ncm_class;
|
||||
|
||||
eth_device_init(&g_cdc_ncm_dev, "u1");
|
||||
eth_device_linkchange(&g_cdc_ncm_dev, RT_TRUE);
|
||||
|
||||
usb_osal_thread_create("usbh_cdc_ncm_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_cdc_ncm_rx_thread, NULL);
|
||||
}
|
||||
|
||||
void usbh_cdc_ncm_stop(struct usbh_cdc_ncm *cdc_ncm_class)
|
||||
{
|
||||
(void)cdc_ncm_class;
|
||||
|
||||
eth_device_deinit(&g_cdc_ncm_dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USBHOST_PLATFORM_ASIX
|
||||
#include "usbh_asix.h"
|
||||
|
||||
static struct eth_device g_asix_dev;
|
||||
|
||||
static rt_err_t rt_usbh_asix_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
struct usbh_asix *asix_class = (struct usbh_asix *)dev->user_data;
|
||||
|
||||
switch (cmd) {
|
||||
case NIOCTL_GADDR:
|
||||
|
||||
/* get mac address */
|
||||
if (args)
|
||||
rt_memcpy(args, asix_class->mac, 6);
|
||||
else
|
||||
return -RT_ERROR;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t rt_usbh_asix_eth_tx(rt_device_t dev, struct pbuf *p)
|
||||
{
|
||||
int ret;
|
||||
(void)dev;
|
||||
|
||||
usbh_lwip_eth_output_common(p, usbh_asix_get_eth_txbuf());
|
||||
ret = usbh_asix_eth_output(p->tot_len);
|
||||
if (ret < 0) {
|
||||
return -RT_ERROR;
|
||||
} else {
|
||||
return RT_EOK;
|
||||
}
|
||||
}
|
||||
|
||||
void usbh_asix_eth_input(uint8_t *buf, uint32_t buflen)
|
||||
{
|
||||
usbh_lwip_eth_input_common(g_asix_dev.netif, buf, buflen);
|
||||
}
|
||||
|
||||
void usbh_asix_run(struct usbh_asix *asix_class)
|
||||
{
|
||||
memset(&g_asix_dev, 0, sizeof(struct eth_device));
|
||||
|
||||
g_asix_dev.parent.control = rt_usbh_asix_control;
|
||||
g_asix_dev.eth_rx = NULL;
|
||||
g_asix_dev.eth_tx = rt_usbh_asix_eth_tx;
|
||||
g_asix_dev.parent.user_data = asix_class;
|
||||
|
||||
eth_device_init(&g_asix_dev, "u3");
|
||||
eth_device_linkchange(&g_asix_dev, RT_TRUE);
|
||||
|
||||
usb_osal_thread_create("usbh_asix_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_asix_rx_thread, NULL);
|
||||
}
|
||||
|
||||
void usbh_asix_stop(struct usbh_asix *asix_class)
|
||||
{
|
||||
(void)asix_class;
|
||||
|
||||
eth_device_deinit(&g_asix_dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USBHOST_PLATFORM_RTL8152
|
||||
#include "usbh_rtl8152.h"
|
||||
|
||||
static struct eth_device g_rtl8152_dev;
|
||||
|
||||
static rt_err_t rt_usbh_rtl8152_control(rt_device_t dev, int cmd, void *args)
|
||||
{
|
||||
struct usbh_rtl8152 *rtl8152_class = (struct usbh_rtl8152 *)dev->user_data;
|
||||
|
||||
switch (cmd) {
|
||||
case NIOCTL_GADDR:
|
||||
|
||||
/* get mac address */
|
||||
if (args)
|
||||
rt_memcpy(args, rtl8152_class->mac, 6);
|
||||
else
|
||||
return -RT_ERROR;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t rt_usbh_rtl8152_eth_tx(rt_device_t dev, struct pbuf *p)
|
||||
{
|
||||
int ret;
|
||||
(void)dev;
|
||||
|
||||
usbh_lwip_eth_output_common(p, usbh_rtl8152_get_eth_txbuf());
|
||||
ret = usbh_rtl8152_eth_output(p->tot_len);
|
||||
if (ret < 0) {
|
||||
return -RT_ERROR;
|
||||
} else {
|
||||
return RT_EOK;
|
||||
}
|
||||
}
|
||||
|
||||
void usbh_rtl8152_eth_input(uint8_t *buf, uint32_t buflen)
|
||||
{
|
||||
usbh_lwip_eth_input_common(g_rtl8152_dev.netif, buf, buflen);
|
||||
}
|
||||
|
||||
void usbh_rtl8152_run(struct usbh_rtl8152 *rtl8152_class)
|
||||
{
|
||||
memset(&g_rtl8152_dev, 0, sizeof(struct eth_device));
|
||||
|
||||
g_rtl8152_dev.parent.control = rt_usbh_rtl8152_control;
|
||||
g_rtl8152_dev.eth_rx = NULL;
|
||||
g_rtl8152_dev.eth_tx = rt_usbh_rtl8152_eth_tx;
|
||||
g_rtl8152_dev.parent.user_data = rtl8152_class;
|
||||
|
||||
eth_device_init(&g_rtl8152_dev, "u4");
|
||||
eth_device_linkchange(&g_rtl8152_dev, RT_TRUE);
|
||||
|
||||
usb_osal_thread_create("usbh_rtl8152_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_rtl8152_rx_thread, NULL);
|
||||
}
|
||||
|
||||
void usbh_rtl8152_stop(struct usbh_rtl8152 *rtl8152_class)
|
||||
{
|
||||
(void)rtl8152_class;
|
||||
|
||||
eth_device_deinit(&g_rtl8152_dev);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,914 @@
|
||||
/*
|
||||
* Copyright (c) 2025, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
#include "usbh_core.h"
|
||||
#include "usbh_cdc_acm.h"
|
||||
#include "usbh_ftdi.h"
|
||||
#include "usbh_cp210x.h"
|
||||
#include "usbh_ch34x.h"
|
||||
#include "usbh_pl2303.h"
|
||||
|
||||
#define DEV_FORMAT_VENDOR "ttyUSB%d"
|
||||
#define DEV_FORMAT_CDC_ACM "ttyACM%d"
|
||||
|
||||
#define USBH_RX_MAX_SIZE 2048
|
||||
|
||||
#ifndef CONFIG_USBHOST_MAX_VENDOR_SERIAL_CLASS
|
||||
#define CONFIG_USBHOST_MAX_VENDOR_SERIAL_CLASS (4)
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_USBHOST_SERIAL_RX_BUFSIZE
|
||||
#define CONFIG_USBHOST_SERIAL_RX_BUFSIZE (USBH_RX_MAX_SIZE * 2)
|
||||
#endif
|
||||
|
||||
enum usbh_serial_type {
|
||||
USBH_SERIAL_TYPE_CDC_ACM = 0,
|
||||
USBH_SERIAL_TYPE_FTDI,
|
||||
USBH_SERIAL_TYPE_CP210X,
|
||||
USBH_SERIAL_TYPE_CH34X,
|
||||
USBH_SERIAL_TYPE_PL2303,
|
||||
};
|
||||
|
||||
struct usbh_serial {
|
||||
struct rt_device parent;
|
||||
enum usbh_serial_type type;
|
||||
uint8_t minor;
|
||||
char name[CONFIG_USBHOST_DEV_NAMELEN];
|
||||
struct rt_ringbuffer rx_rb;
|
||||
rt_uint8_t rx_rb_buffer[CONFIG_USBHOST_SERIAL_RX_BUFSIZE];
|
||||
};
|
||||
|
||||
static uint32_t g_devinuse_vendor = 0;
|
||||
static uint32_t g_devinuse_cdc_acm = 0;
|
||||
|
||||
static USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_usbh_serial_vendor_rx_buf[CONFIG_USBHOST_MAX_VENDOR_SERIAL_CLASS][USB_ALIGN_UP(USBH_RX_MAX_SIZE, CONFIG_USB_ALIGN_SIZE)];
|
||||
static USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_usbh_serial_cdc_acm_rx_buf[CONFIG_USBHOST_MAX_CDC_ACM_CLASS][USB_ALIGN_UP(USBH_RX_MAX_SIZE, CONFIG_USB_ALIGN_SIZE)];
|
||||
|
||||
static struct usbh_serial *usbh_serial_alloc(uint8_t type)
|
||||
{
|
||||
uint8_t devno;
|
||||
struct usbh_serial *serial;
|
||||
|
||||
for (devno = 0; devno < CONFIG_USBHOST_MAX_VENDOR_SERIAL_CLASS; devno++) {
|
||||
if ((g_devinuse_vendor & (1U << devno)) == 0) {
|
||||
g_devinuse_vendor |= (1U << devno);
|
||||
|
||||
serial = rt_malloc(sizeof(struct usbh_serial));
|
||||
memset(serial, 0, sizeof(struct usbh_serial));
|
||||
serial->type = type;
|
||||
serial->minor = devno;
|
||||
snprintf(serial->name, CONFIG_USBHOST_DEV_NAMELEN, DEV_FORMAT_VENDOR, serial->minor);
|
||||
return serial;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void usbh_serial_free(struct usbh_serial *serial)
|
||||
{
|
||||
uint8_t devno = serial->minor;
|
||||
|
||||
if (devno < 32) {
|
||||
g_devinuse_vendor &= ~(1U << devno);
|
||||
}
|
||||
memset(serial, 0, sizeof(struct usbh_serial));
|
||||
rt_free(serial);
|
||||
}
|
||||
|
||||
static struct usbh_serial *usbh_serial_cdc_acm_alloc(uint8_t type)
|
||||
{
|
||||
uint8_t devno;
|
||||
struct usbh_serial *serial;
|
||||
|
||||
for (devno = 0; devno < CONFIG_USBHOST_MAX_CDC_ACM_CLASS; devno++) {
|
||||
if ((g_devinuse_cdc_acm & (1U << devno)) == 0) {
|
||||
g_devinuse_cdc_acm |= (1U << devno);
|
||||
|
||||
serial = rt_malloc(sizeof(struct usbh_serial));
|
||||
memset(serial, 0, sizeof(struct usbh_serial));
|
||||
serial->type = type;
|
||||
serial->minor = devno;
|
||||
snprintf(serial->name, CONFIG_USBHOST_DEV_NAMELEN, DEV_FORMAT_CDC_ACM, serial->minor);
|
||||
return serial;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void usbh_serial_cdc_acm_free(struct usbh_serial *serial)
|
||||
{
|
||||
uint8_t devno = serial->minor;
|
||||
|
||||
if (devno < 32) {
|
||||
g_devinuse_cdc_acm &= ~(1U << devno);
|
||||
}
|
||||
memset(serial, 0, sizeof(struct usbh_serial));
|
||||
rt_free(serial);
|
||||
}
|
||||
|
||||
static rt_err_t usbh_serial_open(struct rt_device *dev, rt_uint16_t oflag)
|
||||
{
|
||||
struct usbh_serial *serial;
|
||||
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
serial = (struct usbh_serial *)dev;
|
||||
|
||||
switch (serial->type) {
|
||||
case USBH_SERIAL_TYPE_CDC_ACM:
|
||||
break;
|
||||
case USBH_SERIAL_TYPE_FTDI:
|
||||
break;
|
||||
case USBH_SERIAL_TYPE_CP210X:
|
||||
break;
|
||||
case USBH_SERIAL_TYPE_CH34X:
|
||||
break;
|
||||
case USBH_SERIAL_TYPE_PL2303:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_err_t usbh_serial_close(struct rt_device *dev)
|
||||
{
|
||||
struct usbh_serial *serial;
|
||||
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
serial = (struct usbh_serial *)dev;
|
||||
|
||||
switch (serial->type) {
|
||||
case USBH_SERIAL_TYPE_CDC_ACM:
|
||||
break;
|
||||
case USBH_SERIAL_TYPE_FTDI:
|
||||
break;
|
||||
case USBH_SERIAL_TYPE_CP210X:
|
||||
break;
|
||||
case USBH_SERIAL_TYPE_CH34X:
|
||||
break;
|
||||
case USBH_SERIAL_TYPE_PL2303:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
static rt_ssize_t usbh_serial_read(struct rt_device *dev,
|
||||
rt_off_t pos,
|
||||
void *buffer,
|
||||
rt_size_t size)
|
||||
{
|
||||
struct usbh_serial *serial;
|
||||
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
serial = (struct usbh_serial *)dev;
|
||||
|
||||
return rt_ringbuffer_get(&serial->rx_rb, (rt_uint8_t *)buffer, size);
|
||||
}
|
||||
|
||||
static rt_ssize_t usbh_serial_write(struct rt_device *dev,
|
||||
rt_off_t pos,
|
||||
const void *buffer,
|
||||
rt_size_t size)
|
||||
{
|
||||
struct usbh_serial *serial;
|
||||
int ret = 0;
|
||||
rt_uint8_t *align_buf;
|
||||
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
serial = (struct usbh_serial *)dev;
|
||||
|
||||
align_buf = (rt_uint8_t *)buffer;
|
||||
#ifdef CONFIG_USB_DCACHE_ENABLE
|
||||
if ((uint32_t)buffer & (CONFIG_USB_ALIGN_SIZE - 1)) {
|
||||
align_buf = rt_malloc_align(size, CONFIG_USB_ALIGN_SIZE);
|
||||
if (!align_buf) {
|
||||
USB_LOG_ERR("serial get align buf failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
usb_memcpy(align_buf, buffer, size);
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (serial->type) {
|
||||
#if defined(PKG_CHERRYUSB_HOST_CDC_ACM) || defined(RT_CHERRYUSB_HOST_CDC_ACM)
|
||||
case USBH_SERIAL_TYPE_CDC_ACM:
|
||||
ret = usbh_cdc_acm_bulk_out_transfer((struct usbh_cdc_acm *)dev->user_data, (uint8_t *)align_buf, size, RT_WAITING_FOREVER);
|
||||
if (ret < 0) {
|
||||
USB_LOG_ERR("usbh_cdc_acm_bulk_out_transfer failed: %d\n", ret);
|
||||
#ifdef CONFIG_USB_DCACHE_ENABLE
|
||||
rt_free_align(align_buf);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if defined(PKG_CHERRYUSB_HOST_FTDI) || defined(RT_CHERRYUSB_HOST_FTDI)
|
||||
case USBH_SERIAL_TYPE_FTDI:
|
||||
ret = usbh_ftdi_bulk_out_transfer((struct usbh_ftdi *)dev->user_data, (uint8_t *)align_buf, size, RT_WAITING_FOREVER);
|
||||
if (ret < 0) {
|
||||
USB_LOG_ERR("usbh_ftdi_bulk_out_transfer failed: %d\n", ret);
|
||||
#ifdef CONFIG_USB_DCACHE_ENABLE
|
||||
rt_free_align(align_buf);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if defined(PKG_CHERRYUSB_HOST_CH34X) || defined(RT_CHERRYUSB_HOST_CH34X)
|
||||
case USBH_SERIAL_TYPE_CH34X:
|
||||
ret = usbh_ch34x_bulk_out_transfer((struct usbh_ch34x *)dev->user_data, (uint8_t *)align_buf, size, RT_WAITING_FOREVER);
|
||||
if (ret < 0) {
|
||||
USB_LOG_ERR("usbh_ch34x_bulk_out_transfer failed: %d\n", ret);
|
||||
#ifdef CONFIG_USB_DCACHE_ENABLE
|
||||
rt_free_align(align_buf);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if defined(PKG_CHERRYUSB_HOST_PL2303) || defined(RT_CHERRYUSB_HOST_PL2303)
|
||||
case USBH_SERIAL_TYPE_PL2303:
|
||||
ret = usbh_pl2303_bulk_out_transfer((struct usbh_pl2303 *)dev->user_data, (uint8_t *)align_buf, size, RT_WAITING_FOREVER);
|
||||
if (ret < 0) {
|
||||
USB_LOG_ERR("usbh_pl2303_bulk_out_transfer failed: %d\n", ret);
|
||||
#ifdef CONFIG_USB_DCACHE_ENABLE
|
||||
rt_free_align(align_buf);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_USB_DCACHE_ENABLE
|
||||
if ((uint32_t)buffer & (CONFIG_USB_ALIGN_SIZE - 1)) {
|
||||
rt_free_align(align_buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static rt_err_t usbh_serial_control(struct rt_device *dev,
|
||||
int cmd,
|
||||
void *args)
|
||||
{
|
||||
struct usbh_serial *serial;
|
||||
struct serial_configure *config;
|
||||
struct cdc_line_coding line_coding;
|
||||
int ret = -RT_EINVAL;
|
||||
|
||||
RT_ASSERT(dev != RT_NULL);
|
||||
|
||||
serial = (struct usbh_serial *)dev;
|
||||
|
||||
switch (serial->type) {
|
||||
#if defined(PKG_CHERRYUSB_HOST_CDC_ACM) || defined(RT_CHERRYUSB_HOST_CDC_ACM)
|
||||
case USBH_SERIAL_TYPE_CDC_ACM:
|
||||
if (cmd == RT_DEVICE_CTRL_CONFIG) {
|
||||
struct usbh_cdc_acm *cdc_acm_class;
|
||||
cdc_acm_class = (struct usbh_cdc_acm *)dev->user_data;
|
||||
|
||||
config = (struct serial_configure *)args;
|
||||
|
||||
line_coding.dwDTERate = config->baud_rate;
|
||||
line_coding.bDataBits = config->data_bits;
|
||||
line_coding.bCharFormat = 0; // STOP_BITS_1
|
||||
line_coding.bParityType = config->parity;
|
||||
|
||||
usbh_cdc_acm_set_line_coding(cdc_acm_class, &line_coding);
|
||||
}
|
||||
|
||||
ret = RT_EOK;
|
||||
break;
|
||||
#endif
|
||||
#if defined(PKG_CHERRYUSB_HOST_FTDI) || defined(RT_CHERRYUSB_HOST_FTDI)
|
||||
case USBH_SERIAL_TYPE_FTDI:
|
||||
if (cmd == RT_DEVICE_CTRL_CONFIG) {
|
||||
struct usbh_ftdi *ftdi_class;
|
||||
ftdi_class = (struct usbh_ftdi *)dev->user_data;
|
||||
|
||||
config = (struct serial_configure *)args;
|
||||
|
||||
line_coding.dwDTERate = config->baud_rate;
|
||||
line_coding.bDataBits = config->data_bits;
|
||||
line_coding.bCharFormat = 0; // STOP_BITS_1
|
||||
line_coding.bParityType = config->parity;
|
||||
|
||||
usbh_ftdi_set_line_coding(ftdi_class, &line_coding);
|
||||
}
|
||||
|
||||
ret = RT_EOK;
|
||||
break;
|
||||
#endif
|
||||
#if defined(PKG_CHERRYUSB_HOST_CP210X) || defined(RT_CHERRYUSB_HOST_CP210X)
|
||||
case USBH_SERIAL_TYPE_CP210X:
|
||||
if (cmd == RT_DEVICE_CTRL_CONFIG) {
|
||||
struct usbh_cp210x *cp210x_class;
|
||||
cp210x_class = (struct usbh_cp210x *)dev->user_data;
|
||||
|
||||
config = (struct serial_configure *)args;
|
||||
|
||||
line_coding.dwDTERate = config->baud_rate;
|
||||
line_coding.bDataBits = config->data_bits;
|
||||
line_coding.bCharFormat = 0; // STOP_BITS_1
|
||||
line_coding.bParityType = config->parity;
|
||||
|
||||
usbh_cp210x_set_line_coding(cp210x_class, &line_coding);
|
||||
}
|
||||
|
||||
ret = RT_EOK;
|
||||
break;
|
||||
#endif
|
||||
#if defined(PKG_CHERRYUSB_HOST_CH34X) || defined(RT_CHERRYUSB_HOST_CH34X)
|
||||
case USBH_SERIAL_TYPE_CH34X:
|
||||
if (cmd == RT_DEVICE_CTRL_CONFIG) {
|
||||
struct usbh_ch34x *ch34x_class;
|
||||
ch34x_class = (struct usbh_ch34x *)dev->user_data;
|
||||
|
||||
config = (struct serial_configure *)args;
|
||||
|
||||
line_coding.dwDTERate = config->baud_rate;
|
||||
line_coding.bDataBits = config->data_bits;
|
||||
line_coding.bCharFormat = 0; // STOP_BITS_1
|
||||
line_coding.bParityType = config->parity;
|
||||
|
||||
usbh_ch34x_set_line_coding(ch34x_class, &line_coding);
|
||||
}
|
||||
|
||||
ret = RT_EOK;
|
||||
break;
|
||||
#endif
|
||||
#if defined(PKG_CHERRYUSB_HOST_PL2303) || defined(RT_CHERRYUSB_HOST_PL2303)
|
||||
case USBH_SERIAL_TYPE_PL2303:
|
||||
if (cmd == RT_DEVICE_CTRL_CONFIG) {
|
||||
struct usbh_pl2303 *pl2303_class;
|
||||
pl2303_class = (struct usbh_pl2303 *)dev->user_data;
|
||||
|
||||
config = (struct serial_configure *)args;
|
||||
|
||||
line_coding.dwDTERate = config->baud_rate;
|
||||
line_coding.bDataBits = config->data_bits;
|
||||
line_coding.bCharFormat = 0; // STOP_BITS_1
|
||||
line_coding.bParityType = config->parity;
|
||||
|
||||
usbh_pl2303_set_line_coding(pl2303_class, &line_coding);
|
||||
}
|
||||
|
||||
ret = RT_EOK;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
const static struct rt_device_ops usbh_serial_ops = {
|
||||
NULL,
|
||||
usbh_serial_open,
|
||||
usbh_serial_close,
|
||||
usbh_serial_read,
|
||||
usbh_serial_write,
|
||||
usbh_serial_control
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_POSIX_DEVIO
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <dfs_file.h>
|
||||
|
||||
#ifdef RT_USING_POSIX_TERMIOS
|
||||
#include <termios.h>
|
||||
#endif
|
||||
|
||||
static rt_err_t usbh_serial_fops_rx_ind(rt_device_t dev, rt_size_t size)
|
||||
{
|
||||
rt_wqueue_wakeup(&(dev->wait_queue), (void*)POLLIN);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
/* fops for serial */
|
||||
static int usbh_serial_fops_open(struct dfs_file *fd)
|
||||
{
|
||||
rt_err_t ret = 0;
|
||||
rt_uint16_t flags = 0;
|
||||
rt_device_t device;
|
||||
|
||||
device = (rt_device_t)fd->vnode->data;
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
|
||||
switch (fd->flags & O_ACCMODE)
|
||||
{
|
||||
case O_RDONLY:
|
||||
USB_LOG_DBG("fops open: O_RDONLY!");
|
||||
flags = RT_DEVICE_FLAG_RDONLY;
|
||||
break;
|
||||
case O_WRONLY:
|
||||
USB_LOG_DBG("fops open: O_WRONLY!");
|
||||
flags = RT_DEVICE_FLAG_WRONLY;
|
||||
break;
|
||||
case O_RDWR:
|
||||
USB_LOG_DBG("fops open: O_RDWR!");
|
||||
flags = RT_DEVICE_FLAG_RDWR;
|
||||
break;
|
||||
default:
|
||||
USB_LOG_ERR("fops open: unknown mode - %d!", fd->flags & O_ACCMODE);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((fd->flags & O_ACCMODE) != O_WRONLY)
|
||||
rt_device_set_rx_indicate(device, usbh_serial_fops_rx_ind);
|
||||
ret = rt_device_open(device, flags);
|
||||
if (ret == RT_EOK) return 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int usbh_serial_fops_close(struct dfs_file *fd)
|
||||
{
|
||||
rt_device_t device;
|
||||
|
||||
device = (rt_device_t)fd->vnode->data;
|
||||
|
||||
rt_device_set_rx_indicate(device, RT_NULL);
|
||||
rt_device_close(device);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int usbh_serial_fops_ioctl(struct dfs_file *fd, int cmd, void *args)
|
||||
{
|
||||
rt_device_t device;
|
||||
int flags = (int)(rt_base_t)args;
|
||||
int mask = O_NONBLOCK | O_APPEND;
|
||||
|
||||
device = (rt_device_t)fd->vnode->data;
|
||||
switch (cmd)
|
||||
{
|
||||
case FIONREAD:
|
||||
break;
|
||||
case FIONWRITE:
|
||||
break;
|
||||
case F_SETFL:
|
||||
flags &= mask;
|
||||
fd->flags &= ~mask;
|
||||
fd->flags |= flags;
|
||||
break;
|
||||
}
|
||||
|
||||
return rt_device_control(device, cmd, args);
|
||||
}
|
||||
|
||||
static int usbh_serial_fops_read(struct dfs_file *fd, void *buf, size_t count)
|
||||
{
|
||||
int size = 0;
|
||||
rt_device_t device;
|
||||
|
||||
device = (rt_device_t)fd->vnode->data;
|
||||
|
||||
do
|
||||
{
|
||||
size = rt_device_read(device, -1, buf, count);
|
||||
if (size <= 0)
|
||||
{
|
||||
if (fd->flags & O_NONBLOCK)
|
||||
{
|
||||
size = -EAGAIN;
|
||||
break;
|
||||
}
|
||||
|
||||
rt_wqueue_wait(&(device->wait_queue), 0, RT_WAITING_FOREVER);
|
||||
}
|
||||
}while (size <= 0);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static int usbh_serial_fops_write(struct dfs_file *fd, const void *buf, size_t count)
|
||||
{
|
||||
rt_device_t device;
|
||||
|
||||
device = (rt_device_t)fd->vnode->data;
|
||||
return rt_device_write(device, -1, buf, count);
|
||||
}
|
||||
|
||||
static int usbh_serial_fops_poll(struct dfs_file *fd, struct rt_pollreq *req)
|
||||
{
|
||||
int mask = 0;
|
||||
int flags = 0;
|
||||
rt_device_t device;
|
||||
struct usbh_serial *serial;
|
||||
|
||||
device = (rt_device_t)fd->vnode->data;
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
|
||||
serial = (struct usbh_serial *)device;
|
||||
|
||||
/* only support POLLIN */
|
||||
flags = fd->flags & O_ACCMODE;
|
||||
if (flags == O_RDONLY || flags == O_RDWR)
|
||||
{
|
||||
rt_base_t level;
|
||||
|
||||
rt_poll_add(&(device->wait_queue), req);
|
||||
|
||||
level = rt_hw_interrupt_disable();
|
||||
|
||||
if (rt_ringbuffer_data_len(&serial->rx_rb))
|
||||
mask |= POLLIN;
|
||||
rt_hw_interrupt_enable(level);
|
||||
}
|
||||
// mask|=POLLOUT;
|
||||
return mask;
|
||||
}
|
||||
|
||||
const static struct dfs_file_ops usbh_serial_fops =
|
||||
{
|
||||
usbh_serial_fops_open,
|
||||
usbh_serial_fops_close,
|
||||
usbh_serial_fops_ioctl,
|
||||
usbh_serial_fops_read,
|
||||
usbh_serial_fops_write,
|
||||
RT_NULL, /* flush */
|
||||
RT_NULL, /* lseek */
|
||||
RT_NULL, /* getdents */
|
||||
usbh_serial_fops_poll,
|
||||
};
|
||||
#endif /* RT_USING_POSIX_DEVIO */
|
||||
|
||||
rt_err_t usbh_serial_register(struct usbh_serial *serial,
|
||||
void *data)
|
||||
{
|
||||
rt_err_t ret;
|
||||
struct rt_device *device;
|
||||
RT_ASSERT(serial != RT_NULL);
|
||||
|
||||
device = &(serial->parent);
|
||||
|
||||
device->type = RT_Device_Class_Char;
|
||||
device->rx_indicate = RT_NULL;
|
||||
device->tx_complete = RT_NULL;
|
||||
|
||||
#ifdef RT_USING_DEVICE_OPS
|
||||
device->ops = &usbh_serial_ops;
|
||||
#else
|
||||
device->init = NULL;
|
||||
device->open = usbh_serial_open;
|
||||
device->close = usbh_serial_close;
|
||||
device->read = usbh_serial_read;
|
||||
device->write = usbh_serial_write;
|
||||
device->control = usbh_serial_control;
|
||||
#endif
|
||||
device->user_data = data;
|
||||
|
||||
/* register a character device */
|
||||
ret = rt_device_register(device, serial->name, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_REMOVABLE);
|
||||
|
||||
#ifdef RT_USING_POSIX_DEVIO
|
||||
/* set fops */
|
||||
device->fops = &usbh_serial_fops;
|
||||
#endif
|
||||
rt_ringbuffer_init(&serial->rx_rb, serial->rx_rb_buffer, sizeof(serial->rx_rb_buffer));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void usbh_serial_unregister(struct usbh_serial *serial)
|
||||
{
|
||||
RT_ASSERT(serial != NULL);
|
||||
|
||||
rt_device_unregister(&serial->parent);
|
||||
|
||||
if (serial->type == USBH_SERIAL_TYPE_CDC_ACM) {
|
||||
usbh_serial_cdc_acm_free(serial);
|
||||
} else {
|
||||
usbh_serial_free(serial);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(PKG_CHERRYUSB_HOST_CDC_ACM) || defined(RT_CHERRYUSB_HOST_CDC_ACM)
|
||||
void usbh_cdc_acm_callback(void *arg, int nbytes)
|
||||
{
|
||||
struct usbh_cdc_acm *cdc_acm_class = (struct usbh_cdc_acm *)arg;
|
||||
struct usbh_serial *serial;
|
||||
int ret;
|
||||
struct usbh_urb *urb = &cdc_acm_class->bulkin_urb;
|
||||
|
||||
if (nbytes > 0) {
|
||||
serial = (struct usbh_serial *)cdc_acm_class->user_data;
|
||||
rt_ringbuffer_put(&serial->rx_rb, g_usbh_serial_cdc_acm_rx_buf[serial->minor], nbytes);
|
||||
|
||||
if (serial->parent.rx_indicate) {
|
||||
serial->parent.rx_indicate(&serial->parent, nbytes);
|
||||
}
|
||||
|
||||
usbh_bulk_urb_fill(urb, cdc_acm_class->hport, cdc_acm_class->bulkin, g_usbh_serial_cdc_acm_rx_buf[serial->minor], sizeof(g_usbh_serial_cdc_acm_rx_buf[serial->minor]), 0, usbh_cdc_acm_callback, cdc_acm_class);
|
||||
ret = usbh_submit_urb(urb);
|
||||
if (ret < 0) {
|
||||
USB_LOG_ERR("usbh_submit_urb failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void usbh_cdc_acm_run(struct usbh_cdc_acm *cdc_acm_class)
|
||||
{
|
||||
struct usbh_serial *serial;
|
||||
int ret;
|
||||
struct usbh_urb *urb = &cdc_acm_class->bulkin_urb;
|
||||
|
||||
serial = usbh_serial_cdc_acm_alloc(USBH_SERIAL_TYPE_CDC_ACM);
|
||||
cdc_acm_class->user_data = serial;
|
||||
|
||||
usbh_serial_register(serial, cdc_acm_class);
|
||||
|
||||
struct cdc_line_coding linecoding;
|
||||
linecoding.dwDTERate = 115200;
|
||||
linecoding.bDataBits = 8;
|
||||
linecoding.bParityType = 0;
|
||||
linecoding.bCharFormat = 0;
|
||||
usbh_cdc_acm_set_line_coding(cdc_acm_class, &linecoding);
|
||||
|
||||
usbh_bulk_urb_fill(urb, cdc_acm_class->hport, cdc_acm_class->bulkin, g_usbh_serial_cdc_acm_rx_buf[serial->minor], sizeof(g_usbh_serial_cdc_acm_rx_buf[serial->minor]), 0, usbh_cdc_acm_callback, cdc_acm_class);
|
||||
ret = usbh_submit_urb(urb);
|
||||
if (ret < 0) {
|
||||
USB_LOG_ERR("usbh_submit_urb failed: %d\n", ret);
|
||||
usbh_serial_unregister(serial);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void usbh_cdc_acm_stop(struct usbh_cdc_acm *cdc_acm_class)
|
||||
{
|
||||
struct usbh_serial *serial;
|
||||
|
||||
serial = (struct usbh_serial *)cdc_acm_class->user_data;
|
||||
usbh_serial_unregister(serial);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PKG_CHERRYUSB_HOST_FTDI) || defined(RT_CHERRYUSB_HOST_FTDI)
|
||||
void usbh_ftdi_callback(void *arg, int nbytes)
|
||||
{
|
||||
struct usbh_ftdi *ftdi_class = (struct usbh_ftdi *)arg;
|
||||
struct usbh_serial *serial;
|
||||
int ret;
|
||||
struct usbh_urb *urb = &ftdi_class->bulkin_urb;
|
||||
|
||||
if (nbytes >= 2) {
|
||||
serial = (struct usbh_serial *)ftdi_class->user_data;
|
||||
|
||||
nbytes -= 2; // Skip the first two bytes (header)
|
||||
rt_ringbuffer_put(&serial->rx_rb, &g_usbh_serial_vendor_rx_buf[serial->minor][2], nbytes);
|
||||
|
||||
if (serial->parent.rx_indicate && nbytes) {
|
||||
serial->parent.rx_indicate(&serial->parent, nbytes);
|
||||
}
|
||||
|
||||
usbh_bulk_urb_fill(urb, ftdi_class->hport, ftdi_class->bulkin, g_usbh_serial_vendor_rx_buf[serial->minor], sizeof(g_usbh_serial_vendor_rx_buf[serial->minor]), 0, usbh_ftdi_callback, ftdi_class);
|
||||
ret = usbh_submit_urb(urb);
|
||||
if (ret < 0) {
|
||||
USB_LOG_ERR("usbh_submit_urb failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void usbh_ftdi_run(struct usbh_ftdi *ftdi_class)
|
||||
{
|
||||
struct usbh_serial *serial;
|
||||
int ret;
|
||||
struct usbh_urb *urb = &ftdi_class->bulkin_urb;
|
||||
|
||||
serial = usbh_serial_alloc(USBH_SERIAL_TYPE_FTDI);
|
||||
ftdi_class->user_data = serial;
|
||||
|
||||
usbh_serial_register(serial, ftdi_class);
|
||||
|
||||
struct cdc_line_coding linecoding;
|
||||
linecoding.dwDTERate = 115200;
|
||||
linecoding.bDataBits = 8;
|
||||
linecoding.bParityType = 0;
|
||||
linecoding.bCharFormat = 0;
|
||||
usbh_ftdi_set_line_coding(ftdi_class, &linecoding);
|
||||
|
||||
usbh_bulk_urb_fill(urb, ftdi_class->hport, ftdi_class->bulkin, g_usbh_serial_vendor_rx_buf[serial->minor], sizeof(g_usbh_serial_vendor_rx_buf[serial->minor]), 0, usbh_ftdi_callback, ftdi_class);
|
||||
ret = usbh_submit_urb(urb);
|
||||
if (ret < 0) {
|
||||
USB_LOG_ERR("usbh_submit_urb failed: %d\n", ret);
|
||||
usbh_serial_unregister(serial);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void usbh_ftdi_stop(struct usbh_ftdi *ftdi_class)
|
||||
{
|
||||
struct usbh_serial *serial;
|
||||
|
||||
serial = (struct usbh_serial *)ftdi_class->user_data;
|
||||
usbh_serial_unregister(serial);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PKG_CHERRYUSB_HOST_CH34X) || defined(RT_CHERRYUSB_HOST_CH34X)
|
||||
void usbh_ch34x_callback(void *arg, int nbytes)
|
||||
{
|
||||
struct usbh_ch34x *ch34x_class = (struct usbh_ch34x *)arg;
|
||||
struct usbh_serial *serial;
|
||||
int ret;
|
||||
struct usbh_urb *urb = &ch34x_class->bulkin_urb;
|
||||
|
||||
if (nbytes > 0) {
|
||||
serial = (struct usbh_serial *)ch34x_class->user_data;
|
||||
rt_ringbuffer_put(&serial->rx_rb, g_usbh_serial_vendor_rx_buf[serial->minor], nbytes);
|
||||
|
||||
if (serial->parent.rx_indicate) {
|
||||
serial->parent.rx_indicate(&serial->parent, nbytes);
|
||||
}
|
||||
|
||||
usbh_bulk_urb_fill(urb, ch34x_class->hport, ch34x_class->bulkin, g_usbh_serial_vendor_rx_buf[serial->minor], sizeof(g_usbh_serial_vendor_rx_buf[serial->minor]), 0, usbh_ch34x_callback, ch34x_class);
|
||||
ret = usbh_submit_urb(urb);
|
||||
if (ret < 0) {
|
||||
USB_LOG_ERR("usbh_submit_urb failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void usbh_ch34x_run(struct usbh_ch34x *ch34x_class)
|
||||
{
|
||||
struct usbh_serial *serial;
|
||||
int ret;
|
||||
struct usbh_urb *urb = &ch34x_class->bulkin_urb;
|
||||
|
||||
serial = usbh_serial_alloc(USBH_SERIAL_TYPE_CH34X);
|
||||
ch34x_class->user_data = serial;
|
||||
|
||||
usbh_serial_register(serial, ch34x_class);
|
||||
|
||||
struct cdc_line_coding linecoding;
|
||||
linecoding.dwDTERate = 115200;
|
||||
linecoding.bDataBits = 8;
|
||||
linecoding.bParityType = 0;
|
||||
linecoding.bCharFormat = 0;
|
||||
usbh_ch34x_set_line_coding(ch34x_class, &linecoding);
|
||||
|
||||
usbh_bulk_urb_fill(urb, ch34x_class->hport, ch34x_class->bulkin, g_usbh_serial_vendor_rx_buf[serial->minor], sizeof(g_usbh_serial_vendor_rx_buf[serial->minor]), 0, usbh_ch34x_callback, ch34x_class);
|
||||
ret = usbh_submit_urb(urb);
|
||||
if (ret < 0) {
|
||||
USB_LOG_ERR("usbh_submit_urb failed: %d\n", ret);
|
||||
usbh_serial_unregister(serial);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void usbh_ch34x_stop(struct usbh_ch34x *ch34x_class)
|
||||
{
|
||||
struct usbh_serial *serial;
|
||||
|
||||
serial = (struct usbh_serial *)ch34x_class->user_data;
|
||||
usbh_serial_unregister(serial);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PKG_CHERRYUSB_HOST_CP210X) || defined(RT_CHERRYUSB_HOST_CP210X)
|
||||
void usbh_cp210x_callback(void *arg, int nbytes)
|
||||
{
|
||||
struct usbh_cp210x *cp210x_class = (struct usbh_cp210x *)arg;
|
||||
struct usbh_serial *serial;
|
||||
int ret;
|
||||
struct usbh_urb *urb = &cp210x_class->bulkin_urb;
|
||||
|
||||
if (nbytes > 0) {
|
||||
serial = (struct usbh_serial *)cp210x_class->user_data;
|
||||
rt_ringbuffer_put(&serial->rx_rb, g_usbh_serial_vendor_rx_buf[serial->minor], nbytes);
|
||||
|
||||
if (serial->parent.rx_indicate) {
|
||||
serial->parent.rx_indicate(&serial->parent, nbytes);
|
||||
}
|
||||
|
||||
usbh_bulk_urb_fill(urb, cp210x_class->hport, cp210x_class->bulkin, g_usbh_serial_vendor_rx_buf[serial->minor], sizeof(g_usbh_serial_vendor_rx_buf[serial->minor]), 0, usbh_cp210x_callback, cp210x_class);
|
||||
ret = usbh_submit_urb(urb);
|
||||
if (ret < 0) {
|
||||
USB_LOG_ERR("usbh_submit_urb failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void usbh_cp210x_run(struct usbh_cp210x *cp210x_class)
|
||||
{
|
||||
struct usbh_serial *serial;
|
||||
int ret;
|
||||
struct usbh_urb *urb = &cp210x_class->bulkin_urb;
|
||||
|
||||
serial = usbh_serial_alloc(USBH_SERIAL_TYPE_CP210X);
|
||||
cp210x_class->user_data = serial;
|
||||
|
||||
usbh_serial_register(serial, cp210x_class);
|
||||
|
||||
struct cdc_line_coding linecoding;
|
||||
linecoding.dwDTERate = 115200;
|
||||
linecoding.bDataBits = 8;
|
||||
linecoding.bParityType = 0;
|
||||
linecoding.bCharFormat = 0;
|
||||
usbh_cp210x_set_line_coding(cp210x_class, &linecoding);
|
||||
|
||||
usbh_bulk_urb_fill(urb, cp210x_class->hport, cp210x_class->bulkin, g_usbh_serial_vendor_rx_buf[serial->minor], sizeof(g_usbh_serial_vendor_rx_buf[serial->minor]), 0, usbh_cp210x_callback, cp210x_class);
|
||||
ret = usbh_submit_urb(urb);
|
||||
if (ret < 0) {
|
||||
USB_LOG_ERR("usbh_submit_urb failed: %d\n", ret);
|
||||
usbh_serial_unregister(serial);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void usbh_cp210x_stop(struct usbh_cp210x *cp210x_class)
|
||||
{
|
||||
struct usbh_serial *serial;
|
||||
|
||||
serial = (struct usbh_serial *)cp210x_class->user_data;
|
||||
usbh_serial_unregister(serial);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(PKG_CHERRYUSB_HOST_PL2303) || defined(RT_CHERRYUSB_HOST_PL2303)
|
||||
void usbh_pl2303_callback(void *arg, int nbytes)
|
||||
{
|
||||
struct usbh_pl2303 *pl2303_class = (struct usbh_pl2303 *)arg;
|
||||
struct usbh_serial *serial;
|
||||
int ret;
|
||||
struct usbh_urb *urb = &pl2303_class->bulkin_urb;
|
||||
|
||||
if (nbytes > 0) {
|
||||
serial = (struct usbh_serial *)pl2303_class->user_data;
|
||||
rt_ringbuffer_put(&serial->rx_rb, g_usbh_serial_vendor_rx_buf[serial->minor], nbytes);
|
||||
|
||||
if (serial->parent.rx_indicate) {
|
||||
serial->parent.rx_indicate(&serial->parent, nbytes);
|
||||
}
|
||||
|
||||
usbh_bulk_urb_fill(urb, pl2303_class->hport, pl2303_class->bulkin, g_usbh_serial_vendor_rx_buf[serial->minor], sizeof(g_usbh_serial_vendor_rx_buf[serial->minor]), 0, usbh_pl2303_callback, pl2303_class);
|
||||
ret = usbh_submit_urb(urb);
|
||||
if (ret < 0) {
|
||||
USB_LOG_ERR("usbh_submit_urb failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void usbh_pl2303_run(struct usbh_pl2303 *pl2303_class)
|
||||
{
|
||||
struct usbh_serial *serial;
|
||||
int ret;
|
||||
struct usbh_urb *urb = &pl2303_class->bulkin_urb;
|
||||
|
||||
serial = usbh_serial_alloc(USBH_SERIAL_TYPE_PL2303);
|
||||
pl2303_class->user_data = serial;
|
||||
|
||||
usbh_serial_register(serial, pl2303_class);
|
||||
|
||||
struct cdc_line_coding linecoding;
|
||||
linecoding.dwDTERate = 115200;
|
||||
linecoding.bDataBits = 8;
|
||||
linecoding.bParityType = 0;
|
||||
linecoding.bCharFormat = 0;
|
||||
usbh_pl2303_set_line_coding(pl2303_class, &linecoding);
|
||||
|
||||
usbh_bulk_urb_fill(urb, pl2303_class->hport, pl2303_class->bulkin, g_usbh_serial_vendor_rx_buf[serial->minor], sizeof(g_usbh_serial_vendor_rx_buf[serial->minor]), 0, usbh_pl2303_callback, pl2303_class);
|
||||
ret = usbh_submit_urb(urb);
|
||||
if (ret < 0) {
|
||||
USB_LOG_ERR("usbh_submit_urb failed: %d\n", ret);
|
||||
usbh_serial_unregister(serial);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void usbh_pl2303_stop(struct usbh_pl2303 *pl2303_class)
|
||||
{
|
||||
struct usbh_serial *serial;
|
||||
|
||||
serial = (struct usbh_serial *)pl2303_class->user_data;
|
||||
usbh_serial_unregister(serial);
|
||||
}
|
||||
#endif
|
||||
@@ -364,4 +364,5 @@ static inline void dwc2_get_hwparams(uint32_t reg_base, struct dwc2_hw_params *h
|
||||
void dwc2_get_user_params(uint32_t reg_base, struct dwc2_user_params *params);
|
||||
void dwc2_get_user_fifo_config(uint32_t reg_base, struct usb_dwc2_user_fifo_config *config);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -435,7 +435,7 @@ endif
|
||||
|
||||
config RT_VER_NUM
|
||||
hex
|
||||
default 0x50201
|
||||
default 0x50202
|
||||
help
|
||||
RT-Thread version number
|
||||
|
||||
|
||||
Reference in New Issue
Block a user