OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 2447|回复: 0

求大佬帮忙解决stm32f105RBT6读写u盘无法进入枚举的问题

[复制链接]

2

主题

3

帖子

0

精华

新手上路

积分
21
金钱
21
注册时间
2019-10-15
在线时间
5 小时
发表于 2019-10-17 14:00:18 | 显示全部楼层 |阅读模式
3金钱
基于官方库开发的工程,配置基本上只修改了usb_bsp.c和usb_usr.c这两个文件
usb_bsp.c改动如下:
/**
  ******************************************************************************
  * @file    usb_bsp.c
  * @Author  MCD Application Team
  * @version V1.2.0
  * @date    09-November-2015
  * @brief   This file implements the board support package for the USB host library
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
  *
  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  * You may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:

  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "usb_bsp.h"
#include "stm32f10x.h"     //固件库头文件
#include "typnumber.h"   //数据类型定义头文件
#include "SysTick.h"    //滴答时钟,延时函数头文件
#include "stm32f10x_tim.h"

/** @addtogroup USBH_USER
* @{
*/

/** @defgroup USB_BSP
  * @brief This file is responsible to offer board support package
  * @{
  */

/** @defgroup USB_BSP_Private_Defines
  * @{
  */
#define USE_ACCURATE_TIME
#define TIM_MSEC_DELAY                     0x01
#define TIM_USEC_DELAY                     0x02
#define HOST_OVRCURR_PORT                  GPIOE
#define HOST_OVRCURR_LINE                  GPIO_Pin_1
#define HOST_OVRCURR_PORT_SOURCE           GPIO_PortSourceGPIOE
#define HOST_OVRCURR_PIN_SOURCE            GPIO_PinSource1
#define HOST_OVRCURR_PORT_RCC              RCC_APB2Periph_GPIOE
#define HOST_OVRCURR_EXTI_LINE             EXTI_Line1
#define HOST_OVRCURR_IRQn                  EXTI1_IRQn

#ifdef USE_STM3210C_EVAL
#define HOST_POWERSW_PORT_RCC             RCC_APB2Periph_GPIOC
#define HOST_POWERSW_PORT                 GPIOC
#define HOST_POWERSW_VBUS                 GPIO_Pin_9
#endif

#if defined(USE_STM324x9I_EVAL)
  #ifdef USE_USB_OTG_FS
    #define HOST_POWERSW_FS1_VBUS                    IO16_Pin_7
  #endif
   
  #ifdef USE_USB_OTG_HS
    #define HOST_POWERSW_FS2_VBUS                    IO16_Pin_9
  #endif
#endif

#if defined(USE_STM322xG_EVAL) || defined(USE_STM324xG_EVAL)
   #ifdef USE_USB_OTG_FS
    #define HOST_POWERSW_PORT_RCC            RCC_AHB1Periph_GPIOH
    #define HOST_POWERSW_PORT                GPIOH
    #define HOST_POWERSW_VBUS                GPIO_Pin_5
   #endif /* USE_USB_OTG_FS */
#endif /* defined(USE_STM322xG_EVAL) || defined(USE_STM324xG_EVAL) */

#define HOST_SOF_OUTPUT_RCC                RCC_APB2Periph_GPIOA
#define HOST_SOF_PORT                      GPIOA
#define HOST_SOF_SIGNAL                    GPIO_Pin_8

/**
  * @}
  */


/** @defgroup USB_BSP_Private_TypesDefinitions
  * @{
  */
/**
  * @}
  */

/** @defgroup USB_BSP_Private_Macros
  * @{
  */
/**
  * @}
  */
/** @defgroup USBH_BSP_Private_Variables
  * @{
  */
ErrorStatus HSEStartUpStatus;
#ifdef USE_ACCURATE_TIME
__IO uint32_t BSP_delay = 0;
#endif
/**
  * @}
  */
/** @defgroup USBH_BSP_Private_FunctionPrototypes
  * @{
  */
#ifdef USE_ACCURATE_TIME
#endif
/**
  * @}
  */
/** @defgroup USB_BSP_Private_Functions
  * @{
  */
/**
  * @brief  USB_OTG_BSP_Init
  *         Initializes BSP configurations
  * @param  None
  * @retval None
  */
void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev)
{
GPIO_InitTypeDef GPIO_InitStructure;

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO, ENABLE);  
  RCC_OTGFSCLKConfig(RCC_OTGFSCLKSource_PLLVCO_Div3);
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_OTG_FS, ENABLE) ;
  
  
  /* Configure SOF ID DM DP Pins GPIO_Pin_8|*/
  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_11 |
                                GPIO_Pin_12;
  
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP ;
  GPIO_Init(GPIOA, &GPIO_InitStructure);  


// USB_OTG_BSP_TimeInit();
}
/**
  * @brief  USB_OTG_BSP_EnableInterrupt
  *         Configures USB Global interrupt
  * @param  None
  * @retval None
  */
void USB_OTG_BSP_EnableInterrupt(USB_OTG_CORE_HANDLE *pdev)
{
   NVIC_InitTypeDef NVIC_InitStructure;

  /* Enable the USB Interrupts */
  NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
}
/**
  * @brief  BSP_Drive_VBUS
  *         Drives the Vbus signal through IO
  * @param  state : VBUS states
  * @retval None
  */

//static void USB_OTG_BSP_TimeInit ( void )
//{
//
// RCC_OTGFSCLKConfig(RCC_OTGFSCLKSource_PLLVCO_Div3);//USBclk=PLLclk/1.5=48Mhz
// RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);  //USB时钟使能
//  
//}
void USB_OTG_BSP_TimerIRQ (void)
{
#ifdef USE_ACCURATE_TIME
   
  if(TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET)
  {
   TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
    if (BSP_delay > 0x00)
    {
      BSP_delay--;
    }
    else
    {
      TIM_Cmd(TIM2,DISABLE);
    }
  }
#endif  
}
void USB_OTG_BSP_DriveVBUS(USB_OTG_CORE_HANDLE *pdev, uint8_t state)
{
}
/**
  * @brief  USB_OTG_BSP_ConfigVBUS
  *         Configures the IO for the Vbus and OverCurrent
  * @param  None
  * @retval None
  */
void  USB_OTG_BSP_ConfigVBUS(USB_OTG_CORE_HANDLE *pdev)
{
}
/**
  * @brief  USB_OTG_BSP_TimeInit
  *         Initializes delay unit using Timer2
  * @param  None
  * @retval None
  */
/**
  * @brief  USB_OTG_BSP_uDelay
  *         This function provides delay time in micro sec
  * @param  usec : Value of delay required in micro sec
  * @retval None
  */
void USB_OTG_BSP_uDelay (const uint32_t usec)
{
delay_us(usec);
}

/**
  * @brief  USB_OTG_BSP_mDelay
  *          This function provides delay time in milli sec
  * @param  msec : Value of delay required in milli sec
  * @retval None
  */
void USB_OTG_BSP_mDelay (const uint32_t msec)
{
delay_ms(msec);
}
   

/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
配置好的程序下载到板子后只能检测到u盘的插入,拔出和复位状态,无法进入枚举


寄存器和部分变量值我截图出来了,请大佬帮忙找找问题!!!!!














正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-28 19:08

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表