This commit is contained in:
qiyongshuang
2024-02-26 13:22:09 +08:00
parent 0ad592325e
commit 9596a13c17
573 changed files with 36301 additions and 23003 deletions
+10 -13
View File
@@ -15,17 +15,14 @@
*IAP upgrade routine:
*Support serial port and USB for FLASH burning
*
*1. Use the IAP download tool to realize the download PA0 floating (default pull-up input)
*2. After downloading the APP, connect PA0 to ground (low level input), and press
*the reset button to run the APP program.
*3. The routine needs to install the CH372 driver.
*1. The routine needs to install the CH372 driver.
*Note: FLASH operation keeps the frequency below 100Mhz, it is recommended that the main
*frequency of IAP be below 100Mhz
*
*/
#include "debug.h"
#include "ch32v20x_usbotg_device.h"
#include "ch32v20x_usbfs_device.h"
#include "iap.h"
#include "usb_istr.h"
#include "usb_desc.h"
@@ -42,21 +39,21 @@ extern u8 End_Flag;
*/
void IAP_2_APP(void) {
USB_Port_Set(DISABLE, DISABLE);
USBOTG_H_FS->HOST_CTRL = 0x00;
USBOTG_FS->BASE_CTRL = 0x00;
USBOTG_FS->INT_EN = 0x00;
USBOTG_FS->UEP2_3_MOD = 0x00;
USBOTG_FS->BASE_CTRL |= (1 << 1) | (1 << 2);
USBFSH->HOST_CTRL = 0x00;
USBFSD->BASE_CTRL = 0x00;
USBFSD->INT_EN = 0x00;
USBFSD->UEP2_3_MOD = 0x00;
USBFSD->BASE_CTRL |= (1 << 1) | (1 << 2);
Delay_Ms(50);
printf("jump APP\r\n");
GPIO_DeInit(GPIOA);
GPIO_DeInit(GPIOB);
USART_DeInit(USART3);
NVIC_DisableIRQ( USBHD_IRQn );
NVIC_DisableIRQ( USBFS_IRQn );
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, DISABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, DISABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3,DISABLE);
RCC_AHBPeriphClockCmd( RCC_AHBPeriph_OTG_FS, DISABLE );
RCC_AHBPeriphClockCmd( RCC_AHBPeriph_USBFS, DISABLE );
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, DISABLE);
Delay_Ms(10);
NVIC_EnableIRQ(Software_IRQn);
@@ -83,7 +80,7 @@ int main(void) {
USB_Port_Set(ENABLE, ENABLE);
USB_Interrupts_Config();
USBOTG_Init();
USBFS_Init();
USART3_CFG(57600);
while(1)
{