usb: remove usbdev from StdPeriphDriver
The library only have 4 endpoint supported while the chip have capable of 8. And its design is kind of cumbersome.
This commit is contained in:
@@ -1,113 +0,0 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH58x_usbdev.c
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "CH58x_common.h"
|
||||
|
||||
uint8_t *pEP0_RAM_Addr;
|
||||
uint8_t *pEP1_RAM_Addr;
|
||||
uint8_t *pEP2_RAM_Addr;
|
||||
uint8_t *pEP3_RAM_Addr;
|
||||
|
||||
/*********************************************************************
|
||||
* @fn USB_DeviceInit
|
||||
*
|
||||
* @brief USB设备功能初始化,4个端点,8个通道。
|
||||
*
|
||||
* @param none
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void USB_DeviceInit(void)
|
||||
{
|
||||
R8_USB_CTRL = 0x00; // 先设定模式,取消 RB_UC_CLR_ALL
|
||||
|
||||
R8_UEP4_1_MOD = RB_UEP4_RX_EN | RB_UEP4_TX_EN | RB_UEP1_RX_EN | RB_UEP1_TX_EN; // 端点4 OUT+IN,端点1 OUT+IN
|
||||
R8_UEP2_3_MOD = RB_UEP2_RX_EN | RB_UEP2_TX_EN | RB_UEP3_RX_EN | RB_UEP3_TX_EN; // 端点2 OUT+IN,端点3 OUT+IN
|
||||
|
||||
R16_UEP0_DMA = (uint16_t)(uint32_t)pEP0_RAM_Addr;
|
||||
R16_UEP1_DMA = (uint16_t)(uint32_t)pEP1_RAM_Addr;
|
||||
R16_UEP2_DMA = (uint16_t)(uint32_t)pEP2_RAM_Addr;
|
||||
R16_UEP3_DMA = (uint16_t)(uint32_t)pEP3_RAM_Addr;
|
||||
|
||||
R8_UEP0_CTRL = UEP_R_RES_ACK | UEP_T_RES_NAK;
|
||||
R8_UEP1_CTRL = UEP_R_RES_ACK | UEP_T_RES_NAK | RB_UEP_AUTO_TOG;
|
||||
R8_UEP2_CTRL = UEP_R_RES_ACK | UEP_T_RES_NAK | RB_UEP_AUTO_TOG;
|
||||
R8_UEP3_CTRL = UEP_R_RES_ACK | UEP_T_RES_NAK | RB_UEP_AUTO_TOG;
|
||||
R8_UEP4_CTRL = UEP_R_RES_ACK | UEP_T_RES_NAK;
|
||||
|
||||
R8_USB_DEV_AD = 0x00;
|
||||
R8_USB_CTRL = RB_UC_DEV_PU_EN | RB_UC_INT_BUSY | RB_UC_DMA_EN; // 启动USB设备及DMA,在中断期间中断标志未清除前自动返回NAK
|
||||
R16_PIN_ANALOG_IE |= RB_PIN_USB_IE | RB_PIN_USB_DP_PU; // 防止USB端口浮空及上拉电阻
|
||||
R8_USB_INT_FG = 0xFF; // 清中断标志
|
||||
R8_UDEV_CTRL = RB_UD_PD_DIS | RB_UD_PORT_EN; // 允许USB端口
|
||||
R8_USB_INT_EN = RB_UIE_SUSPEND | RB_UIE_BUS_RST | RB_UIE_TRANSFER;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn DevEP1_IN_Deal
|
||||
*
|
||||
* @brief 端点1数据上传
|
||||
*
|
||||
* @param l - 上传数据长度(<64B)
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void DevEP1_IN_Deal(uint8_t l)
|
||||
{
|
||||
R8_UEP1_T_LEN = l;
|
||||
R8_UEP1_CTRL = (R8_UEP1_CTRL & ~MASK_UEP_T_RES) | UEP_T_RES_ACK;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn DevEP2_IN_Deal
|
||||
*
|
||||
* @brief 端点2数据上传
|
||||
*
|
||||
* @param l - 上传数据长度(<64B)
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void DevEP2_IN_Deal(uint8_t l)
|
||||
{
|
||||
R8_UEP2_T_LEN = l;
|
||||
R8_UEP2_CTRL = (R8_UEP2_CTRL & ~MASK_UEP_T_RES) | UEP_T_RES_ACK;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn DevEP3_IN_Deal
|
||||
*
|
||||
* @brief 端点3数据上传
|
||||
*
|
||||
* @param l - 上传数据长度(<64B)
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void DevEP3_IN_Deal(uint8_t l)
|
||||
{
|
||||
R8_UEP3_T_LEN = l;
|
||||
R8_UEP3_CTRL = (R8_UEP3_CTRL & ~MASK_UEP_T_RES) | UEP_T_RES_ACK;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* @fn DevEP4_IN_Deal
|
||||
*
|
||||
* @brief 端点4数据上传
|
||||
*
|
||||
* @param l - 上传数据长度(<64B)
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
void DevEP4_IN_Deal(uint8_t l)
|
||||
{
|
||||
R8_UEP4_T_LEN = l;
|
||||
R8_UEP4_CTRL = (R8_UEP4_CTRL & ~MASK_UEP_T_RES) | UEP_T_RES_ACK;
|
||||
}
|
||||
@@ -84,7 +84,6 @@
|
||||
#include "CH58x_sys.h"
|
||||
#include "CH58x_timer.h"
|
||||
#include "CH58x_spi.h"
|
||||
#include "CH58x_usbdev.h"
|
||||
#include "CH58x_usbhost.h"
|
||||
#include "ISP583.h"
|
||||
|
||||
|
||||
@@ -1,177 +0,0 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : CH57x_usbdev.h
|
||||
* Author : WCH
|
||||
* Version : V1.2
|
||||
* Date : 2021/11/17
|
||||
* Description
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __CH58x_USBDEV_H__
|
||||
#define __CH58x_USBDEV_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* HID类请求 */
|
||||
#define DEF_USB_GET_IDLE 0x02 /* get idle for key or mouse */
|
||||
#define DEF_USB_GET_PROTOCOL 0x03 /* get protocol for bios type */
|
||||
#define DEF_USB_SET_REPORT 0x09 /* set report for key */
|
||||
#define DEF_USB_SET_IDLE 0x0A /* set idle for key or mouse */
|
||||
#define DEF_USB_SET_PROTOCOL 0x0B /* set protocol for bios type */
|
||||
|
||||
/* 以下缓存区是USB模块收发使用的数据缓冲区,总共9个通道(9块缓存),用户可根据实际使用的通道数定义相应缓存区 */
|
||||
extern uint8_t *pEP0_RAM_Addr; //ep0(64)+ep4_out(64)+ep4_in(64)
|
||||
extern uint8_t *pEP1_RAM_Addr; //ep1_out(64)+ep1_in(64)
|
||||
extern uint8_t *pEP2_RAM_Addr; //ep2_out(64)+ep2_in(64)
|
||||
extern uint8_t *pEP3_RAM_Addr; //ep3_out(64)+ep3_in(64)
|
||||
|
||||
extern uint8_t *pU2EP0_RAM_Addr; //ep0(64)+ep4_out(64)+ep4_in(64)
|
||||
extern uint8_t *pU2EP1_RAM_Addr; //ep1_out(64)+ep1_in(64)
|
||||
extern uint8_t *pU2EP2_RAM_Addr; //ep2_out(64)+ep2_in(64)
|
||||
extern uint8_t *pU2EP3_RAM_Addr; //ep3_out(64)+ep3_in(64)
|
||||
|
||||
#define pSetupReqPak ((PUSB_SETUP_REQ)pEP0_RAM_Addr)
|
||||
#define pEP0_DataBuf (pEP0_RAM_Addr)
|
||||
#define pEP1_OUT_DataBuf (pEP1_RAM_Addr)
|
||||
#define pEP1_IN_DataBuf (pEP1_RAM_Addr + 64)
|
||||
#define pEP2_OUT_DataBuf (pEP2_RAM_Addr)
|
||||
#define pEP2_IN_DataBuf (pEP2_RAM_Addr + 64)
|
||||
#define pEP3_OUT_DataBuf (pEP3_RAM_Addr)
|
||||
#define pEP3_IN_DataBuf (pEP3_RAM_Addr + 64)
|
||||
#define pEP4_OUT_DataBuf (pEP0_RAM_Addr + 64)
|
||||
#define pEP4_IN_DataBuf (pEP0_RAM_Addr + 128)
|
||||
|
||||
#define pU2SetupReqPak ((PUSB_SETUP_REQ)pU2EP0_RAM_Addr)
|
||||
#define pU2EP0_DataBuf (pU2EP0_RAM_Addr)
|
||||
#define pU2EP1_OUT_DataBuf (pU2EP1_RAM_Addr)
|
||||
#define pU2EP1_IN_DataBuf (pU2EP1_RAM_Addr + 64)
|
||||
#define pU2EP2_OUT_DataBuf (pU2EP2_RAM_Addr)
|
||||
#define pU2EP2_IN_DataBuf (pU2EP2_RAM_Addr + 64)
|
||||
#define pU2EP3_OUT_DataBuf (pU2EP3_RAM_Addr)
|
||||
#define pU2EP3_IN_DataBuf (pU2EP3_RAM_Addr + 64)
|
||||
#define pU2EP4_OUT_DataBuf (pU2EP0_RAM_Addr + 64)
|
||||
#define pU2EP4_IN_DataBuf (pU2EP0_RAM_Addr + 128)
|
||||
|
||||
/**
|
||||
* @brief USB设备功能初始化,4个端点,8个通道。
|
||||
*/
|
||||
void USB_DeviceInit(void);
|
||||
|
||||
/**
|
||||
* @brief USB设备应答传输处理
|
||||
*/
|
||||
void USB_DevTransProcess(void);
|
||||
|
||||
/**
|
||||
* @brief 端点1下传数据处理
|
||||
*
|
||||
* @param l - 待处理数据长度(<64B)
|
||||
*/
|
||||
void DevEP1_OUT_Deal(uint8_t l);
|
||||
|
||||
/**
|
||||
* @brief 端点2下传数据处理
|
||||
*
|
||||
* @param l - 待处理数据长度(<64B)
|
||||
*/
|
||||
void DevEP2_OUT_Deal(uint8_t l);
|
||||
|
||||
/**
|
||||
* @brief 端点3下传数据处理
|
||||
*
|
||||
* @param l - 待处理数据长度(<64B)
|
||||
*/
|
||||
void DevEP3_OUT_Deal(uint8_t l);
|
||||
|
||||
/**
|
||||
* @brief 端点4下传数据处理
|
||||
*
|
||||
* @param l - 待处理数据长度(<64B)
|
||||
*/
|
||||
void DevEP4_OUT_Deal(uint8_t l);
|
||||
|
||||
/**
|
||||
* @brief 端点1数据上传
|
||||
*
|
||||
* @param l - 上传数据长度(<64B)
|
||||
*/
|
||||
void DevEP1_IN_Deal(uint8_t l);
|
||||
|
||||
/**
|
||||
* @brief 端点2数据上传
|
||||
*
|
||||
* @param l - 上传数据长度(<64B)
|
||||
*/
|
||||
void DevEP2_IN_Deal(uint8_t l);
|
||||
|
||||
/**
|
||||
* @brief 端点3数据上传
|
||||
*
|
||||
* @param l - 上传数据长度(<64B)
|
||||
*/
|
||||
void DevEP3_IN_Deal(uint8_t l);
|
||||
|
||||
/**
|
||||
* @brief 端点4数据上传
|
||||
*
|
||||
* @param l - 上传数据长度(<64B)
|
||||
*/
|
||||
void DevEP4_IN_Deal(uint8_t l);
|
||||
|
||||
/**
|
||||
* @brief 查询端点1是否上传完成
|
||||
*
|
||||
* @return 0-未完成 (!0)-已完成
|
||||
*/
|
||||
#define EP1_GetINSta() (R8_UEP1_CTRL & UEP_T_RES_NAK)
|
||||
|
||||
/**
|
||||
* @brief 查询端点2是否上传完成
|
||||
*
|
||||
* @return 0-未完成 (!0)-已完成
|
||||
*/
|
||||
#define EP2_GetINSta() (R8_UEP2_CTRL & UEP_T_RES_NAK)
|
||||
|
||||
/**
|
||||
* @brief 查询端点3是否上传完成
|
||||
*
|
||||
* @return 0-未完成 (!0)-已完成
|
||||
*/
|
||||
#define EP3_GetINSta() (R8_UEP3_CTRL & UEP_T_RES_NAK)
|
||||
|
||||
/**
|
||||
* @brief 查询端点4是否上传完成
|
||||
*
|
||||
* @return 0-未完成 (!0)-已完成
|
||||
*/
|
||||
#define EP4_GetINSta() (R8_UEP4_CTRL & UEP_T_RES_NAK)
|
||||
|
||||
void USB2_DeviceInit(void); /* USB2设备功能初始化,4个端点,8个通道 */
|
||||
void USB2_DevTransProcess(void); /* USB2设备应答传输处理 */
|
||||
|
||||
void U2DevEP1_OUT_Deal(uint8_t l); /* 设备端点1下传通道处理 */
|
||||
void U2DevEP2_OUT_Deal(uint8_t l); /* 设备端点2下传通道处理 */
|
||||
void U2DevEP3_OUT_Deal(uint8_t l); /* 设备端点3下传通道处理 */
|
||||
void U2DevEP4_OUT_Deal(uint8_t l); /* 设备端点4下传通道处理 */
|
||||
|
||||
void U2DevEP1_IN_Deal(uint8_t l); /* 设备端点1上传通道处理 */
|
||||
void U2DevEP2_IN_Deal(uint8_t l); /* 设备端点2上传通道处理 */
|
||||
void U2DevEP3_IN_Deal(uint8_t l); /* 设备端点3上传通道处理 */
|
||||
void U2DevEP4_IN_Deal(uint8_t l); /* 设备端点4上传通道处理 */
|
||||
|
||||
// 0-未完成 (!0)-已完成
|
||||
#define U2EP1_GetINSta() (R8_U2EP1_CTRL & UEP_T_RES_NAK) /* 查询端点1是否上传完成 */
|
||||
#define U2EP2_GetINSta() (R8_U2EP2_CTRL & UEP_T_RES_NAK) /* 查询端点2是否上传完成 */
|
||||
#define U2EP3_GetINSta() (R8_U2EP3_CTRL & UEP_T_RES_NAK) /* 查询端点3是否上传完成 */
|
||||
#define U2EP4_GetINSta() (R8_U2EP4_CTRL & UEP_T_RES_NAK) /* 查询端点4是否上传完成 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __CH58x_USBDEV_H__
|
||||
1
Makefile
1
Makefile
@@ -37,7 +37,6 @@ CH5xx_ble_firmware_library/StdPeriphDriver/CH58x_uart0.c \
|
||||
CH5xx_ble_firmware_library/StdPeriphDriver/CH58x_timer1.c \
|
||||
CH5xx_ble_firmware_library/StdPeriphDriver/CH58x_pwm.c \
|
||||
CH5xx_ble_firmware_library/StdPeriphDriver/CH58x_usbhostClass.c \
|
||||
CH5xx_ble_firmware_library/StdPeriphDriver/CH58x_usbdev.c \
|
||||
CH5xx_ble_firmware_library/StdPeriphDriver/CH58x_adc.c \
|
||||
CH5xx_ble_firmware_library/StdPeriphDriver/CH58x_usbhostBase.c \
|
||||
CH5xx_ble_firmware_library/StdPeriphDriver/CH58x_timer3.c \
|
||||
|
||||
Reference in New Issue
Block a user