资源简介

stm32实现USB_存储_HID复合设备,采用官方固件库实现,U盘实际上是读卡器

资源截图

代码片段和文件信息

#include “usb_data_process.h“


//HID发送数据
//返回1发送失败 返回0发送成功
u8 HID_Send_Data(u8* bufferu8 length)
{
if(sendOk == 1)
{
if(length == 0)
{
SetEPTxStatus(ENDP1 EP_TX_NAK);//不发送
}
else
{
UserToPMABufferCopy(buffer GetEPTxAddr(ENDP1) length);
SetEPTxCount(ENDP1 length);
SetEPTxValid(ENDP1);//使能发送
sendOk = 0;//设置发送未完成状态等待发送回调函数将数据发送到主机
}
return 0;
}
else
{
return 1;//上一次的数据还没发送出去所以这次发送失败
}
}


//HID接收数据处理
u8 HID_Receive_Data(u8* buffer)
{
u16 length = 0;//获取接收到的数据长度
u8 i = 0;
if(ReceiveOk == 1)//有数据
{
length = GetEPRxCount(ENDP1);
if(length == 0)return 0;
else
{
PMAToUserBufferCopy(buffer GetEPRxAddr(ENDP1) length);
SetEPRxValid(ENDP1);//使能接收
ReceiveOk = 0;

printf(“hid receive : “);
for(i = 0; i < length; i++)
{
printf(“%c “buffer[i]);
}
printf(“\r\n“);

return length;//返回接收到的数据
}
}
else
{
//没有数据直接为0
return 0;
}
}



 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1097  2015-03-21 22:03  USB_HID_READCARD_COMPOSE\app\usb_data_process.c

     文件        356  2015-03-21 21:43  USB_HID_READCARD_COMPOSE\app\usb_data_process.h

     文件      20421  2012-04-26 22:22  USB_HID_READCARD_COMPOSE\cmsis\core_cm3.c

     文件      86316  2012-04-26 22:40  USB_HID_READCARD_COMPOSE\cmsis\core_cm3.h

     文件      15503  2014-04-10 14:16  USB_HID_READCARD_COMPOSE\cmsis\startup_stm32f10x_hd.s

     文件     633963  2014-04-10 14:16  USB_HID_READCARD_COMPOSE\cmsis\stm32f10x.h

     文件      36557  2014-04-10 14:16  USB_HID_READCARD_COMPOSE\cmsis\system_stm32f10x.c

     文件       2085  2014-04-10 14:16  USB_HID_READCARD_COMPOSE\cmsis\system_stm32f10x.h

     文件        248  2015-03-02 15:33  USB_HID_READCARD_COMPOSE\command\commandConfig.h

     文件       1608  2015-03-03 13:14  USB_HID_READCARD_COMPOSE\command\CommandCore.c

     文件        239  2015-03-02 15:31  USB_HID_READCARD_COMPOSE\command\commandCore.h

     文件        739  2015-03-02 15:29  USB_HID_READCARD_COMPOSE\command\commandFunc.c

     文件        177  2015-03-02 15:31  USB_HID_READCARD_COMPOSE\command\commandFunc.h

     文件        258  2015-03-02 14:59  USB_HID_READCARD_COMPOSE\command\commandInclude.h

     文件        240  2015-03-02 15:22  USB_HID_READCARD_COMPOSE\command\commandList.c

     文件        327  2015-03-02 15:31  USB_HID_READCARD_COMPOSE\command\commandList.h

     文件      11953  2015-03-02 15:13  USB_HID_READCARD_COMPOSE\command\commandUtil.c

     文件       1438  2015-03-02 15:19  USB_HID_READCARD_COMPOSE\command\commandUtil.h

     文件        819  2015-03-02 15:44  USB_HID_READCARD_COMPOSE\command\使用说明.txt

     文件      16350  2015-03-03 14:06  USB_HID_READCARD_COMPOSE\device\font.h

     文件       5461  2015-02-27 15:16  USB_HID_READCARD_COMPOSE\device\key.c

     文件        336  2015-02-27 15:21  USB_HID_READCARD_COMPOSE\device\key.h

     文件      14942  2015-03-03 14:26  USB_HID_READCARD_COMPOSE\device\lcd.c

     文件       6370  2015-03-03 14:06  USB_HID_READCARD_COMPOSE\device\lcd.h

     文件       1175  2015-02-27 15:00  USB_HID_READCARD_COMPOSE\device\led.c

     文件        155  2015-02-27 15:01  USB_HID_READCARD_COMPOSE\device\led.h

     文件       9776  2014-12-08 13:32  USB_HID_READCARD_COMPOSE\device\SDCARD.c

     文件       2676  2015-03-22 23:30  USB_HID_READCARD_COMPOSE\device\SDCARD.h

     文件       3833  2015-02-27 14:58  USB_HID_READCARD_COMPOSE\driver\debugSerial.c

     文件        615  2015-02-27 11:49  USB_HID_READCARD_COMPOSE\driver\debugSerial.h

............此处省略139个文件信息

评论

共有 条评论