当前位置: 首页 > 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.lryc.cn/news/602961.html

相关文章:

  • 安装anaconda后,如何进入python解释器
  • SSH 远程控制及相关工具
  • 常见的JVM虚拟机的参数详解
  • “量子通信”
  • 【C语言网络编程基础】TCP并发网络编程:io多路复用
  • 五自由度磁悬浮轴承转子:基于自适应陷波器的零振动攻克不平衡质量扰动的终极策略
  • linux du、df命令使用教程
  • 面向对象设计原则和设计模式分类
  • 开源AI智能体-JoyAgent集成Deepseek
  • C++模板元编程从入门到精通
  • [论文阅读] 人工智能 | 机器学习工作流的“救星”:数据虚拟化服务如何解决数据管理难题?
  • [机缘参悟-236]:通过AI人工神经网络理解人的思维特征:惯性思维、路径依赖、适应性、不同场合不同言行、经验、概率、常规与特殊情形(正态分布)、环境适应性
  • 5 分钟上手 Firecrawl
  • Java项目:基于SSM框架实现的社区团购管理系统【ssm+B/S架构+源码+数据库+毕业论文+答辩PPT+远程部署】
  • js的学习1
  • 如何理解有符号数在计算机中用​​补码​​存储
  • 阿里给AI To C战略戴上眼镜
  • 案例开发 - 日程管理 - 第三期
  • Android Handler 完全指南
  • 【QT搭建opencv环境】
  • 商城系统-项目测试
  • redis未授权getshell四种方式
  • Ubuntu24安装MariaDB/MySQL后不知道root密码如何解决
  • 基于STM32设计的智慧果园云监测系统_256
  • 基于Uniapp及Spring Boot的奢侈品二手交易平台的设计与实现/基于微信小程序的二手交易系统
  • linux安装zsh,oh-my-zsh,配置zsh主题及插件的方法
  • 机器学习基础-numpy
  • OpenMP 并行编程核心机制详解:从变量作用域到同步优化
  • SwinTransformer改进(14):集成MLCA注意力机制的Swin Transformer模型
  • Linux DNS解析2 -- 网关DNS代理的作用