标题:
USB鼠标源码 Labview USB-RAW-Bulk上位机发送数据STM32下位机接受
[打印本页]
作者:
爱儿
时间:
2018-6-8 15:04
标题:
USB鼠标源码 Labview USB-RAW-Bulk上位机发送数据STM32下位机接受
为了获得一点黑币,好下载,也是不择手段了!
0.png
(47.44 KB, 下载次数: 40)
下载附件
2018-6-9 03:45 上传
IDE-Version:
*********************************************
μVision V4
下载方式
*********************************************
·SWD JTAG
程序功能
*********************************************
·STM32 USB鼠标实验
硬件连接
*********************************************
·将USB插到开发板上
实验现象
*********************************************
·可以使用KEY来控制电脑的鼠标的方向
单片机源程序如下:
/*********************************************************************************************************
*
* File : main.c
* Hardware Environment:
* Build Environment : RealView MDK-ARM Version: 4.32
* Version : V1.0
* By : mao
*
*
*********************************************************************************************************/
/* Includes ------------------------------------------------------------------*/
#include "stm32f10x.h"
#include "usb_lib.h"
#include "hw_config.h"
#include "usb_pwr.h"
#include "usart1.h"
#include "Data.h"
#ifdef __GNUC__
/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
set to 'Yes') calls __io_putchar() */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif /* __GNUC__ */
/* Private function prototypes -----------------------------------------------*/
u8 MsgCmd;
void Delay (uint32_t nCount);
void USB_SendString(u8 *str) //
{
u8 ii=0;
while(*str)
{
Transi_Buffer[ii++]=*(str++);
if (ii ==22) break;
}
UserToPMABufferCopy(Transi_Buffer, ENDP2_TXADDR, 22);
_SetEPTxStatus(ENDP2, EP_TX_VALID);
}
/*******************************************************************************
* Function Name : main
* Description : Main program
* Input : None
* Output : None
* Return : None
* Attention : None
*******************************************************************************/
int main(void)
{
Set_System();
USB_Interrupts_Config();
Set_USBClock();
USB_Init();
/* USART1 config 115200 8-N-1 */
USART1_Config();
NVIC_USART1_Configuration();
MsgCmd=0;
while (1)
{
if(MsgCmd) //当上位机发送数据以后,对MsgCmd置1
{
Delay(50000); //没有这个延时,会少部分数据?为什么?
// while(EP_RX_NAK!=GetEPRxStatus(ENDP1));
printf("\r\n进入主函数");
GET_CMD();
}
}
}
/*******************************************************************************
* Function Name : Delay
* Description : Delay Time
* Input : - nCount: Delay Time
* Output : None
* Return : None
* Attention : None
*******************************************************************************/
void Delay (uint32_t nCount)
{
for(; nCount != 0; nCount--)
{
}
}
/*******************************************************************************
* Function Name : GPIO_Configuration
* Description : Configure GPIO Pin
* Input : None
* Output : None
* Return : None
* Attention : None
*******************************************************************************/
//void GPIO_Configuration(void)
//{
// GPIO_InitTypeDef GPIO_InitStructure;
//
// RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB , ENABLE);
///**
// * LED1 -> PB15 , LED2 -> PB14 , LED3 -> PB13 , LED4 -> PB12
// */
// GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
// GPIO_Init(GPIOB, &GPIO_InitStructure);
//}
//
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval 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
/*********************************************************************************************************
END FILE
*********************************************************************************************************/
复制代码
所有资料51hei提供下载:
usb下位机1(上位机发,下位机收).rar
(407.71 KB, 下载次数: 36)
2018-6-9 03:45 上传
点击文件名下载附件
下载积分: 黑币 -5
作者:
lzts88
时间:
2018-6-9 09:01
很好的参考资料, 收藏了
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1