summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2009-06-04 16:01:38 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2009-06-04 16:01:38 +0100
commit006e10694be7056e62fe1372889918326d38630b (patch)
tree19f3193dffc9ecbee54796ef92a5619aefc9df60
downloadstm32-virtcomport-006e10694be7056e62fe1372889918326d38630b.tar.bz2
A raw import of the raw comport stuff
-rw-r--r--hw_config.c406
-rw-r--r--hw_config.h48
-rw-r--r--main.c84
-rw-r--r--platform_config.h52
-rw-r--r--stm32f10x_conf.h174
-rw-r--r--stm32f10x_it.c752
-rw-r--r--stm32f10x_it.h100
-rw-r--r--usb_conf.h83
-rw-r--r--usb_desc.c159
-rw-r--r--usb_desc.h53
-rw-r--r--usb_endp.c60
-rw-r--r--usb_istr.c170
-rw-r--r--usb_istr.h82
-rw-r--r--usb_prop.c407
-rw-r--r--usb_prop.h74
-rw-r--r--usb_pwr.c223
-rw-r--r--usb_pwr.h59
17 files changed, 2986 insertions, 0 deletions
diff --git a/hw_config.c b/hw_config.c
new file mode 100644
index 0000000..4bb6ecc
--- /dev/null
+++ b/hw_config.c
@@ -0,0 +1,406 @@
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : hw_config.c
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Hardware Configuration & Setup
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_it.h"
+#include "usb_lib.h"
+#include "usb_prop.h"
+#include "usb_desc.h"
+#include "hw_config.h"
+#include "platform_config.h"
+#include "usb_pwr.h"
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+USART_InitTypeDef USART_InitStructure;
+ErrorStatus HSEStartUpStatus;
+
+/* Extern variables ----------------------------------------------------------*/
+u8 buffer_in[VIRTUAL_COM_PORT_DATA_SIZE];
+extern u32 count_in;
+extern LINE_CODING linecoding;
+
+/* Private function prototypes -----------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+/*******************************************************************************
+* Function Name : Set_System
+* Description : Configures Main system clocks & power
+* Input : None.
+* Return : None.
+*******************************************************************************/
+void Set_System(void)
+{
+ GPIO_InitTypeDef GPIO_InitStructure;
+
+ /* SYSCLK, HCLK, PCLK2 and PCLK1 configuration -----------------------------*/
+ /* RCC system reset(for debug purpose) */
+ RCC_DeInit();
+
+ /* Enable HSE */
+ RCC_HSEConfig(RCC_HSE_ON);
+
+ /* Wait till HSE is ready */
+ HSEStartUpStatus = RCC_WaitForHSEStartUp();
+
+ if (HSEStartUpStatus == SUCCESS)
+ {
+ /* Enable Prefetch Buffer */
+ FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
+
+ /* Flash 2 wait state */
+ FLASH_SetLatency(FLASH_Latency_2);
+
+ /* HCLK = SYSCLK */
+ RCC_HCLKConfig(RCC_SYSCLK_Div1);
+
+ /* PCLK2 = HCLK */
+ RCC_PCLK2Config(RCC_HCLK_Div1);
+
+ /* PCLK1 = HCLK/2 */
+ RCC_PCLK1Config(RCC_HCLK_Div2);
+
+ /* ADCCLK = PCLK2/6 */
+ RCC_ADCCLKConfig(RCC_PCLK2_Div6);
+
+ RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
+
+ /* Enable PLL */
+ RCC_PLLCmd(ENABLE);
+
+ /* Wait till PLL is ready */
+ while (RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET)
+ {}
+
+ /* Select PLL as system clock source */
+ RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
+
+ /* Wait till PLL is used as system clock source */
+ while (RCC_GetSYSCLKSource() != 0x08)
+ {}
+ }
+
+ /* Enable GPIOA, GPIOD and USART1 clock */
+ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOD
+ | RCC_APB2Periph_USART1, ENABLE);
+
+ /* Enable USB_DISCONNECT GPIO clock */
+ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIO_DISCONNECT, ENABLE);
+
+ /* Configure USB pull-up pin */
+ GPIO_InitStructure.GPIO_Pin = USB_DISCONNECT_PIN;
+ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
+ GPIO_Init(USB_DISCONNECT, &GPIO_InitStructure);
+
+ /* Configure USART1 Rx (PA.10) as input floating */
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
+ GPIO_Init(GPIOA, &GPIO_InitStructure);
+
+ /* Configure USART1 Tx (PA.09) as alternate function push-pull */
+ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
+ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
+ GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
+ GPIO_Init(GPIOA, &GPIO_InitStructure);
+}
+
+/*******************************************************************************
+* Function Name : Set_USBClock
+* Description : Configures USB Clock input (48MHz)
+* Input : None.
+* Return : None.
+*******************************************************************************/
+void Set_USBClock(void)
+{
+ /* USBCLK = PLLCLK / 1.5 */
+ RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5);
+ /* Enable USB clock */
+ RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);
+}
+
+/*******************************************************************************
+* Function Name : Enter_LowPowerMode
+* Description : Power-off system clocks and power while entering suspend mode
+* Input : None.
+* Return : None.
+*******************************************************************************/
+void Enter_LowPowerMode(void)
+{
+ /* Set the device state to suspend */
+ bDeviceState = SUSPENDED;
+}
+
+/*******************************************************************************
+* Function Name : Leave_LowPowerMode
+* Description : Restores system clocks and power while exiting suspend mode
+* Input : None.
+* Return : None.
+*******************************************************************************/
+void Leave_LowPowerMode(void)
+{
+ DEVICE_INFO *pInfo = &Device_Info;
+
+ /* Set the device state to the correct state */
+ if (pInfo->Current_Configuration != 0)
+ {
+ /* Device configured */
+ bDeviceState = CONFIGURED;
+ }
+ else
+ {
+ bDeviceState = ATTACHED;
+ }
+}
+
+/*******************************************************************************
+* Function Name : USB_Interrupts_Config
+* Description : Configures the USB interrupts
+* Input : None.
+* Return : None.
+*******************************************************************************/
+void USB_Interrupts_Config(void)
+{
+ NVIC_InitTypeDef NVIC_InitStructure;
+
+#ifdef VECT_TAB_RAM
+ /* Set the Vector Table base location at 0x20000000 */
+ NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
+#else /* VECT_TAB_FLASH */
+ /* Set the Vector Table base location at 0x08000000 */
+ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
+#endif
+
+ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
+
+ NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN_RX0_IRQChannel;
+ NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
+ NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
+ NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
+ NVIC_Init(&NVIC_InitStructure);
+
+ /* Enable USART1 Interrupt */
+ NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQChannel;
+ NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
+ NVIC_Init(&NVIC_InitStructure);
+}
+
+/*******************************************************************************
+* Function Name : USB_Cable_Config
+* Description : Software Connection/Disconnection of USB Cable
+* Input : None.
+* Return : Status
+*******************************************************************************/
+void USB_Cable_Config (FunctionalState NewState)
+{
+ if (NewState != DISABLE)
+ {
+ GPIO_ResetBits(USB_DISCONNECT, USB_DISCONNECT_PIN);
+ }
+ else
+ {
+ GPIO_SetBits(USB_DISCONNECT, USB_DISCONNECT_PIN);
+ }
+}
+
+/*******************************************************************************
+* Function Name : UART0_Config_Default.
+* Description : configure the UART 0 with default values.
+* Input : None.
+* Return : None.
+*******************************************************************************/
+void USART_Config_Default(void)
+{
+ /* USART1 default configuration */
+ /* USART1 configured as follow:
+ - BaudRate = 9600 baud
+ - Word Length = 8 Bits
+ - One Stop Bit
+ - Parity Odd
+ - Hardware flow control desabled
+ - Receive and transmit enabled
+ */
+ USART_InitStructure.USART_BaudRate = 9600;
+ USART_InitStructure.USART_WordLength = USART_WordLength_8b;
+ USART_InitStructure.USART_StopBits = USART_StopBits_1;
+ USART_InitStructure.USART_Parity = USART_Parity_Odd;
+ USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
+ USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
+
+ /* Configure the USART1 */
+ USART_Init(USART1, &USART_InitStructure);
+
+ /* Enable the USART Receive interrupt */
+ USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
+}
+
+/*******************************************************************************
+* Function Name : UART0_Config.
+* Description : Configure the UART 1 according to the linecoding structure.
+* Input : None.
+* Return : Configuration status
+ TRUE : configuration done with success
+ FALSE : configuration aborted.
+*******************************************************************************/
+bool USART_Config(void)
+{
+
+ /* set the Stop bit*/
+ switch (linecoding.format)
+ {
+ case 0:
+ USART_InitStructure.USART_StopBits = USART_StopBits_1;
+ break;
+ case 1:
+ USART_InitStructure.USART_StopBits = USART_StopBits_1_5;
+ break;
+ case 2:
+ USART_InitStructure.USART_StopBits = USART_StopBits_2;
+ break;
+ default :
+ {
+ USART_Config_Default();
+ return (FALSE);
+ }
+ }
+
+ /* set the parity bit*/
+ switch (linecoding.paritytype)
+ {
+ case 0:
+ USART_InitStructure.USART_Parity = USART_Parity_No;
+ break;
+ case 1:
+ USART_InitStructure.USART_Parity = USART_Parity_Even;
+ break;
+ case 2:
+ USART_InitStructure.USART_Parity = USART_Parity_Odd;
+ break;
+ default :
+ {
+ USART_Config_Default();
+ return (FALSE);
+ }
+ }
+
+ /*set the data type : only 8bits and 9bits is supported */
+ switch (linecoding.datatype)
+ {
+ case 0x07:
+ /* With this configuration a parity (Even or Odd) should be set */
+ USART_InitStructure.USART_WordLength = USART_WordLength_8b;
+ break;
+ case 0x08:
+ if (USART_InitStructure.USART_Parity == USART_Parity_No)
+ {
+ USART_InitStructure.USART_WordLength = USART_WordLength_8b;
+ }
+ else
+ {
+ USART_InitStructure.USART_WordLength = USART_WordLength_9b;
+ }
+
+ break;
+ default :
+ {
+ USART_Config_Default();
+ return (FALSE);
+ }
+ }
+
+ USART_InitStructure.USART_BaudRate = linecoding.bitrate;
+ USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
+ USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
+ USART_Init(USART1, &USART_InitStructure);
+ USART_Cmd(USART1, ENABLE);
+ return (TRUE);
+}
+
+/*******************************************************************************
+* Function Name : USB_To_UART_Send_Data.
+* Description : send the received data from USB to the UART 0.
+* Input : data_buffer: data address.
+ Nb_bytes: number of bytes to send.
+* Return : none.
+*******************************************************************************/
+void USB_To_USART_Send_Data(u8* data_buffer, u8 Nb_bytes)
+{
+ u32 i;
+
+ for (i = 0; i < Nb_bytes; i++)
+ {
+ USART_SendData(USART1, *(data_buffer + i));
+ while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
+ }
+}
+
+/*******************************************************************************
+* Function Name : UART_To_USB_Send_Data.
+* Description : send the received data from UART 0 to USB.
+* Input : None.
+* Return : none.
+*******************************************************************************/
+void USART_To_USB_Send_Data(void)
+{
+ if (linecoding.datatype == 7)
+ {
+ buffer_in[count_in] = USART_ReceiveData(USART1) & 0x7F;
+ }
+ else if (linecoding.datatype == 8)
+ {
+ buffer_in[count_in] = USART_ReceiveData(USART1);
+ }
+ count_in++;
+ UserToPMABufferCopy(buffer_in, ENDP1_TXADDR, count_in);
+ SetEPTxCount(ENDP1, count_in);
+ SetEPTxValid(ENDP1);
+}
+
+/*******************************************************************************
+* Function Name : Get_SerialNum.
+* Description : Create the serial number string descriptor.
+* Input : None.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void Get_SerialNum(void)
+{
+ u32 Device_Serial0, Device_Serial1, Device_Serial2;
+
+ Device_Serial0 = *(vu32*)(0x1FFFF7E8);
+ Device_Serial1 = *(vu32*)(0x1FFFF7EC);
+ Device_Serial2 = *(vu32*)(0x1FFFF7F0);
+
+ if (Device_Serial0 != 0)
+ {
+ Virtual_Com_Port_StringSerial[2] = (u8)(Device_Serial0 & 0x000000FF);
+ Virtual_Com_Port_StringSerial[4] = (u8)((Device_Serial0 & 0x0000FF00) >> 8);
+ Virtual_Com_Port_StringSerial[6] = (u8)((Device_Serial0 & 0x00FF0000) >> 16);
+ Virtual_Com_Port_StringSerial[8] = (u8)((Device_Serial0 & 0xFF000000) >> 24);
+
+ Virtual_Com_Port_StringSerial[10] = (u8)(Device_Serial1 & 0x000000FF);
+ Virtual_Com_Port_StringSerial[12] = (u8)((Device_Serial1 & 0x0000FF00) >> 8);
+ Virtual_Com_Port_StringSerial[14] = (u8)((Device_Serial1 & 0x00FF0000) >> 16);
+ Virtual_Com_Port_StringSerial[16] = (u8)((Device_Serial1 & 0xFF000000) >> 24);
+
+ Virtual_Com_Port_StringSerial[18] = (u8)(Device_Serial2 & 0x000000FF);
+ Virtual_Com_Port_StringSerial[20] = (u8)((Device_Serial2 & 0x0000FF00) >> 8);
+ Virtual_Com_Port_StringSerial[22] = (u8)((Device_Serial2 & 0x00FF0000) >> 16);
+ Virtual_Com_Port_StringSerial[24] = (u8)((Device_Serial2 & 0xFF000000) >> 24);
+ }
+}
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/hw_config.h b/hw_config.h
new file mode 100644
index 0000000..3a5168c
--- /dev/null
+++ b/hw_config.h
@@ -0,0 +1,48 @@
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : hw_config.h
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Hardware Configuration & Setup
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __HW_CONFIG_H
+#define __HW_CONFIG_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "usb_type.h"
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Exported macro ------------------------------------------------------------*/
+/* Exported define -----------------------------------------------------------*/
+#define MASS_MEMORY_START 0x04002000
+#define BULK_MAX_PACKET_SIZE 0x00000040
+#define LED_ON 0xF0
+#define LED_OFF 0xFF
+
+/* Exported functions ------------------------------------------------------- */
+void Set_System(void);
+void Set_USBClock(void);
+void Enter_LowPowerMode(void);
+void Leave_LowPowerMode(void);
+void USB_Interrupts_Config(void);
+void USB_Cable_Config (FunctionalState NewState);
+void USART_Config_Default(void);
+bool USART_Config(void);
+void USB_To_USART_Send_Data(u8* data_buffer, u8 Nb_bytes);
+void USART_To_USB_Send_Data(void);
+void Get_SerialNum(void);
+
+/* External variables --------------------------------------------------------*/
+
+#endif /*__HW_CONFIG_H*/
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..3cbb730
--- /dev/null
+++ b/main.c
@@ -0,0 +1,84 @@
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : main.c
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Virtual Com Port Demo main file
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_lib.h"
+#include "usb_lib.h"
+#include "usb_desc.h"
+#include "hw_config.h"
+#include "usb_pwr.h"
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+/* Extern variables ----------------------------------------------------------*/
+extern u32 count_out;
+extern u8 buffer_out[VIRTUAL_COM_PORT_DATA_SIZE];
+
+/* Private function prototypes -----------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+
+/*******************************************************************************
+* Function Name : main.
+* Description : Main routine.
+* Input : None.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+int main(void)
+{
+
+#ifdef DEBUG
+ debug();
+#endif
+
+ Set_System();
+ Set_USBClock();
+ USB_Interrupts_Config();
+ USB_Init();
+
+ while (1)
+ {
+ if ((count_out != 0) && (bDeviceState == CONFIGURED))
+ {
+ USB_To_USART_Send_Data(&buffer_out[0], count_out);
+ count_out = 0;
+ }
+ }
+}
+
+#ifdef DEBUG
+/*******************************************************************************
+* Function Name : assert_failed
+* Description : Reports the name of the source file and the source line number
+* where the assert_param error has occurred.
+* Input : - file: pointer to the source file name
+* - line: assert_param error line source number
+* Output : None
+* Return : None
+*******************************************************************************/
+void assert_failed(u8* file, u32 line)
+{
+ /* User can add his own implementation to report the file name and line number,
+ ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
+
+ /* Infinite loop */
+ while (1)
+ {}
+}
+#endif
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/platform_config.h b/platform_config.h
new file mode 100644
index 0000000..bd72506
--- /dev/null
+++ b/platform_config.h
@@ -0,0 +1,52 @@
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : platform_config.h
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Evaluation board specific configuration file.
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __PLATFORM_CONFIG_H
+#define __PLATFORM_CONFIG_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_type.h"
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Uncomment the line corresponding to the STMicroelectronics evaluation board
+ used to run the example */
+#if !defined (USE_STM3210B_EVAL) && !defined (USE_STM3210E_EVAL)
+ //#define USE_STM3210B_EVAL
+ #define USE_STM3210E_EVAL
+#endif
+
+/* Define the STM32F10x hardware depending on the used evaluation board */
+#ifdef USE_STM3210B_EVAL
+
+ #define USB_DISCONNECT GPIOD
+ #define USB_DISCONNECT_PIN GPIO_Pin_9
+ #define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOD
+
+#else /* USE_STM3210E_EVAL */
+
+ #define USB_DISCONNECT GPIOB
+ #define USB_DISCONNECT_PIN GPIO_Pin_14
+ #define RCC_APB2Periph_GPIO_DISCONNECT RCC_APB2Periph_GPIOB
+
+#endif /* USE_STM3210B_EVAL */
+
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */
+
+#endif /* __PLATFORM_CONFIG_H */
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/stm32f10x_conf.h b/stm32f10x_conf.h
new file mode 100644
index 0000000..6ec0b61
--- /dev/null
+++ b/stm32f10x_conf.h
@@ -0,0 +1,174 @@
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : stm32f10x_conf.h
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Library configuration file.
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_CONF_H
+#define __STM32F10x_CONF_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_type.h"
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Uncomment the line below to compile the library in DEBUG mode, this will expanse
+ the "assert_param" macro in the firmware library code (see "Exported macro"
+ section below) */
+/* #define DEBUG 1*/
+
+/* Comment the line below to disable the specific peripheral inclusion */
+/************************************* ADC ************************************/
+//#define _ADC
+//#define _ADC1
+//#define _ADC2
+//#define _ADC3
+
+/************************************* BKP ************************************/
+//#define _BKP
+
+/************************************* CAN ************************************/
+//#define _CAN
+
+/************************************* CRC ************************************/
+//#define _CRC
+
+/************************************* DAC ************************************/
+//#define _DAC
+
+/************************************* DBGMCU *********************************/
+//#define _DBGMCU
+
+/************************************* DMA ************************************/
+//#define _DMA
+//#define _DMA1_Channel1
+//#define _DMA1_Channel2
+//#define _DMA1_Channel3
+//#define _DMA1_Channel4
+//#define _DMA1_Channel5
+//#define _DMA1_Channel6
+//#define _DMA1_Channel7
+//#define _DMA2_Channel1
+//#define _DMA2_Channel2
+//#define _DMA2_Channel3
+//#define _DMA2_Channel4
+//#define _DMA2_Channel5
+
+/************************************* EXTI ***********************************/
+//#define _EXTI
+
+/************************************* FLASH and Option Bytes *****************/
+#define _FLASH
+/* Uncomment the line below to enable FLASH program/erase/protections functions,
+ otherwise only FLASH configuration (latency, prefetch, half cycle) functions
+ are enabled */
+/* #define _FLASH_PROG */
+
+/************************************* FSMC ***********************************/
+//#define _FSMC
+
+/************************************* GPIO ***********************************/
+#define _GPIO
+#define _GPIOA
+#define _GPIOB
+//#define _GPIOC
+#define _GPIOD
+//#define _GPIOE
+//#define _GPIOF
+//#define _GPIOG
+#define _AFIO
+
+/************************************* I2C ************************************/
+//#define _I2C
+//#define _I2C1
+//#define _I2C2
+
+/************************************* IWDG ***********************************/
+//#define _IWDG
+
+/************************************* NVIC ***********************************/
+#define _NVIC
+
+/************************************* PWR ************************************/
+//#define _PWR
+
+/************************************* RCC ************************************/
+#define _RCC
+
+/************************************* RTC ************************************/
+//#define _RTC
+
+/************************************* SDIO ***********************************/
+//#define _SDIO
+
+/************************************* SPI ************************************/
+//#define _SPI
+//#define _SPI1
+//#define _SPI2
+//#define _SPI3
+
+/************************************* SysTick ********************************/
+//#define _SysTick
+
+/************************************* TIM ************************************/
+//#define _TIM
+//#define _TIM1
+//#define _TIM2
+//#define _TIM3
+//#define _TIM4
+//#define _TIM5
+//#define _TIM6
+//#define _TIM7
+//#define _TIM8
+
+/************************************* USART **********************************/
+#define _USART
+#define _USART1
+//#define _USART2
+//#define _USART3
+//#define _UART4
+//#define _UART5
+
+/************************************* WWDG ***********************************/
+//#define _WWDG
+
+/* In the following line adjust the value of External High Speed oscillator (HSE)
+ used in your application */
+#define HSE_Value ((u32)8000000) /* Value of the External oscillator in Hz*/
+
+/* In the following line adjust the External High Speed oscillator (HSE) Startup
+ Timeout value */
+#define HSEStartUp_TimeOut ((u16)0x0500) /* Time out for HSE start up */
+
+/* Exported macro ------------------------------------------------------------*/
+#ifdef DEBUG
+/*******************************************************************************
+* Macro Name : assert_param
+* Description : The assert_param macro is used for function's parameters check.
+* It is used only if the library is compiled in DEBUG mode.
+* Input : - expr: If expr is false, it calls assert_failed function
+* which reports the name of the source file and the source
+* line number of the call that failed.
+* If expr is true, it returns no value.
+* Return : None
+*******************************************************************************/
+ #define assert_param(expr) ((expr) ? (void)0 : assert_failed((u8 *)__FILE__, __LINE__))
+/* Exported functions ------------------------------------------------------- */
+ void assert_failed(u8* file, u32 line);
+#else
+ #define assert_param(expr) ((void)0)
+#endif /* DEBUG */
+
+#endif /* __STM32F10x_CONF_H */
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/stm32f10x_it.c b/stm32f10x_it.c
new file mode 100644
index 0000000..078853b
--- /dev/null
+++ b/stm32f10x_it.c
@@ -0,0 +1,752 @@
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : stm32f10x_it.c
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Main Interrupt Service Routines.
+* This file provides template for all exceptions handler
+* and peripherals interrupt service routine.
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_it.h"
+#include "usb_lib.h"
+#include "usb_istr.h"
+#include "hw_config.h"
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+/* Private function prototypes -----------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+
+/*******************************************************************************
+* Function Name : NMIException
+* Description : This function handles NMI exception.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void NMIException(void)
+{}
+
+/*******************************************************************************
+* Function Name : HardFaultException
+* Description : This function handles Hard Fault exception.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void HardFaultException(void)
+{
+ /* Go to infinite loop when Hard Fault exception occurs */
+ while (1)
+ {}
+}
+
+/*******************************************************************************
+* Function Name : MemManageException
+* Description : This function handles Memory Manage exception.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void MemManageException(void)
+{
+ /* Go to infinite loop when Memory Manage exception occurs */
+ while (1)
+ {}
+}
+
+/*******************************************************************************
+* Function Name : BusFaultException
+* Description : This function handles Bus Fault exception.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void BusFaultException(void)
+{
+ /* Go to infinite loop when Bus Fault exception occurs */
+ while (1)
+ {}
+}
+
+/*******************************************************************************
+* Function Name : UsageFaultException
+* Description : This function handles Usage Fault exception.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void UsageFaultException(void)
+{
+ /* Go to infinite loop when Usage Fault exception occurs */
+ while (1)
+ {}
+}
+
+/*******************************************************************************
+* Function Name : DebugMonitor
+* Description : This function handles Debug Monitor exception.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void DebugMonitor(void)
+{}
+
+/*******************************************************************************
+* Function Name : SVCHandler
+* Description : This function handles SVCall exception.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void SVCHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : PendSVC
+* Description : This function handles PendSVC exception.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void PendSVC(void)
+{}
+
+/*******************************************************************************
+* Function Name : SysTickHandler
+* Description : This function handles SysTick Handler.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void SysTickHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : WWDG_IRQHandler
+* Description : This function handles WWDG interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void WWDG_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : PVD_IRQHandler
+* Description : This function handles PVD interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void PVD_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : TAMPER_IRQHandler
+* Description : This function handles Tamper interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void TAMPER_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : RTC_IRQHandler
+* Description : This function handles RTC global interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void RTC_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : FLASH_IRQHandler
+* Description : This function handles Flash interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void FLASH_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : RCC_IRQHandler
+* Description : This function handles RCC interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void RCC_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : EXTI0_IRQHandler
+* Description : This function handles External interrupt Line 0 request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void EXTI0_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : EXTI1_IRQHandler
+* Description : This function handles External interrupt Line 1 request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void EXTI1_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : EXTI2_IRQHandler
+* Description : This function handles External interrupt Line 2 request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void EXTI2_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : EXTI3_IRQHandler
+* Description : This function handles External interrupt Line 3 request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void EXTI3_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : EXTI4_IRQHandler
+* Description : This function handles External interrupt Line 4 request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void EXTI4_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : DMA1_Channel1_IRQHandler
+* Description : This function handles DMA1 Channel 1 interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void DMA1_Channel1_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : DMA1_Channel2_IRQHandler
+* Description : This function handles DMA1 Channel 2 interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void DMA1_Channel2_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : DMA1_Channel3_IRQHandler
+* Description : This function handles DMA1 Channel 3 interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void DMA1_Channel3_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : DMA1_Channel4_IRQHandler
+* Description : This function handles DMA1 Channel 4 interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void DMA1_Channel4_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : DMA1_Channel5_IRQHandler
+* Description : This function handles DMA1 Channel 5 interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void DMA1_Channel5_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : DMA1_Channel6_IRQHandler
+* Description : This function handles DMA1 Channel 6 interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void DMA1_Channel6_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : DMA1_Channel7_IRQHandler
+* Description : This function handles DMA1 Channel 7 interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void DMA1_Channel7_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : ADC1_2_IRQHandler
+* Description : This function handles ADC1 and ADC2 global interrupts requests.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void ADC1_2_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : USB_HP_CAN_TX_IRQHandler
+* Description : This function handles USB High Priority or CAN TX interrupts
+* requests.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void USB_HP_CAN_TX_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : USB_LP_CAN_RX0_IRQHandler
+* Description : This function handles USB Low Priority or CAN RX0 interrupts
+* requests.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void USB_LP_CAN_RX0_IRQHandler(void)
+{
+ USB_Istr();
+}
+
+/*******************************************************************************
+* Function Name : CAN_RX1_IRQHandler
+* Description : This function handles CAN RX1 interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void CAN_RX1_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : CAN_SCE_IRQHandler
+* Description : This function handles CAN SCE interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void CAN_SCE_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : EXTI9_5_IRQHandler
+* Description : This function handles External lines 9 to 5 interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void EXTI9_5_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : TIM1_BRK_IRQHandler
+* Description : This function handles TIM1 Break interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void TIM1_BRK_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : TIM1_UP_IRQHandler
+* Description : This function handles TIM1 overflow and update interrupt
+* request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void TIM1_UP_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : TIM1_TRG_COM_IRQHandler
+* Description : This function handles TIM1 Trigger and commutation interrupts
+* requests.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void TIM1_TRG_COM_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : TIM1_CC_IRQHandler
+* Description : This function handles TIM1 capture compare interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void TIM1_CC_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : TIM2_IRQHandler
+* Description : This function handles TIM2 global interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void TIM2_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : TIM3_IRQHandler
+* Description : This function handles TIM3 global interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void TIM3_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : TIM4_IRQHandler
+* Description : This function handles TIM4 global interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void TIM4_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : I2C1_EV_IRQHandler
+* Description : This function handles I2C1 Event interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void I2C1_EV_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : I2C1_ER_IRQHandler
+* Description : This function handles I2C1 Error interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void I2C1_ER_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : I2C2_EV_IRQHandler
+* Description : This function handles I2C2 Event interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void I2C2_EV_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : I2C2_ER_IRQHandler
+* Description : This function handles I2C2 Error interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void I2C2_ER_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : SPI1_IRQHandler
+* Description : This function handles SPI1 global interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void SPI1_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : SPI2_IRQHandler
+* Description : This function handles SPI2 global interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void SPI2_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : USART1_IRQHandler
+* Description : This function handles USART1 global interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void USART1_IRQHandler(void)
+{
+ if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
+ {
+ /* Send the received data to the PC Host*/
+ USART_To_USB_Send_Data();
+ }
+}
+
+/*******************************************************************************
+* Function Name : USART2_IRQHandler
+* Description : This function handles USART2 global interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void USART2_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : USART3_IRQHandler
+* Description : This function handles USART3 global interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void USART3_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : EXTI15_10_IRQHandler
+* Description : This function handles External lines 15 to 10 interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void EXTI15_10_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : RTCAlarm_IRQHandler
+* Description : This function handles RTC Alarm interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void RTCAlarm_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : USBWakeUp_IRQHandler
+* Description : This function handles USB WakeUp interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void USBWakeUp_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : TIM8_BRK_IRQHandler
+* Description : This function handles TIM8 Break interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void TIM8_BRK_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : TIM8_UP_IRQHandler
+* Description : This function handles TIM8 overflow and update interrupt
+* request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void TIM8_UP_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : TIM8_TRG_COM_IRQHandler
+* Description : This function handles TIM8 Trigger and commutation interrupts
+* requests.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void TIM8_TRG_COM_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : TIM8_CC_IRQHandler
+* Description : This function handles TIM8 capture compare interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void TIM8_CC_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : ADC3_IRQHandler
+* Description : This function handles ADC3 global interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void ADC3_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : FSMC_IRQHandler
+* Description : This function handles FSMC global interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void FSMC_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : SDIO_IRQHandler
+* Description : This function handles SDIO global interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void SDIO_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : TIM5_IRQHandler
+* Description : This function handles TIM5 global interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void TIM5_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : SPI3_IRQHandler
+* Description : This function handles SPI3 global interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void SPI3_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : UART4_IRQHandler
+* Description : This function handles UART4 global interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void UART4_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : UART5_IRQHandler
+* Description : This function handles UART5 global interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void UART5_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : TIM6_IRQHandler
+* Description : This function handles TIM6 global interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void TIM6_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : TIM7_IRQHandler
+* Description : This function handles TIM7 global interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void TIM7_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : DMA2_Channel1_IRQHandler
+* Description : This function handles DMA2 Channel 1 interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void DMA2_Channel1_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : DMA2_Channel2_IRQHandler
+* Description : This function handles DMA2 Channel 2 interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void DMA2_Channel2_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : DMA2_Channel3_IRQHandler
+* Description : This function handles DMA2 Channel 3 interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void DMA2_Channel3_IRQHandler(void)
+{}
+
+/*******************************************************************************
+* Function Name : DMA2_Channel4_5_IRQHandler
+* Description : This function handles DMA2 Channel 4 and DMA2 Channel 5
+* interrupt request.
+* Input : None
+* Output : None
+* Return : None
+*******************************************************************************/
+void DMA2_Channel4_5_IRQHandler(void)
+{}
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/stm32f10x_it.h b/stm32f10x_it.h
new file mode 100644
index 0000000..d7a24ab
--- /dev/null
+++ b/stm32f10x_it.h
@@ -0,0 +1,100 @@
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : stm32f10x_it.h
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : This file contains the headers of the interrupt handlers.
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __STM32F10x_IT_H
+#define __STM32F10x_IT_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_lib.h"
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */
+
+void NMIException(void);
+void HardFaultException(void);
+void MemManageException(void);
+void BusFaultException(void);
+void UsageFaultException(void);
+void DebugMonitor(void);
+void SVCHandler(void);
+void PendSVC(void);
+void SysTickHandler(void);
+void WWDG_IRQHandler(void);
+void PVD_IRQHandler(void);
+void TAMPER_IRQHandler(void);
+void RTC_IRQHandler(void);
+void FLASH_IRQHandler(void);
+void RCC_IRQHandler(void);
+void EXTI0_IRQHandler(void);
+void EXTI1_IRQHandler(void);
+void EXTI2_IRQHandler(void);
+void EXTI3_IRQHandler(void);
+void EXTI4_IRQHandler(void);
+void DMA1_Channel1_IRQHandler(void);
+void DMA1_Channel2_IRQHandler(void);
+void DMA1_Channel3_IRQHandler(void);
+void DMA1_Channel4_IRQHandler(void);
+void DMA1_Channel5_IRQHandler(void);
+void DMA1_Channel6_IRQHandler(void);
+void DMA1_Channel7_IRQHandler(void);
+void ADC1_2_IRQHandler(void);
+void USB_HP_CAN_TX_IRQHandler(void);
+void USB_LP_CAN_RX0_IRQHandler(void);
+void CAN_RX1_IRQHandler(void);
+void CAN_SCE_IRQHandler(void);
+void EXTI9_5_IRQHandler(void);
+void TIM1_BRK_IRQHandler(void);
+void TIM1_UP_IRQHandler(void);
+void TIM1_TRG_COM_IRQHandler(void);
+void TIM1_CC_IRQHandler(void);
+void TIM2_IRQHandler(void);
+void TIM3_IRQHandler(void);
+void TIM4_IRQHandler(void);
+void I2C1_EV_IRQHandler(void);
+void I2C1_ER_IRQHandler(void);
+void I2C2_EV_IRQHandler(void);
+void I2C2_ER_IRQHandler(void);
+void SPI1_IRQHandler(void);
+void SPI2_IRQHandler(void);
+void USART1_IRQHandler(void);
+void USART2_IRQHandler(void);
+void USART3_IRQHandler(void);
+void EXTI15_10_IRQHandler(void);
+void RTCAlarm_IRQHandler(void);
+void USBWakeUp_IRQHandler(void);
+void TIM8_BRK_IRQHandler(void);
+void TIM8_UP_IRQHandler(void);
+void TIM8_TRG_COM_IRQHandler(void);
+void TIM8_CC_IRQHandler(void);
+void ADC3_IRQHandler(void);
+void FSMC_IRQHandler(void);
+void SDIO_IRQHandler(void);
+void TIM5_IRQHandler(void);
+void SPI3_IRQHandler(void);
+void UART4_IRQHandler(void);
+void UART5_IRQHandler(void);
+void TIM6_IRQHandler(void);
+void TIM7_IRQHandler(void);
+void DMA2_Channel1_IRQHandler(void);
+void DMA2_Channel2_IRQHandler(void);
+void DMA2_Channel3_IRQHandler(void);
+void DMA2_Channel4_5_IRQHandler(void);
+
+#endif /* __STM32F10x_IT_H */
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/usb_conf.h b/usb_conf.h
new file mode 100644
index 0000000..d7a1993
--- /dev/null
+++ b/usb_conf.h
@@ -0,0 +1,83 @@
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_conf.h
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Virtual COM Port Demo configuration header
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USB_CONF_H
+#define __USB_CONF_H
+
+/*-------------------------------------------------------------*/
+/* EP_NUM */
+/* defines how many endpoints are used by the device */
+/*-------------------------------------------------------------*/
+
+#define EP_NUM (4)
+
+/*-------------------------------------------------------------*/
+/* -------------- Buffer Description Table -----------------*/
+/*-------------------------------------------------------------*/
+/* buffer table base address */
+/* buffer table base address */
+#define BTABLE_ADDRESS (0x00)
+
+/* EP0 */
+/* rx/tx buffer base address */
+#define ENDP0_RXADDR (0x40)
+#define ENDP0_TXADDR (0x80)
+
+/* EP1 */
+/* tx buffer base address */
+#define ENDP1_TXADDR (0xC0)
+#define ENDP2_TXADDR (0x100)
+#define ENDP3_RXADDR (0x110)
+
+
+/*-------------------------------------------------------------*/
+/* ------------------- ISTR events -------------------------*/
+/*-------------------------------------------------------------*/
+/* IMR_MSK */
+/* mask defining which events has to be handled */
+/* by the device application software */
+#define IMR_MSK (CNTR_CTRM | CNTR_SOFM | CNTR_RESETM )
+
+/*#define CTR_CALLBACK*/
+/*#define DOVR_CALLBACK*/
+/*#define ERR_CALLBACK*/
+/*#define WKUP_CALLBACK*/
+/*#define SUSP_CALLBACK*/
+/*#define RESET_CALLBACK*/
+/*#define SOF_CALLBACK*/
+/*#define ESOF_CALLBACK*/
+
+/* CTR service routines */
+/* associated to defined endpoints */
+/*#define EP1_IN_Callback NOP_Process*/
+#define EP2_IN_Callback NOP_Process
+#define EP3_IN_Callback NOP_Process
+#define EP4_IN_Callback NOP_Process
+#define EP5_IN_Callback NOP_Process
+#define EP6_IN_Callback NOP_Process
+#define EP7_IN_Callback NOP_Process
+
+#define EP1_OUT_Callback NOP_Process
+#define EP2_OUT_Callback NOP_Process
+/*#define EP3_OUT_Callback NOP_Process*/
+#define EP4_OUT_Callback NOP_Process
+#define EP5_OUT_Callback NOP_Process
+#define EP6_OUT_Callback NOP_Process
+#define EP7_OUT_Callback NOP_Process
+
+#endif /* __USB_CONF_H */
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/usb_desc.c b/usb_desc.c
new file mode 100644
index 0000000..ba7c00a
--- /dev/null
+++ b/usb_desc.c
@@ -0,0 +1,159 @@
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_desc.c
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Descriptors for Virtual Com Port Demo
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Includes ------------------------------------------------------------------*/
+#include "usb_lib.h"
+#include "usb_desc.h"
+/* USB Standard Device Descriptor */
+const u8 Virtual_Com_Port_DeviceDescriptor[] =
+ {
+ 0x12, /* bLength */
+ USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */
+ 0x00,
+ 0x02, /* bcdUSB = 2.00 */
+ 0x02, /* bDeviceClass: CDC */
+ 0x00, /* bDeviceSubClass */
+ 0x00, /* bDeviceProtocol */
+ 0x40, /* bMaxPacketSize0 */
+ 0x83,
+ 0x04, /* idVendor = 0x0483 */
+ 0x40,
+ 0x57, /* idProduct = 0x7540 */
+ 0x00,
+ 0x02, /* bcdDevice = 2.00 */
+ 1, /* Index of string descriptor describing manufacturer */
+ 2, /* Index of string descriptor describing product */
+ 3, /* Index of string descriptor describing the device's serial number */
+ 0x01 /* bNumConfigurations */
+ };
+
+const u8 Virtual_Com_Port_ConfigDescriptor[] =
+ {
+ /*Configuation Descriptor*/
+ 0x09, /* bLength: Configuation Descriptor size */
+ USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
+ VIRTUAL_COM_PORT_SIZ_CONFIG_DESC, /* wTotalLength:no of returned bytes */
+ 0x00,
+ 0x02, /* bNumInterfaces: 2 interface */
+ 0x01, /* bConfigurationValue: Configuration value */
+ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */
+ 0xC0, /* bmAttributes: self powered */
+ 0x32, /* MaxPower 0 mA */
+ /*Interface Descriptor*/
+ 0x09, /* bLength: Interface Descriptor size */
+ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: Interface */
+ /* Interface descriptor type */
+ 0x00, /* bInterfaceNumber: Number of Interface */
+ 0x00, /* bAlternateSetting: Alternate setting */
+ 0x01, /* bNumEndpoints: One endpoints used */
+ 0x02, /* bInterfaceClass: Communication Interface Class */
+ 0x02, /* bInterfaceSubClass: Abstract Control Model */
+ 0x01, /* bInterfaceProtocol: Common AT commands */
+ 0x00, /* iInterface: */
+ /*Header Functional Descriptor*/
+ 0x05, /* bLength: Endpoint Descriptor size */
+ 0x24, /* bDescriptorType: CS_INTERFACE */
+ 0x00, /* bDescriptorSubtype: Header Func Desc */
+ 0x10, /* bcdCDC: spec release number */
+ 0x01,
+ /*Call Managment Functional Descriptor*/
+ 0x05, /* bFunctionLength */
+ 0x24, /* bDescriptorType: CS_INTERFACE */
+ 0x01, /* bDescriptorSubtype: Call Management Func Desc */
+ 0x00, /* bmCapabilities: D0+D1 */
+ 0x01, /* bDataInterface: 1 */
+ /*ACM Functional Descriptor*/
+ 0x04, /* bFunctionLength */
+ 0x24, /* bDescriptorType: CS_INTERFACE */
+ 0x02, /* bDescriptorSubtype: Abstract Control Management desc */
+ 0x02, /* bmCapabilities */
+ /*Union Functional Descriptor*/
+ 0x05, /* bFunctionLength */
+ 0x24, /* bDescriptorType: CS_INTERFACE */
+ 0x06, /* bDescriptorSubtype: Union func desc */
+ 0x00, /* bMasterInterface: Communication class interface */
+ 0x01, /* bSlaveInterface0: Data Class Interface */
+ /*Endpoint 2 Descriptor*/
+ 0x07, /* bLength: Endpoint Descriptor size */
+ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
+ 0x82, /* bEndpointAddress: (IN2) */
+ 0x03, /* bmAttributes: Interrupt */
+ VIRTUAL_COM_PORT_INT_SIZE, /* wMaxPacketSize: */
+ 0x00,
+ 0xFF, /* bInterval: */
+ /*Data class interface descriptor*/
+ 0x09, /* bLength: Endpoint Descriptor size */
+ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType: */
+ 0x01, /* bInterfaceNumber: Number of Interface */
+ 0x00, /* bAlternateSetting: Alternate setting */
+ 0x02, /* bNumEndpoints: Two endpoints used */
+ 0x0A, /* bInterfaceClass: CDC */
+ 0x00, /* bInterfaceSubClass: */
+ 0x00, /* bInterfaceProtocol: */
+ 0x00, /* iInterface: */
+ /*Endpoint 3 Descriptor*/
+ 0x07, /* bLength: Endpoint Descriptor size */
+ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
+ 0x03, /* bEndpointAddress: (OUT3) */
+ 0x02, /* bmAttributes: Bulk */
+ VIRTUAL_COM_PORT_DATA_SIZE, /* wMaxPacketSize: */
+ 0x00,
+ 0x00, /* bInterval: ignore for Bulk transfer */
+ /*Endpoint 1 Descriptor*/
+ 0x07, /* bLength: Endpoint Descriptor size */
+ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: Endpoint */
+ 0x81, /* bEndpointAddress: (IN1) */
+ 0x02, /* bmAttributes: Bulk */
+ VIRTUAL_COM_PORT_DATA_SIZE, /* wMaxPacketSize: */
+ 0x00,
+ 0x00 /* bInterval */
+ };
+
+/* USB String Descriptors */
+const u8 Virtual_Com_Port_StringLangID[VIRTUAL_COM_PORT_SIZ_STRING_LANGID] =
+ {
+ VIRTUAL_COM_PORT_SIZ_STRING_LANGID,
+ USB_STRING_DESCRIPTOR_TYPE,
+ 0x09,
+ 0x04 /* LangID = 0x0409: U.S. English */
+ };
+
+const u8 Virtual_Com_Port_StringVendor[VIRTUAL_COM_PORT_SIZ_STRING_VENDOR] =
+ {
+ VIRTUAL_COM_PORT_SIZ_STRING_VENDOR, /* Size of Vendor string */
+ USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType*/
+ /* Manufacturer: "STMicroelectronics" */
+ 'S', 0, 'T', 0, 'M', 0, 'i', 0, 'c', 0, 'r', 0, 'o', 0, 'e', 0,
+ 'l', 0, 'e', 0, 'c', 0, 't', 0, 'r', 0, 'o', 0, 'n', 0, 'i', 0,
+ 'c', 0, 's', 0
+ };
+
+const u8 Virtual_Com_Port_StringProduct[VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT] =
+ {
+ VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT, /* bLength */
+ USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
+ /* Product name: "STM32 Virtual COM Port" */
+ 'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, ' ', 0, 'V', 0, 'i', 0,
+ 'r', 0, 't', 0, 'u', 0, 'a', 0, 'l', 0, ' ', 0, 'C', 0, 'O', 0,
+ 'M', 0, ' ', 0, 'P', 0, 'o', 0, 'r', 0, 't', 0, ' ', 0, ' ', 0
+ };
+
+u8 Virtual_Com_Port_StringSerial[VIRTUAL_COM_PORT_SIZ_STRING_SERIAL] =
+ {
+ VIRTUAL_COM_PORT_SIZ_STRING_SERIAL, /* bLength */
+ USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
+ 'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, '1', 0, '0', 0
+ }
+ ;/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/usb_desc.h b/usb_desc.h
new file mode 100644
index 0000000..8a2000d
--- /dev/null
+++ b/usb_desc.h
@@ -0,0 +1,53 @@
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_desc.h
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Descriptor Header for Virtual COM Port Device
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USB_DESC_H
+#define __USB_DESC_H
+
+/* Includes ------------------------------------------------------------------*/
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Exported macro ------------------------------------------------------------*/
+/* Exported define -----------------------------------------------------------*/
+#define USB_DEVICE_DESCRIPTOR_TYPE 0x01
+#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
+#define USB_STRING_DESCRIPTOR_TYPE 0x03
+#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
+#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
+
+#define VIRTUAL_COM_PORT_DATA_SIZE 64
+#define VIRTUAL_COM_PORT_INT_SIZE 8
+
+#define VIRTUAL_COM_PORT_SIZ_DEVICE_DESC 18
+#define VIRTUAL_COM_PORT_SIZ_CONFIG_DESC 67
+#define VIRTUAL_COM_PORT_SIZ_STRING_LANGID 4
+#define VIRTUAL_COM_PORT_SIZ_STRING_VENDOR 38
+#define VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT 50
+#define VIRTUAL_COM_PORT_SIZ_STRING_SERIAL 26
+
+#define STANDARD_ENDPOINT_DESC_SIZE 0x09
+
+/* Exported functions ------------------------------------------------------- */
+extern const u8 Virtual_Com_Port_DeviceDescriptor[VIRTUAL_COM_PORT_SIZ_DEVICE_DESC];
+extern const u8 Virtual_Com_Port_ConfigDescriptor[VIRTUAL_COM_PORT_SIZ_CONFIG_DESC];
+
+extern const u8 Virtual_Com_Port_StringLangID[VIRTUAL_COM_PORT_SIZ_STRING_LANGID];
+extern const u8 Virtual_Com_Port_StringVendor[VIRTUAL_COM_PORT_SIZ_STRING_VENDOR];
+extern const u8 Virtual_Com_Port_StringProduct[VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT];
+extern u8 Virtual_Com_Port_StringSerial[VIRTUAL_COM_PORT_SIZ_STRING_SERIAL];
+
+#endif /* __USB_DESC_H */
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/usb_endp.c b/usb_endp.c
new file mode 100644
index 0000000..7e0ef87
--- /dev/null
+++ b/usb_endp.c
@@ -0,0 +1,60 @@
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_endp.c
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Endpoint routines
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Includes ------------------------------------------------------------------*/
+#include "usb_lib.h"
+#include "usb_desc.h"
+#include "usb_mem.h"
+#include "hw_config.h"
+#include "usb_istr.h"
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+u8 buffer_out[VIRTUAL_COM_PORT_DATA_SIZE];
+u32 count_out = 0;
+u32 count_in = 0;
+
+/* Private function prototypes -----------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+/*******************************************************************************
+* Function Name : EP3_IN_Callback
+* Description :
+* Input : None.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void EP3_OUT_Callback(void)
+{
+ count_out = GetEPRxCount(ENDP3);
+ PMAToUserBufferCopy(buffer_out, ENDP3_RXADDR, count_out);
+ SetEPRxValid(ENDP3);
+}
+
+/*******************************************************************************
+* Function Name : EP1_IN_Callback
+* Description :
+* Input : None.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void EP1_IN_Callback(void)
+{
+ count_in = 0;
+}
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
+
diff --git a/usb_istr.c b/usb_istr.c
new file mode 100644
index 0000000..c54ef28
--- /dev/null
+++ b/usb_istr.c
@@ -0,0 +1,170 @@
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_istr.c
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : ISTR events interrupt service routines
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Includes ------------------------------------------------------------------*/
+#include "usb_lib.h"
+#include "usb_prop.h"
+#include "usb_pwr.h"
+#include "usb_istr.h"
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+volatile u16 wIstr; /* ISTR register last read value */
+volatile u8 bIntPackSOF = 0; /* SOFs received between 2 consecutive packets */
+
+/* Extern variables ----------------------------------------------------------*/
+/* Private function prototypes -----------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+/* function pointers to non-control endpoints service routines */
+void (*pEpInt_IN[7])(void) =
+ {
+ EP1_IN_Callback,
+ EP2_IN_Callback,
+ EP3_IN_Callback,
+ EP4_IN_Callback,
+ EP5_IN_Callback,
+ EP6_IN_Callback,
+ EP7_IN_Callback,
+ };
+
+void (*pEpInt_OUT[7])(void) =
+ {
+ EP1_OUT_Callback,
+ EP2_OUT_Callback,
+ EP3_OUT_Callback,
+ EP4_OUT_Callback,
+ EP5_OUT_Callback,
+ EP6_OUT_Callback,
+ EP7_OUT_Callback,
+ };
+
+
+/*******************************************************************************
+* Function Name : USB_Istr.
+* Description : ISTR events interrupt service routine.
+* Input : None.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void USB_Istr(void)
+{
+
+ wIstr = _GetISTR();
+
+#if (IMR_MSK & ISTR_RESET)
+ if (wIstr & ISTR_RESET & wInterrupt_Mask)
+ {
+ _SetISTR((u16)CLR_RESET);
+ Device_Property.Reset();
+#ifdef RESET_CALLBACK
+ RESET_Callback();
+#endif
+ }
+#endif
+ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+#if (IMR_MSK & ISTR_DOVR)
+ if (wIstr & ISTR_DOVR & wInterrupt_Mask)
+ {
+ _SetISTR((u16)CLR_DOVR);
+#ifdef DOVR_CALLBACK
+ DOVR_Callback();
+#endif
+ }
+#endif
+ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+#if (IMR_MSK & ISTR_ERR)
+ if (wIstr & ISTR_ERR & wInterrupt_Mask)
+ {
+ _SetISTR((u16)CLR_ERR);
+#ifdef ERR_CALLBACK
+ ERR_Callback();
+#endif
+ }
+#endif
+ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+#if (IMR_MSK & ISTR_WKUP)
+ if (wIstr & ISTR_WKUP & wInterrupt_Mask)
+ {
+ _SetISTR((u16)CLR_WKUP);
+ Resume(RESUME_EXTERNAL);
+#ifdef WKUP_CALLBACK
+ WKUP_Callback();
+#endif
+ }
+#endif
+ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+#if (IMR_MSK & ISTR_SUSP)
+ if (wIstr & ISTR_SUSP & wInterrupt_Mask)
+ {
+
+ /* check if SUSPEND is possible */
+ if (fSuspendEnabled)
+ {
+ Suspend();
+ }
+ else
+ {
+ /* if not possible then resume after xx ms */
+ Resume(RESUME_LATER);
+ }
+ /* clear of the ISTR bit must be done after setting of CNTR_FSUSP */
+ _SetISTR((u16)CLR_SUSP);
+#ifdef SUSP_CALLBACK
+ SUSP_Callback();
+#endif
+ }
+#endif
+ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+#if (IMR_MSK & ISTR_SOF)
+ if (wIstr & ISTR_SOF & wInterrupt_Mask)
+ {
+ _SetISTR((u16)CLR_SOF);
+ bIntPackSOF++;
+
+#ifdef SOF_CALLBACK
+ SOF_Callback();
+#endif
+ }
+#endif
+ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+#if (IMR_MSK & ISTR_ESOF)
+ if (wIstr & ISTR_ESOF & wInterrupt_Mask)
+ {
+ _SetISTR((u16)CLR_ESOF);
+ /* resume handling timing is made with ESOFs */
+ Resume(RESUME_ESOF); /* request without change of the machine state */
+
+#ifdef ESOF_CALLBACK
+ ESOF_Callback();
+#endif
+ }
+#endif
+ /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
+#if (IMR_MSK & ISTR_CTR)
+ if (wIstr & ISTR_CTR & wInterrupt_Mask)
+ {
+ /* servicing of the endpoint correct transfer interrupt */
+ /* clear of the CTR flag into the sub */
+ CTR_LP();
+#ifdef CTR_CALLBACK
+ CTR_Callback();
+#endif
+ }
+#endif
+} /* USB_Istr */
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/usb_istr.h b/usb_istr.h
new file mode 100644
index 0000000..5e18601
--- /dev/null
+++ b/usb_istr.h
@@ -0,0 +1,82 @@
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_istr.h
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : This file includes the peripherals header files in the
+* user application.
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USB_ISTR_H
+#define __USB_ISTR_H
+
+/* Includes ------------------------------------------------------------------*/
+#include "usb_conf.h"
+
+/* Exported types ------------------------------------------------------------*/
+/* Exported constants --------------------------------------------------------*/
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */
+void USB_Istr(void);
+
+/* function prototypes Automatically built defining related macros */
+
+#ifdef CTR_CALLBACK
+ void CTR_Callback(void);
+#endif
+
+#ifdef DOVR_CALLBACK
+ void DOVR_Callback(void);
+#endif
+
+#ifdef ERR_CALLBACK
+ void ERR_Callback(void);
+#endif
+
+#ifdef WKUP_CALLBACK
+ void WKUP_Callback(void);
+#endif
+
+#ifdef SUSP_CALLBACK
+ void SUSP_Callback(void);
+#endif
+
+#ifdef RESET_CALLBACK
+ void RESET_Callback(void);
+#endif
+
+#ifdef SOF_CALLBACK
+ void SOF_Callback(void);
+#endif
+
+#ifdef ESOF_CALLBACK
+ void ESOF_Callback(void);
+#endif
+
+void EP1_IN_Callback(void);
+void EP2_IN_Callback(void);
+void EP3_IN_Callback(void);
+void EP4_IN_Callback(void);
+void EP5_IN_Callback(void);
+void EP6_IN_Callback(void);
+void EP7_IN_Callback(void);
+
+void EP1_OUT_Callback(void);
+void EP2_OUT_Callback(void);
+void EP3_OUT_Callback(void);
+void EP4_OUT_Callback(void);
+void EP5_OUT_Callback(void);
+void EP6_OUT_Callback(void);
+void EP7_OUT_Callback(void);
+
+#endif /*__USB_ISTR_H*/
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/usb_prop.c b/usb_prop.c
new file mode 100644
index 0000000..44ac0ff
--- /dev/null
+++ b/usb_prop.c
@@ -0,0 +1,407 @@
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_prop.c
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : All processing related to Virtual Com Port Demo
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Includes ------------------------------------------------------------------*/
+#include "usb_lib.h"
+#include "usb_conf.h"
+#include "usb_prop.h"
+#include "usb_desc.h"
+#include "usb_pwr.h"
+#include "hw_config.h"
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+u8 Request = 0;
+
+LINE_CODING linecoding =
+ {
+ 115200, /* baud rate*/
+ 0x00, /* stop bits-1*/
+ 0x00, /* parity - none*/
+ 0x08 /* no. of bits 8*/
+ };
+
+/* -------------------------------------------------------------------------- */
+/* Structures initializations */
+/* -------------------------------------------------------------------------- */
+
+DEVICE Device_Table =
+ {
+ EP_NUM,
+ 1
+ };
+
+DEVICE_PROP Device_Property =
+ {
+ Virtual_Com_Port_init,
+ Virtual_Com_Port_Reset,
+ Virtual_Com_Port_Status_In,
+ Virtual_Com_Port_Status_Out,
+ Virtual_Com_Port_Data_Setup,
+ Virtual_Com_Port_NoData_Setup,
+ Virtual_Com_Port_Get_Interface_Setting,
+ Virtual_Com_Port_GetDeviceDescriptor,
+ Virtual_Com_Port_GetConfigDescriptor,
+ Virtual_Com_Port_GetStringDescriptor,
+ 0,
+ 0x40 /*MAX PACKET SIZE*/
+ };
+
+USER_STANDARD_REQUESTS User_Standard_Requests =
+ {
+ Virtual_Com_Port_GetConfiguration,
+ Virtual_Com_Port_SetConfiguration,
+ Virtual_Com_Port_GetInterface,
+ Virtual_Com_Port_SetInterface,
+ Virtual_Com_Port_GetStatus,
+ Virtual_Com_Port_ClearFeature,
+ Virtual_Com_Port_SetEndPointFeature,
+ Virtual_Com_Port_SetDeviceFeature,
+ Virtual_Com_Port_SetDeviceAddress
+ };
+
+ONE_DESCRIPTOR Device_Descriptor =
+ {
+ (u8*)Virtual_Com_Port_DeviceDescriptor,
+ VIRTUAL_COM_PORT_SIZ_DEVICE_DESC
+ };
+
+ONE_DESCRIPTOR Config_Descriptor =
+ {
+ (u8*)Virtual_Com_Port_ConfigDescriptor,
+ VIRTUAL_COM_PORT_SIZ_CONFIG_DESC
+ };
+
+ONE_DESCRIPTOR String_Descriptor[4] =
+ {
+ {(u8*)Virtual_Com_Port_StringLangID, VIRTUAL_COM_PORT_SIZ_STRING_LANGID},
+ {(u8*)Virtual_Com_Port_StringVendor, VIRTUAL_COM_PORT_SIZ_STRING_VENDOR},
+ {(u8*)Virtual_Com_Port_StringProduct, VIRTUAL_COM_PORT_SIZ_STRING_PRODUCT},
+ {(u8*)Virtual_Com_Port_StringSerial, VIRTUAL_COM_PORT_SIZ_STRING_SERIAL}
+ };
+
+/* Extern variables ----------------------------------------------------------*/
+/* Private function prototypes -----------------------------------------------*/
+/* Extern function prototypes ------------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+/*******************************************************************************
+* Function Name : Virtual_Com_Port_init.
+* Description : Virtual COM Port Mouse init routine.
+* Input : None.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void Virtual_Com_Port_init(void)
+{
+
+ /* Update the serial number string descriptor with the data from the unique
+ ID*/
+ Get_SerialNum();
+
+ pInformation->Current_Configuration = 0;
+
+ /* Connect the device */
+ PowerOn();
+ /* USB interrupts initialization */
+ /* clear pending interrupts */
+ _SetISTR(0);
+ wInterrupt_Mask = IMR_MSK;
+ /* set interrupts mask */
+ _SetCNTR(wInterrupt_Mask);
+
+ /* configure the USART 1 to the default settings */
+ USART_Config_Default();
+
+ bDeviceState = UNCONNECTED;
+}
+
+/*******************************************************************************
+* Function Name : Virtual_Com_Port_Reset
+* Description : Virtual_Com_Port Mouse reset routine
+* Input : None.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void Virtual_Com_Port_Reset(void)
+{
+ /* Set Virtual_Com_Port DEVICE as not configured */
+ pInformation->Current_Configuration = 0;
+
+ /* Current Feature initialization */
+ pInformation->Current_Feature = Virtual_Com_Port_ConfigDescriptor[7];
+
+ /* Set Virtual_Com_Port DEVICE with the default Interface*/
+ pInformation->Current_Interface = 0;
+ SetBTABLE(BTABLE_ADDRESS);
+
+ /* Initialize Endpoint 0 */
+ SetEPType(ENDP0, EP_CONTROL);
+ SetEPTxStatus(ENDP0, EP_TX_STALL);
+ SetEPRxAddr(ENDP0, ENDP0_RXADDR);
+ SetEPTxAddr(ENDP0, ENDP0_TXADDR);
+ Clear_Status_Out(ENDP0);
+ SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
+ SetEPRxValid(ENDP0);
+
+ /* Initialize Endpoint 1 */
+ SetEPType(ENDP1, EP_BULK);
+ SetEPTxAddr(ENDP1, ENDP1_TXADDR);
+ SetEPTxStatus(ENDP1, EP_TX_NAK);
+ SetEPRxStatus(ENDP1, EP_RX_DIS);
+
+ /* Initialize Endpoint 2 */
+ SetEPType(ENDP2, EP_INTERRUPT);
+ SetEPTxAddr(ENDP2, ENDP2_TXADDR);
+ SetEPRxStatus(ENDP2, EP_RX_DIS);
+ SetEPTxStatus(ENDP2, EP_TX_NAK);
+
+ /* Initialize Endpoint 3 */
+ SetEPType(ENDP3, EP_BULK);
+ SetEPRxAddr(ENDP3, ENDP3_RXADDR);
+ SetEPRxCount(ENDP3, VIRTUAL_COM_PORT_DATA_SIZE);
+ SetEPRxStatus(ENDP3, EP_RX_VALID);
+ SetEPTxStatus(ENDP3, EP_TX_DIS);
+
+ /* Set this device to response on default address */
+ SetDeviceAddress(0);
+
+ bDeviceState = ATTACHED;
+}
+
+/*******************************************************************************
+* Function Name : Virtual_Com_Port_SetConfiguration.
+* Description : Udpade the device state to configured.
+* Input : None.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void Virtual_Com_Port_SetConfiguration(void)
+{
+ DEVICE_INFO *pInfo = &Device_Info;
+
+ if (pInfo->Current_Configuration != 0)
+ {
+ /* Device configured */
+ bDeviceState = CONFIGURED;
+ }
+}
+
+/*******************************************************************************
+* Function Name : Virtual_Com_Port_SetConfiguration.
+* Description : Udpade the device state to addressed.
+* Input : None.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void Virtual_Com_Port_SetDeviceAddress (void)
+{
+ bDeviceState = ADDRESSED;
+}
+
+/*******************************************************************************
+* Function Name : Virtual_Com_Port_Status_In.
+* Description : Virtual COM Port Status In Routine.
+* Input : None.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void Virtual_Com_Port_Status_In(void)
+{
+ if (Request == SET_LINE_CODING)
+ {
+ USART_Config();
+ Request = 0;
+ }
+}
+
+/*******************************************************************************
+* Function Name : Virtual_Com_Port_Status_Out
+* Description : Virtual COM Port Status OUT Routine.
+* Input : None.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void Virtual_Com_Port_Status_Out(void)
+{}
+
+/*******************************************************************************
+* Function Name : Virtual_Com_Port_Data_Setup
+* Description : handle the data class specific requests
+* Input : Request Nb.
+* Output : None.
+* Return : USB_UNSUPPORT or USB_SUCCESS.
+*******************************************************************************/
+RESULT Virtual_Com_Port_Data_Setup(u8 RequestNo)
+{
+ u8 *(*CopyRoutine)(u16);
+
+ CopyRoutine = NULL;
+
+ if (RequestNo == GET_LINE_CODING)
+ {
+ if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
+ {
+ CopyRoutine = Virtual_Com_Port_GetLineCoding;
+ }
+ }
+ else if (RequestNo == SET_LINE_CODING)
+ {
+ if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
+ {
+ CopyRoutine = Virtual_Com_Port_SetLineCoding;
+ }
+ Request = SET_LINE_CODING;
+ }
+
+ if (CopyRoutine == NULL)
+ {
+ return USB_UNSUPPORT;
+ }
+
+ pInformation->Ctrl_Info.CopyData = CopyRoutine;
+ pInformation->Ctrl_Info.Usb_wOffset = 0;
+ (*CopyRoutine)(0);
+ return USB_SUCCESS;
+}
+
+/*******************************************************************************
+* Function Name : Virtual_Com_Port_NoData_Setup.
+* Description : handle the no data class specific requests.
+* Input : Request Nb.
+* Output : None.
+* Return : USB_UNSUPPORT or USB_SUCCESS.
+*******************************************************************************/
+RESULT Virtual_Com_Port_NoData_Setup(u8 RequestNo)
+{
+
+ if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
+ {
+ if (RequestNo == SET_COMM_FEATURE)
+ {
+ return USB_SUCCESS;
+ }
+ else if (RequestNo == SET_CONTROL_LINE_STATE)
+ {
+ return USB_SUCCESS;
+ }
+ }
+
+ return USB_UNSUPPORT;
+}
+
+/*******************************************************************************
+* Function Name : Virtual_Com_Port_GetDeviceDescriptor.
+* Description : Gets the device descriptor.
+* Input : Length.
+* Output : None.
+* Return : The address of the device descriptor.
+*******************************************************************************/
+u8 *Virtual_Com_Port_GetDeviceDescriptor(u16 Length)
+{
+ return Standard_GetDescriptorData(Length, &Device_Descriptor);
+}
+
+/*******************************************************************************
+* Function Name : Virtual_Com_Port_GetConfigDescriptor.
+* Description : get the configuration descriptor.
+* Input : Length.
+* Output : None.
+* Return : The address of the configuration descriptor.
+*******************************************************************************/
+u8 *Virtual_Com_Port_GetConfigDescriptor(u16 Length)
+{
+ return Standard_GetDescriptorData(Length, &Config_Descriptor);
+}
+
+/*******************************************************************************
+* Function Name : Virtual_Com_Port_GetStringDescriptor
+* Description : Gets the string descriptors according to the needed index
+* Input : Length.
+* Output : None.
+* Return : The address of the string descriptors.
+*******************************************************************************/
+u8 *Virtual_Com_Port_GetStringDescriptor(u16 Length)
+{
+ u8 wValue0 = pInformation->USBwValue0;
+ if (wValue0 > 4)
+ {
+ return NULL;
+ }
+ else
+ {
+ return Standard_GetDescriptorData(Length, &String_Descriptor[wValue0]);
+ }
+}
+
+/*******************************************************************************
+* Function Name : Virtual_Com_Port_Get_Interface_Setting.
+* Description : test the interface and the alternate setting according to the
+* supported one.
+* Input1 : u8: Interface : interface number.
+* Input2 : u8: AlternateSetting : Alternate Setting number.
+* Output : None.
+* Return : The address of the string descriptors.
+*******************************************************************************/
+RESULT Virtual_Com_Port_Get_Interface_Setting(u8 Interface, u8 AlternateSetting)
+{
+ if (AlternateSetting > 0)
+ {
+ return USB_UNSUPPORT;
+ }
+ else if (Interface > 1)
+ {
+ return USB_UNSUPPORT;
+ }
+ return USB_SUCCESS;
+}
+
+/*******************************************************************************
+* Function Name : Virtual_Com_Port_GetLineCoding.
+* Description : send the linecoding structure to the PC host.
+* Input : Length.
+* Output : None.
+* Return : Inecoding structure base address.
+*******************************************************************************/
+u8 *Virtual_Com_Port_GetLineCoding(u16 Length)
+{
+ if (Length == 0)
+ {
+ pInformation->Ctrl_Info.Usb_wLength = sizeof(linecoding);
+ return NULL;
+ }
+ return(u8 *)&linecoding;
+}
+
+/*******************************************************************************
+* Function Name : Virtual_Com_Port_SetLineCoding.
+* Description : Set the linecoding structure fields.
+* Input : Length.
+* Output : None.
+* Return : Linecoding structure base address.
+*******************************************************************************/
+u8 *Virtual_Com_Port_SetLineCoding(u16 Length)
+{
+ if (Length == 0)
+ {
+ pInformation->Ctrl_Info.Usb_wLength = sizeof(linecoding);
+ return NULL;
+ }
+ return(u8 *)&linecoding;
+}
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
+
diff --git a/usb_prop.h b/usb_prop.h
new file mode 100644
index 0000000..ee9b1cd
--- /dev/null
+++ b/usb_prop.h
@@ -0,0 +1,74 @@
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_prop.h
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : All processing related to Virtual COM Port Demo (Endpoint 0)
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __usb_prop_H
+#define __usb_prop_H
+
+/* Includes ------------------------------------------------------------------*/
+/* Exported types ------------------------------------------------------------*/
+typedef struct
+{
+ u32 bitrate;
+ u8 format;
+ u8 paritytype;
+ u8 datatype;
+}LINE_CODING;
+
+/* Exported constants --------------------------------------------------------*/
+/* Exported macro ------------------------------------------------------------*/
+/* Exported define -----------------------------------------------------------*/
+
+#define Virtual_Com_Port_GetConfiguration NOP_Process
+//#define Virtual_Com_Port_SetConfiguration NOP_Process
+#define Virtual_Com_Port_GetInterface NOP_Process
+#define Virtual_Com_Port_SetInterface NOP_Process
+#define Virtual_Com_Port_GetStatus NOP_Process
+#define Virtual_Com_Port_ClearFeature NOP_Process
+#define Virtual_Com_Port_SetEndPointFeature NOP_Process
+#define Virtual_Com_Port_SetDeviceFeature NOP_Process
+//#define Virtual_Com_Port_SetDeviceAddress NOP_Process
+
+#define SEND_ENCAPSULATED_COMMAND 0x00
+#define GET_ENCAPSULATED_RESPONSE 0x01
+#define SET_COMM_FEATURE 0x02
+#define GET_COMM_FEATURE 0x03
+#define CLEAR_COMM_FEATURE 0x04
+#define SET_LINE_CODING 0x20
+#define GET_LINE_CODING 0x21
+#define SET_CONTROL_LINE_STATE 0x22
+#define SEND_BREAK 0x23
+
+/* Exported functions ------------------------------------------------------- */
+void Virtual_Com_Port_init(void);
+void Virtual_Com_Port_Reset(void);
+void Virtual_Com_Port_SetConfiguration(void);
+void Virtual_Com_Port_SetDeviceAddress (void);
+void Virtual_Com_Port_Status_In (void);
+void Virtual_Com_Port_Status_Out (void);
+RESULT Virtual_Com_Port_Data_Setup(u8);
+RESULT Virtual_Com_Port_NoData_Setup(u8);
+RESULT Virtual_Com_Port_Get_Interface_Setting(u8 Interface, u8 AlternateSetting);
+u8 *Virtual_Com_Port_GetDeviceDescriptor(u16 );
+u8 *Virtual_Com_Port_GetConfigDescriptor(u16);
+u8 *Virtual_Com_Port_GetStringDescriptor(u16);
+
+u8 *Virtual_Com_Port_GetLineCoding(u16 Length);
+u8 *Virtual_Com_Port_SetLineCoding(u16 Length);
+
+#endif /* __usb_prop_H */
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
+
diff --git a/usb_pwr.c b/usb_pwr.c
new file mode 100644
index 0000000..5395605
--- /dev/null
+++ b/usb_pwr.c
@@ -0,0 +1,223 @@
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_pwr.c
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Connection/disconnection & power management
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Includes ------------------------------------------------------------------*/
+#include "stm32f10x_lib.h"
+#include "usb_lib.h"
+#include "usb_conf.h"
+#include "usb_pwr.h"
+#include "hw_config.h"
+
+/* Private typedef -----------------------------------------------------------*/
+/* Private define ------------------------------------------------------------*/
+/* Private macro -------------------------------------------------------------*/
+/* Private variables ---------------------------------------------------------*/
+vu32 bDeviceState = UNCONNECTED; /* USB device status */
+volatile bool fSuspendEnabled = TRUE; /* True when suspend is possible */
+
+struct
+{
+ volatile RESUME_STATE eState;
+ volatile u8 bESOFcnt;
+}
+ResumeS;
+
+/* Extern variables ----------------------------------------------------------*/
+/* Private function prototypes -----------------------------------------------*/
+/* Extern function prototypes ------------------------------------------------*/
+/* Private functions ---------------------------------------------------------*/
+
+/*******************************************************************************
+* Function Name : PowerOn
+* Description : USB IP power ON Routine.
+* Input : None.
+* Output : None.
+* Return : USB_SUCCESS.
+*******************************************************************************/
+RESULT PowerOn(void)
+{
+ u16 wRegVal;
+
+ /*** cable plugged-in ? ***/
+ USB_Cable_Config(ENABLE);
+
+ /*** CNTR_PWDN = 0 ***/
+ wRegVal = CNTR_FRES;
+ _SetCNTR(wRegVal);
+
+ /*** CNTR_FRES = 0 ***/
+ wInterrupt_Mask = 0;
+ _SetCNTR(wInterrupt_Mask);
+ /*** Clear pending interrupts ***/
+ _SetISTR(0);
+ /*** Set interrupt mask ***/
+ wInterrupt_Mask = CNTR_RESETM | CNTR_SUSPM | CNTR_WKUPM;
+ _SetCNTR(wInterrupt_Mask);
+
+ return USB_SUCCESS;
+}
+
+/*******************************************************************************
+* Function Name : PowerOff
+* Description : Handles switch-off conditions
+* Input : None.
+* Output : None.
+* Return : USB_SUCCESS.
+*******************************************************************************/
+RESULT PowerOff()
+{
+ /* disable all ints and force USB reset */
+ _SetCNTR(CNTR_FRES);
+ /* clear interrupt status register */
+ _SetISTR(0);
+ /* Disable the Pull-Up*/
+ USB_Cable_Config(DISABLE);
+ /* switch-off device */
+ _SetCNTR(CNTR_FRES + CNTR_PDWN);
+ /* sw variables reset */
+ /* ... */
+
+ return USB_SUCCESS;
+}
+
+/*******************************************************************************
+* Function Name : Suspend
+* Description : sets suspend mode operating conditions
+* Input : None.
+* Output : None.
+* Return : USB_SUCCESS.
+*******************************************************************************/
+void Suspend(void)
+{
+ u16 wCNTR;
+ /* suspend preparation */
+ /* ... */
+
+ /* macrocell enters suspend mode */
+ wCNTR = _GetCNTR();
+ wCNTR |= CNTR_FSUSP;
+ _SetCNTR(wCNTR);
+
+ /* ------------------ ONLY WITH BUS-POWERED DEVICES ---------------------- */
+ /* power reduction */
+ /* ... on connected devices */
+
+
+ /* force low-power mode in the macrocell */
+ wCNTR = _GetCNTR();
+ wCNTR |= CNTR_LPMODE;
+ _SetCNTR(wCNTR);
+
+ /* switch-off the clocks */
+ /* ... */
+ Enter_LowPowerMode();
+
+}
+
+/*******************************************************************************
+* Function Name : Resume_Init
+* Description : Handles wake-up restoring normal operations
+* Input : None.
+* Output : None.
+* Return : USB_SUCCESS.
+*******************************************************************************/
+void Resume_Init(void)
+{
+ u16 wCNTR;
+ /* ------------------ ONLY WITH BUS-POWERED DEVICES ---------------------- */
+ /* restart the clocks */
+ /* ... */
+
+ /* CNTR_LPMODE = 0 */
+ wCNTR = _GetCNTR();
+ wCNTR &= (~CNTR_LPMODE);
+ _SetCNTR(wCNTR);
+
+ /* restore full power */
+ /* ... on connected devices */
+ Leave_LowPowerMode();
+
+ /* reset FSUSP bit */
+ _SetCNTR(IMR_MSK);
+
+ /* reverse suspend preparation */
+ /* ... */
+
+}
+
+/*******************************************************************************
+* Function Name : Resume
+* Description : This is the state machine handling resume operations and
+* timing sequence. The control is based on the Resume structure
+* variables and on the ESOF interrupt calling this subroutine
+* without changing machine state.
+* Input : a state machine value (RESUME_STATE)
+* RESUME_ESOF doesn't change ResumeS.eState allowing
+* decrementing of the ESOF counter in different states.
+* Output : None.
+* Return : None.
+*******************************************************************************/
+void Resume(RESUME_STATE eResumeSetVal)
+{
+ u16 wCNTR;
+
+ if (eResumeSetVal != RESUME_ESOF)
+ ResumeS.eState = eResumeSetVal;
+
+ switch (ResumeS.eState)
+ {
+ case RESUME_EXTERNAL:
+ Resume_Init();
+ ResumeS.eState = RESUME_OFF;
+ break;
+ case RESUME_INTERNAL:
+ Resume_Init();
+ ResumeS.eState = RESUME_START;
+ break;
+ case RESUME_LATER:
+ ResumeS.bESOFcnt = 2;
+ ResumeS.eState = RESUME_WAIT;
+ break;
+ case RESUME_WAIT:
+ ResumeS.bESOFcnt--;
+ if (ResumeS.bESOFcnt == 0)
+ ResumeS.eState = RESUME_START;
+ break;
+ case RESUME_START:
+ wCNTR = _GetCNTR();
+ wCNTR |= CNTR_RESUME;
+ _SetCNTR(wCNTR);
+ ResumeS.eState = RESUME_ON;
+ ResumeS.bESOFcnt = 10;
+ break;
+ case RESUME_ON:
+ ResumeS.bESOFcnt--;
+ if (ResumeS.bESOFcnt == 0)
+ {
+ wCNTR = _GetCNTR();
+ wCNTR &= (~CNTR_RESUME);
+ _SetCNTR(wCNTR);
+ ResumeS.eState = RESUME_OFF;
+ }
+ break;
+ case RESUME_OFF:
+ case RESUME_ESOF:
+ default:
+ ResumeS.eState = RESUME_OFF;
+ break;
+ }
+}
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
diff --git a/usb_pwr.h b/usb_pwr.h
new file mode 100644
index 0000000..7fe790c
--- /dev/null
+++ b/usb_pwr.h
@@ -0,0 +1,59 @@
+/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
+* File Name : usb_pwr.h
+* Author : MCD Application Team
+* Version : V2.2.1
+* Date : 09/22/2008
+* Description : Connection/disconnection & power management header
+********************************************************************************
+* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
+* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
+* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
+* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
+* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
+* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
+*******************************************************************************/
+
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USB_PWR_H
+#define __USB_PWR_H
+
+/* Includes ------------------------------------------------------------------*/
+/* Exported types ------------------------------------------------------------*/
+typedef enum _RESUME_STATE
+{
+ RESUME_EXTERNAL,
+ RESUME_INTERNAL,
+ RESUME_LATER,
+ RESUME_WAIT,
+ RESUME_START,
+ RESUME_ON,
+ RESUME_OFF,
+ RESUME_ESOF
+} RESUME_STATE;
+
+typedef enum _DEVICE_STATE
+{
+ UNCONNECTED,
+ ATTACHED,
+ POWERED,
+ SUSPENDED,
+ ADDRESSED,
+ CONFIGURED
+} DEVICE_STATE;
+
+/* Exported constants --------------------------------------------------------*/
+/* Exported macro ------------------------------------------------------------*/
+/* Exported functions ------------------------------------------------------- */
+void Suspend(void);
+void Resume_Init(void);
+void Resume(RESUME_STATE eResumeSetVal);
+RESULT PowerOn(void);
+RESULT PowerOff(void);
+
+/* External variables --------------------------------------------------------*/
+extern vu32 bDeviceState; /* USB device status */
+extern volatile bool fSuspendEnabled; /* true when suspend is possible */
+
+#endif /*__USB_PWR_H*/
+
+/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/