当前位置: 首页 > news >正文

STM32 USB HOST 驱动FT232 USB转串

2

闲来无事,测试了个HOST驱动FT232,暂时只测试了个回环

获取枚举信息,通过短接FT232 TX和RX ,开始数据回环测试。


/*** @brief  Initialize the transmit and receive buffer and its parameter* @param  None* @retval None*/
static void CDC_InitTxRxParam(void)
{/*Initialize the Transmit buffer and its parameter*/CDC_TxParam.CDCState = CDC_IDLE;CDC_TxParam.DataLength = 0;CDC_TxParam.pRxTxBuff = TxBuf;/*Initialize the Receive buffer and its parameter*/CDC_RxParam.CDCState = CDC_IDLE;CDC_RxParam.DataLength = 0;CDC_RxParam.pFillBuff = RxBuf;  CDC_RxParam.pEmptyBuff = RxBuf;CDC_RxParam.BufferLen = sizeof(RxBuf);      
}/*** @brief  This is a call back function from cdc core layer to redirect the *         received data on the user out put system* @param  cdc_Data: type of USBH_CDCXfer_TypeDef* @retval None*/
static void CDC_ReceiveData(CDC_Xfer_TypeDef *cdc_Data)
{uint8_t *ptr; if(cdc_Data->pEmptyBuff < cdc_Data->pFillBuff){ptr = cdc_Data->pFillBuff;*ptr = 0x00;/* redirect the received data on the user out put system */UserCb.Receive(cdc_Data->pEmptyBuff, cdc_Data->DataLength);cdc_Data->pFillBuff  = cdc_Data->pEmptyBuff ; cdc_Data->DataLength = 0;    /*Reset the data length to zero*/}
}/*** @brief  This function send data to the device.* @param  fileName : name of the file * @retval the filestate will be returned * FS_SUCCESS : returned to the parent function when the file length become to zero*/
void  CDC_SendData(uint8_t *data, uint16_t length)
{if(CDC_TxParam.CDCState == CDC_IDLE){CDC_TxParam.pRxTxBuff = data; CDC_TxParam.DataLength = length;CDC_TxParam.CDCState = CDC_SEND_DATA;  }    
}/*** @brief  This function send data to the device.* @param  fileName : name of the file * @retval the filestate will be returned * FS_SUCCESS : returned to the parent function when the file length become to zero*/
void  CDC_StartReception( USB_OTG_CORE_HANDLE *pdev)
{RX_Enabled = 1;
}/*** @brief  This function send data to the device.* @param  fileName : name of the file * @retval the filestate will be returned * FS_SUCCESS : returned to the parent function when the file length become to zero*/
void  CDC_StopReception( USB_OTG_CORE_HANDLE *pdev)
{RX_Enabled = 0; USB_OTG_HC_Halt(pdev, CDC_Machine.CDC_DataItf.hc_num_in);USBH_Free_Channel  (pdev,CDC_Machine.CDC_DataItf.hc_num_in);
}
http://www.xdnf.cn/news/1205065.html

相关文章:

  • Android 解析 TrafficDescriptor 的 OSAPP 信息
  • OpenLayers 综合案例-区域掩膜
  • [机缘参悟-237]:AI人工神经网络与人类的神经网络工作原理的相似性
  • SpringBoot数学实例:高等数学实战
  • 7.项目起步(1)
  • Baumer工业相机堡盟工业相机如何通过YoloV8深度学习模型实现面部口罩的检测识别(C#代码,UI界面版)
  • 数据结构(动态数组)
  • HTML应用指南:利用GET请求获取全国小米之家门店位置信息
  • 第4章唯一ID生成器——4.2 单调递增的唯一ID
  • 【Zustand】从复杂到简洁:Zustand 状态管理简化实战指南
  • 绿算技术携手昇腾发布高性能全闪硬盘缓存设备,推动AI大模型降本增效
  • Laravel 分页方案整理
  • 安宝特新闻丨Vuzix与Wyr.Ai合作推出基于M400眼镜的全新一代质检平台
  • springboot校园外卖配送系统
  • 【设计模式】状态模式 (状态对象(Objects for States))
  • Linux应用程序架构与软件包管理
  • Redis实战(3)-- 高级数据结构zset
  • MySQL5.7主从延迟高排查优化思路
  • Qt:盒子模型的理解
  • 电流变送器电路的分析与计算
  • TCPIP之常用协议
  • LeetCode--50.Pow(x,n)
  • RCLAMP2574N.TCT Semtech:超低钳位TVS二极管 0.5pF超低电容+±30kV超强防护
  • FastGPT本地构建工作流高级编排(最新4.11.0)
  • 【云馨AI-大模型】2025世界人工智能大会引爆全球AI热潮,技术突破与政策布局引领产业新未来
  • 4、如何生成分布式ID?
  • C++中既重要又困难的部分—类和对象
  • 【历史人物】【韩愈】简历与生平
  • sqlite3学习---基础知识、增删改查和排序和限制、打开执行关闭函数
  • 归雁思维:解锁自然规律与人类智慧的桥梁