Guest User

Untitled

a guest
May 24th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. #define STM32F10X_CL
  2.  
  3. /******************** (C) COPYRIGHT 2011 STMicroelectronics ********************
  4. * File Name : main.c
  5. * Author : MCD Application Team
  6. * Version : V3.3.0
  7. * Date : 21-March-2011
  8. * Description : Virtual Com Port Demo main file
  9. ********************************************************************************
  10. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  11. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
  12. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
  13. * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
  14. * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
  15. * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  16. *******************************************************************************/
  17.  
  18. /* Includes ------------------------------------------------------------------*/
  19. #ifdef STM32L1XX_MD
  20. #include "stm32l1xx.h"
  21. #else
  22. #include "stm32f10x.h"
  23. #endif /* STM32L1XX_MD */
  24.  
  25. #include "usb_lib.h"
  26. #include "usb_desc.h"
  27. #include "hw_config.h"
  28. #include "usb_pwr.h"
  29.  
  30. /* Private typedef -----------------------------------------------------------*/
  31. /* Private define ------------------------------------------------------------*/
  32. /* Private macro -------------------------------------------------------------*/
  33. /* Private variables ---------------------------------------------------------*/
  34. /* Extern variables ----------------------------------------------------------*/
  35. /* Private function prototypes -----------------------------------------------*/
  36. /* Private functions ---------------------------------------------------------*/
  37.  
  38. /*******************************************************************************
  39. * Function Name : main.
  40. * Description : Main routine.
  41. * Input : None.
  42. * Output : None.
  43. * Return : None.
  44. *******************************************************************************/
  45. int main(void)
  46. {
  47. char s[]="*********************************\r\n";
  48. char* buffer_in,*buffer_out[40];
  49. int len,i,n,lp,count_in=0,count_out;
  50. volatile int j,k;
  51.  
  52. Set_System();
  53. Set_USBClock();
  54. USB_Interrupts_Config();
  55.  
  56. USB_Init();
  57.  
  58. while (bDeviceState != CONFIGURED) ;
  59.  
  60. len = strlen(s);
  61. lp = 0;
  62. for(j=0;;j++)
  63. {
  64. // sioputs("test\r\n");
  65. /* Write the data to the USB endpoint */
  66. //n = VIRTUAL_COM_PORT_DATA_SIZE-count_in;
  67. if( 10 < j ){
  68. //sioputs("len=");
  69. //sioputint(len);
  70. //sioputs("\r\n");
  71. j=0;
  72. __disable_irq();
  73. if( count_in == 0 )
  74. {
  75. for(i=0; i<len; i++){
  76. buffer_in[i] = s[i];
  77. }
  78. count_in = len;
  79. USB_SIL_Write(EP1_IN, buffer_in, count_in);
  80. //count_in += n;
  81. }
  82. __enable_irq();
  83. //sioputs("end usb_sil_write\r\n");
  84. }
  85. if ((count_out != 0) && (bDeviceState == CONFIGURED))
  86. {
  87. //USB_To_USART_Send_Data(&buffer_out[0], count_out);
  88. count_out = 0;
  89. }
  90. }
  91.  
  92.  
  93. }
  94. #ifdef USE_FULL_ASSERT
  95. /*******************************************************************************
  96. * Function Name : assert_failed
  97. * Description : Reports the name of the source file and the source line number
  98. * where the assert_param error has occurred.
  99. * Input : - file: pointer to the source file name
  100. * - line: assert_param error line source number
  101. * Output : None
  102. * Return : None
  103. *******************************************************************************/
  104. void assert_failed(uint8_t* file, uint32_t line)
  105. {
  106. /* User can add his own implementation to report the file name and line number,
  107. ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  108.  
  109. /* Infinite loop */
  110. while (1)
  111. {}
  112. }
  113. #endif
  114.  
  115. /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
Add Comment
Please, Sign In to add comment