这样修改之后stm32f429可以自动收到一个reset中断
This commit is contained in:
@@ -79,144 +79,144 @@ extern "C" {
|
|||||||
#define CFG_TUSB_DEBUG_PRINTF rt_kprintf
|
#define CFG_TUSB_DEBUG_PRINTF rt_kprintf
|
||||||
#endif /* CFG_TUSB_DEBUG */
|
#endif /* CFG_TUSB_DEBUG */
|
||||||
|
|
||||||
#ifndef BOARD_DEVICE_RHPORT_NUM
|
// fs is 0; hs is 1
|
||||||
#define BOARD_DEVICE_RHPORT_NUM PKG_TINYUSB_RHPORT_NUM
|
#ifndef BOARD_DEVICE_RHPORT_NUM
|
||||||
#endif
|
#define BOARD_DEVICE_RHPORT_NUM 1
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef BOARD_DEVICE_RHPORT_SPEED
|
#ifndef BOARD_DEVICE_RHPORT_SPEED
|
||||||
#define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_FULL_SPEED
|
#define BOARD_DEVICE_RHPORT_SPEED OPT_MODE_FULL_SPEED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BOARD_DEVICE_RHPORT_NUM == 0
|
#if BOARD_DEVICE_RHPORT_NUM == 0
|
||||||
#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | BOARD_DEVICE_RHPORT_SPEED)
|
#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | BOARD_DEVICE_RHPORT_SPEED)
|
||||||
#elif BOARD_DEVICE_RHPORT_NUM == 1
|
#elif BOARD_DEVICE_RHPORT_NUM == 1
|
||||||
#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE | BOARD_DEVICE_RHPORT_SPEED)
|
#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_DEVICE | BOARD_DEVICE_RHPORT_SPEED)
|
||||||
#else
|
#else
|
||||||
#error "Incorrect RHPort configuration"
|
#error "Incorrect RHPort configuration"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
|
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
|
||||||
* Tinyusb use follows macros to declare transferring memory so that they can be put
|
* Tinyusb use follows macros to declare transferring memory so that they can be put
|
||||||
* into those specific section.
|
* into those specific section.
|
||||||
* e.g
|
* e.g
|
||||||
* - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
|
* - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
|
||||||
* - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4)))
|
* - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4)))
|
||||||
*/
|
*/
|
||||||
#ifndef CFG_TUSB_MEM_SECTION
|
#ifndef CFG_TUSB_MEM_SECTION
|
||||||
#define CFG_TUSB_MEM_SECTION
|
#define CFG_TUSB_MEM_SECTION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUSB_MEM_ALIGN
|
#ifndef CFG_TUSB_MEM_ALIGN
|
||||||
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
|
#define CFG_TUSB_MEM_ALIGN __attribute__((aligned(4)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// DEVICE CONFIGURATION
|
// DEVICE CONFIGURATION
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
#if defined(PKG_TINYUSB_DEVICE_ENABLE)
|
#if defined(PKG_TINYUSB_DEVICE_ENABLE)
|
||||||
#define CFG_TUD_ENABLED (1)
|
#define CFG_TUD_ENABLED (1)
|
||||||
#else
|
#else
|
||||||
#define CFG_TUD_ENABLED (0)
|
#define CFG_TUD_ENABLED (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUD_ENDPOINT0_SIZE
|
#ifndef CFG_TUD_ENDPOINT0_SIZE
|
||||||
#define CFG_TUD_ENDPOINT0_SIZE 8
|
#define CFG_TUD_ENDPOINT0_SIZE 8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CFG_TUD_CDC
|
#ifndef CFG_TUD_CDC
|
||||||
#define CFG_TUD_CDC 1
|
#define CFG_TUD_CDC 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// CDC FIFO size of TX and RX
|
// CDC FIFO size of TX and RX
|
||||||
#define CFG_TUD_CDC_RX_BUFSIZE 128
|
#define CFG_TUD_CDC_RX_BUFSIZE 128
|
||||||
#define CFG_TUD_CDC_TX_BUFSIZE 128
|
#define CFG_TUD_CDC_TX_BUFSIZE 128
|
||||||
|
|
||||||
#define CFG_TUD_MSC_EP_BUFSIZE 32
|
#define CFG_TUD_MSC_EP_BUFSIZE 32
|
||||||
|
|
||||||
#define CFG_TUD_HID_EP_BUFSIZE 32
|
#define CFG_TUD_HID_EP_BUFSIZE 32
|
||||||
|
|
||||||
#ifndef PKG_TINYUSB_DEVICE_CDC_STRING
|
#ifndef PKG_TINYUSB_DEVICE_CDC_STRING
|
||||||
#define PKG_TINYUSB_DEVICE_CDC_STRING ""
|
#define PKG_TINYUSB_DEVICE_CDC_STRING ""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PKG_TINYUSB_DEVICE_MSC_STRING
|
#ifndef PKG_TINYUSB_DEVICE_MSC_STRING
|
||||||
#define PKG_TINYUSB_DEVICE_MSC_STRING ""
|
#define PKG_TINYUSB_DEVICE_MSC_STRING ""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PKG_TINYUSB_DEVICE_HID_STRING
|
#ifndef PKG_TINYUSB_DEVICE_HID_STRING
|
||||||
#define PKG_TINYUSB_DEVICE_HID_STRING ""
|
#define PKG_TINYUSB_DEVICE_HID_STRING ""
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
// HOST CONFIGURATION
|
// HOST CONFIGURATION
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
#if defined(PKG_TINYUSB_HOST_ENABLE)
|
#if defined(PKG_TINYUSB_HOST_ENABLE)
|
||||||
#define CFG_TUH_ENABLED (1)
|
#define CFG_TUH_ENABLED (1)
|
||||||
#else
|
#else
|
||||||
#define CFG_TUH_ENABLED (0)
|
#define CFG_TUH_ENABLED (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (PKG_TINYUSB_HOST_PORT == 0) && defined(PKG_TINYUSB_HOST_ENABLE)
|
#if (PKG_TINYUSB_HOST_PORT == 0) && defined(PKG_TINYUSB_HOST_ENABLE)
|
||||||
#undef CFG_TUSB_RHPORT0_MODE
|
#undef CFG_TUSB_RHPORT0_MODE
|
||||||
#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_HOST | PKG_TINYUSB_HOST_PORT_SPEED)
|
#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_HOST | PKG_TINYUSB_HOST_PORT_SPEED)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (PKG_TINYUSB_HOST_PORT == 1) && defined(PKG_TINYUSB_HOST_ENABLE)
|
#if (PKG_TINYUSB_HOST_PORT == 1) && defined(PKG_TINYUSB_HOST_ENABLE)
|
||||||
#undef CFG_TUSB_RHPORT1_MODE
|
#undef CFG_TUSB_RHPORT1_MODE
|
||||||
#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_HOST | PKG_TINYUSB_HOST_PORT_SPEED)
|
#define CFG_TUSB_RHPORT1_MODE (OPT_MODE_HOST | PKG_TINYUSB_HOST_PORT_SPEED)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BOARD_TUH_RHPORT PKG_TINYUSB_HOST_PORT // FULL SPEED
|
#define BOARD_TUH_RHPORT PKG_TINYUSB_HOST_PORT// FULL SPEED
|
||||||
#define BOARD_TUH_MAX_SPEED PKG_TINYUSB_HOST_PORT_SPEED
|
#define BOARD_TUH_MAX_SPEED PKG_TINYUSB_HOST_PORT_SPEED
|
||||||
// Default is max speed that hardware controller could support with on-chip PHY
|
// Default is max speed that hardware controller could support with on-chip PHY
|
||||||
#define CFG_TUH_MAX_SPEED BOARD_TUH_MAX_SPEED
|
#define CFG_TUH_MAX_SPEED BOARD_TUH_MAX_SPEED
|
||||||
|
|
||||||
//------------------------- Board Specific --------------------------
|
//------------------------- Board Specific --------------------------
|
||||||
|
|
||||||
// RHPort number used for host can be defined by board.mk, default to port 0
|
// RHPort number used for host can be defined by board.mk, default to port 0
|
||||||
#ifndef BOARD_TUH_RHPORT
|
#ifndef BOARD_TUH_RHPORT
|
||||||
#define BOARD_TUH_RHPORT 0
|
#define BOARD_TUH_RHPORT 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// RHPort max operational speed can defined by board.mk
|
// RHPort max operational speed can defined by board.mk
|
||||||
#ifndef BOARD_TUH_MAX_SPEED
|
#ifndef BOARD_TUH_MAX_SPEED
|
||||||
#define BOARD_TUH_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
#define BOARD_TUH_MAX_SPEED OPT_MODE_DEFAULT_SPEED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Size of buffer to hold descriptors and other data used for enumeration
|
// Size of buffer to hold descriptors and other data used for enumeration
|
||||||
#define CFG_TUH_ENUMERATION_BUFSIZE 256
|
#define CFG_TUH_ENUMERATION_BUFSIZE 256
|
||||||
|
|
||||||
#define CFG_TUH_HUB 2 // number of supported hubs
|
#define CFG_TUH_HUB 2 // number of supported hubs
|
||||||
#define CFG_TUH_CDC 0 // CDC ACM
|
#define CFG_TUH_CDC 0 // CDC ACM
|
||||||
#define CFG_TUH_CDC_FTDI 0 // FTDI Serial. FTDI is not part of CDC class, only to re-use CDC driver API
|
#define CFG_TUH_CDC_FTDI 0 // FTDI Serial. FTDI is not part of CDC class, only to re-use CDC driver API
|
||||||
#define CFG_TUH_CDC_CP210X 0 // CP210x Serial. CP210X is not part of CDC class, only to re-use CDC driver API
|
#define CFG_TUH_CDC_CP210X 0// CP210x Serial. CP210X is not part of CDC class, only to re-use CDC driver API
|
||||||
#define CFG_TUH_CDC_CH34X 0 // CH340 or CH341 Serial. CH34X is not part of CDC class, only to re-use CDC driver API
|
#define CFG_TUH_CDC_CH34X 0 // CH340 or CH341 Serial. CH34X is not part of CDC class, only to re-use CDC driver API
|
||||||
#define CFG_TUH_HID 0 // typical keyboard + mouse device can have 3-4 HID interfaces
|
#define CFG_TUH_HID 0 // typical keyboard + mouse device can have 3-4 HID interfaces
|
||||||
#define CFG_TUH_MSC 0
|
#define CFG_TUH_MSC 0
|
||||||
//#define CFG_TUH_VENDOR 3
|
//#define CFG_TUH_VENDOR 3
|
||||||
|
|
||||||
// max device support (excluding hub device): 1 hub typically has 4 ports
|
// max device support (excluding hub device): 1 hub typically has 4 ports
|
||||||
#define CFG_TUH_DEVICE_MAX (3*CFG_TUH_HUB + 1)
|
#define CFG_TUH_DEVICE_MAX (3 * CFG_TUH_HUB + 1)
|
||||||
|
|
||||||
//------------- HID -------------//
|
//------------- HID -------------//
|
||||||
#define CFG_TUH_HID_EPIN_BUFSIZE 64
|
#define CFG_TUH_HID_EPIN_BUFSIZE 64
|
||||||
#define CFG_TUH_HID_EPOUT_BUFSIZE 64
|
#define CFG_TUH_HID_EPOUT_BUFSIZE 64
|
||||||
|
|
||||||
//------------- CDC -------------//
|
//------------- CDC -------------//
|
||||||
|
|
||||||
// Set Line Control state on enumeration/mounted:
|
// Set Line Control state on enumeration/mounted:
|
||||||
// DTR ( bit 0), RTS (bit 1)
|
// DTR ( bit 0), RTS (bit 1)
|
||||||
#define CFG_TUH_CDC_LINE_CONTROL_ON_ENUM 0x03
|
#define CFG_TUH_CDC_LINE_CONTROL_ON_ENUM 0x03
|
||||||
|
|
||||||
// Set Line Coding on enumeration/mounted, value for cdc_line_coding_t
|
// Set Line Coding on enumeration/mounted, value for cdc_line_coding_t
|
||||||
// bit rate = 115200, 1 stop bit, no parity, 8 bit data width
|
// bit rate = 115200, 1 stop bit, no parity, 8 bit data width
|
||||||
#define CFG_TUH_CDC_LINE_CODING_ON_ENUM { 115200, CDC_LINE_CODING_STOP_BITS_1, CDC_LINE_CODING_PARITY_NONE, 8 }
|
#define CFG_TUH_CDC_LINE_CODING_ON_ENUM {115200, CDC_LINE_CODING_STOP_BITS_1, CDC_LINE_CODING_PARITY_NONE, 8}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif /*__RTTHREAD__*/
|
#endif /*__RTTHREAD__*/
|
||||||
|
|
||||||
#endif /* _TUSB_CONFIG_H_ */
|
#endif /* _TUSB_CONFIG_H_ */
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#ifdef __RTTHREAD__
|
#ifdef __RTTHREAD__
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
#include "bsp_init.h"
|
#include "bsp_init.h"
|
||||||
|
#include "stm32f4xx.h"
|
||||||
|
|
||||||
#define DBG_TAG "TinyUSB"
|
#define DBG_TAG "TinyUSB"
|
||||||
#define DBG_LVL DBG_INFO
|
#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;
|
static struct rt_thread tusb_thread;
|
||||||
#endif /* RT_USING_HEAP */
|
#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)
|
static void tusb_thread_entry(void *parameter)
|
||||||
{
|
{
|
||||||
@@ -58,7 +75,9 @@ static int init_tinyusb(void)
|
|||||||
{
|
{
|
||||||
rt_thread_t tid;
|
rt_thread_t tid;
|
||||||
|
|
||||||
// tusb_board_init();
|
tusb_board_init();
|
||||||
|
|
||||||
|
//call tusb_rhport_init()
|
||||||
tusb_init();
|
tusb_init();
|
||||||
|
|
||||||
#ifdef RT_USING_HEAP
|
#ifdef RT_USING_HEAP
|
||||||
|
@@ -48,11 +48,17 @@ extern "C" {
|
|||||||
|
|
||||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32F4
|
#elif CFG_TUSB_MCU == OPT_MCU_STM32F4
|
||||||
#include "stm32f4xx.h"
|
#include "stm32f4xx.h"
|
||||||
#define EP_MAX_FS 4
|
#define EP_MAX_FS 5
|
||||||
#define EP_FIFO_SIZE_FS 256
|
#define EP_FIFO_SIZE_FS 0x1000
|
||||||
|
|
||||||
#define EP_MAX_HS 4
|
#define EP_MAX_HS 5
|
||||||
#define EP_FIFO_SIZE_HS 256
|
#define EP_FIFO_SIZE_HS 0x1000
|
||||||
|
|
||||||
|
// #define USB_OTG_HS_BASE_ADDR 0x40040000
|
||||||
|
// #define USB_OTG_FS_BASE_ADDR 0x50000000
|
||||||
|
|
||||||
|
#define USB_OTG_HS_PERIPH_BASE 0x40040000
|
||||||
|
#define USB_OTG_FS_PERIPH_BASE 0x50000000
|
||||||
|
|
||||||
#elif CFG_TUSB_MCU == OPT_MCU_STM32H7
|
#elif CFG_TUSB_MCU == OPT_MCU_STM32H7
|
||||||
#include "stm32h7xx.h"
|
#include "stm32h7xx.h"
|
||||||
|
Reference in New Issue
Block a user