/********************************** (C) COPYRIGHT ******************************* * File Name : main.c * Author : WCH * Version : V1.0.0 * Date : 2022/08/20 * Description : Main program body. ********************************************************************************* * 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. *******************************************************************************/ /* *@Note This routine demonstrates the use of USBFS to emulate a custom CH372 device, with endpoints 1/3/5 downloading data and uploading it via endpoints 2/4/6 respectively where endpoint 1/2 is implemented via a ring buffer and the data is not inverted, and endpoints 3/4 and 5/6 are directly copied and inverted for upload. The device can be operated using Bushund or other upper computer software. Note: This routine needs to be demonstrated in conjunction with the host software. */ #include "ch32v20x_usbfs_device.h" #include "debug.h" /********************************************************************* * @fn Var_Init * * @brief Software parameter initialisation * * @return none */ void Var_Init(void) { uint16_t i; RingBuffer_Comm.LoadPtr = 0; RingBuffer_Comm.StopFlag = 0; RingBuffer_Comm.DealPtr = 0; RingBuffer_Comm.RemainPack = 0; for(i=0; iUEP1_RX_CTRL = (USBOTG_FS->UEP1_RX_CTRL & ~USBFS_UEP_R_RES_MASK) | USBFS_UEP_R_RES_ACK; } } } } }