- UID
- 1029342
- 性别
- 男
|
2,修改代码hw_config.c删除无用代码,新建立2组,读FIFO和写FIFO的函数。后面会用到。
代码如下:
代码2
[url=][/url]
1 /* Includes ------------------------------------------------------------------*/ 2 3 #include "usb_lib.h" 4 #include "usb_prop.h" 5 #include "usb_desc.h" 6 #include "hw_config.h" 7 #include "usb_pwr.h" 8 #include "Queue.h" 9 10 11 /* Private typedef -----------------------------------------------------------*/ 12 /* Private define ------------------------------------------------------------*/ 13 /* Private macro -------------------------------------------------------------*/ 14 /* Private variables ---------------------------------------------------------*/ 15 ErrorStatus HSEStartUpStatus; 16 USART_InitTypeDef USART_InitStructure; 17 EXTI_InitTypeDef EXTI_InitStructure; 18 19 20 #define USB_COM_RX_BUF_SIZE (1024 + 256) 21 #define USB_COM_TX_BUF_SIZE (1024 + 256) 22 23 static QUEUE8_t m_QueueUsbComRx = {0}; 24 static QUEUE8_t m_QueueUsbComTx = {0}; 25 static uint8_t m_UsbComRxBuf[USB_COM_RX_BUF_SIZE] = {0}; 26 static uint8_t m_UsbComTxBuf[USB_COM_TX_BUF_SIZE] = {0}; 27 28 static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len); 29 /* Extern variables ----------------------------------------------------------*/ 30 31 extern LINE_CODING linecoding; 32 33 /* Private function prototypes -----------------------------------------------*/ 34 /* Private functions ---------------------------------------------------------*/ 35 /******************************************************************************* 36 * Function Name : Set_System 37 * Description : Configures Main system clocks & power 38 * Input : None. 39 * Return : None. 40 *******************************************************************************/ 41 void Set_System(void) 42 { 43 GPIO_InitTypeDef GPIO_InitStructure; 44 45 QUEUE_PacketCreate(&m_QueueUsbComRx, m_UsbComRxBuf, sizeof(m_UsbComRxBuf)); 46 QUEUE_PacketCreate(&m_QueueUsbComTx, m_UsbComTxBuf, sizeof(m_UsbComTxBuf)); 47 48 /* Enable USB_DISCONNECT GPIO clock */ 49 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIO_DISCONNECT, ENABLE); 50 51 /* Configure USB pull-up pin */ 52 GPIO_InitStructure.GPIO_Pin = USB_DISCONNECT_PIN; 53 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; 54 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 55 GPIO_Init(USB_DISCONNECT, &GPIO_InitStructure); 56 57 /* Configure the EXTI line 18 connected internally to the USB IP */ 58 EXTI_ClearITPendingBit(EXTI_Line18); 59 EXTI_InitStructure.EXTI_Line = EXTI_Line18; 60 EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; 61 EXTI_InitStructure.EXTI_LineCmd = ENABLE; 62 EXTI_Init(&EXTI_InitStructure); 63 64 65 } 66 67 /******************************************************************************* 68 * Function Name : Set_USBClock 69 * Description : Configures USB Clock input (48MHz) 70 * Input : None. 71 * Return : None. 72 *******************************************************************************/ 73 void Set_USBClock(void) 74 { 75 /* Select USBCLK source */ 76 RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5); 77 78 /* Enable the USB clock */ 79 RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE); 80 } 81 82 /******************************************************************************* 83 * Function Name : Enter_LowPowerMode 84 * Description : Power-off system clocks and power while entering suspend mode 85 * Input : None. 86 * Return : None. 87 *******************************************************************************/ 88 void Enter_LowPowerMode(void) 89 { 90 /* Set the device state to suspend */ 91 bDeviceState = SUSPENDED; 92 } 93 |
|