labview 的usb通信
单片机源程序如下:
- /**
- ******************************************************************************
- * @file main.c
- * @author MCD Application Team
- * @version V4.0.0
- * @date 21-January-2013
- * @brief Virtual Com Port Demo main file
- ******************************************************************************
- * @attention
- *
- * <h2><center>© COPYRIGHT 2013 STMicroelectronics</center></h2>
- *
- * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
- * You may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************
- */
- /* Includes ------------------------------------------------------------------*/
- #include "hw_config.h"
- #include "usb_lib.h"
- #include "usb_desc.h"
- #include "usb_pwr.h"
- #include <string.h>
- #include <stdio.h>
- #include <stdlib.h>
- /* Private typedef -----------------------------------------------------------*/
- /* Private define ------------------------------------------------------------*/
- /* Private macro -------------------------------------------------------------*/
- /* Private variables ---------------------------------------------------------*/
- /* Extern variables ----------------------------------------------------------*/
- /* Private function prototypes -----------------------------------------------*/
- /* Private functions ---------------------------------------------------------*/
- /*******************************************************************************
- * Function Name : main.
- * Description : Main routine.
- * Input : None.
- * Output : None.
- * Return : None.
- *******************************************************************************/
- extern uint32_t USB_SIL_WriteEDP1Dbbuf( uint8_t* pBufferPointer, uint32_t wBufferSize);
- u8 t;
- char usbsndbuf[64];
- void snddata(void)
- {
- static int i=0;
- int len;
- i++;
- USB_SIL_WriteEDP1Dbbuf(usbsndbuf, 64);
-
- }
- int main(void)
- {
- for(t=0;t<64;t++)
- usbsndbuf[t]=t;
- Set_System();
- Set_USBClock();
- USB_Interrupts_Config();
- USB_Init();
-
- while (1)
- {
- snddata();
-
- }
- }
- #ifdef USE_FULL_ASSERT
- /*******************************************************************************
- * 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(uint8_t* file, uint32_t 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 STMicroelectronics *****END OF FILE****/
复制代码
所有资料51hei提供下载:
STM32 Labview USB通信.rar
(625.47 KB, 下载次数: 81)
|