这样修改之后stm32f429可以自动收到一个reset中断

This commit is contained in:
2025-09-20 14:38:45 +08:00
parent 8a1d7f9512
commit 6f4c32755b
3 changed files with 133 additions and 108 deletions

View File

@@ -26,6 +26,7 @@
#ifdef __RTTHREAD__
#include <rtthread.h>
#include "bsp_init.h"
#include "stm32f4xx.h"
#define DBG_TAG "TinyUSB"
#define DBG_LVL DBG_INFO
@@ -38,7 +39,23 @@ static rt_uint8_t tusb_stack[PKG_TINYUSB_STACK_SIZE];
static struct rt_thread tusb_thread;
#endif /* RT_USING_HEAP */
extern int tusb_board_init(void);
int tusb_board_init(void) {
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_OTG_HS, ENABLE);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource14, GPIO_AF_OTG2_FS);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource15, GPIO_AF_OTG2_FS);
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14 | GPIO_Pin_15;
GPIO_Init(GPIOB, &GPIO_InitStructure);
// no need enable irq, it will be enabled in dwc2_dcd_int_enable()
return 0;
}
static void tusb_thread_entry(void *parameter)
{
@@ -58,7 +75,9 @@ static int init_tinyusb(void)
{
rt_thread_t tid;
// tusb_board_init();
tusb_board_init();
//call tusb_rhport_init()
tusb_init();
#ifdef RT_USING_HEAP