当前位置: 首页 > 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.dtcms.com/a/302383.html

相关文章:

  • Flutter在购物场景中BLoC的应用
  • linux安装zsh,oh-my-zsh,配置zsh主题及插件的方法
  • 用了Flutter包体积增大就弃用Flutter吗?包体积与开发效率,这两者之间如何权衡?
  • 形参表不匹配(BUG)
  • 【Git】Linux-ubuntu 22.04 初步认识 -> 安装 -> 基础操作
  • 标准SQL语句示例
  • 专题:2025医药生物行业趋势与投融资研究报告|附90+份报告PDF、原数据表汇总下载
  • 云服务器以域名形式访问机房Kubernetes集群服务之解决方案
  • 时序数据基座升维:Apache IoTDB 以“端边云AI一体化”重构工业智能决策
  • 06-原型和原型链
  • iOS 离屏渲染
  • 【RH134 问答题】第 6 章 管理 SELinux 安全性
  • Java集合遍历的几种方式
  • 1.DRF 环境安装与配置
  • 基于springboot的编程训练系统设计与实现(源码+论文)
  • EMQX Webhook 调用本地 Supabase Edge Functions
  • 3.DRF视图和路由
  • JAVA后端开发——“全量同步”和“增量同步”
  • [AI Coding] 一.腾讯CodeBuddy IDE内测、安装及基本用法(国产AI IDE启航)
  • 使用node-cron实现Node.js定时任务
  • Office-PowerPoint-MCP-Server – 基于MCP的开源PPT生成与编辑工具
  • 每日面试题16:什么是双亲委派模型
  • DBSyncer:开源免费的全能数据同步工具,多数据源无缝支持!
  • 代码随想录day48单调栈1
  • Python全栈项目--基于深度学习的视频内容分析系统
  • html转word下载
  • 【GitHub Workflows 基础(二)】深入理解 on、jobs、steps 的核心语法与执行逻辑
  • Dify快速搭建问答系统
  • 3、CC3200串口DMA
  • Binary Classifier Optimization for Large Language Model Alignment