CH554评测:六,跑一下CH341例程
<div class='showpostmsg'>今天跑一下CH341例程,CH341就是USB转串,直接通过USB芯片收发串口数据。例程如:
我看了下程序,除了三个端点一个控制,一个输入一个输出之外,主要在下边这一段:
case UIS_TOKEN_IN | 0: //endpoint0 IN
switch(SetupReq)
{
case USB_GET_DESCRIPTOR:
len = SetupLen >= THIS_ENDP0_SIZE ? THIS_ENDP0_SIZE : SetupLen; //±¾′Î′«êä3¤¶è
memcpy( Ep0Buffer, pDescr, len ); //¼óÔØéÏ′«êy¾Y
SetupLen -= len;
pDescr += len;
UEP0_T_LEN = len;
UEP0_CTRL ^= bUEP_T_TOG; //í¬2½±ê־λ·-×a
break;
case USB_SET_ADDRESS:
USB_DEV_AD = USB_DEV_AD & bUDA_GP_BIT | SetupLen;
UEP0_CTRL = UEP_R_RES_ACK | UEP_T_RES_NAK;
break;
default:
UEP0_T_LEN = 0; //×′쬽׶Îíê3éÖD¶Ï»òÕßêÇÇ¿ÖÆéÏ′«03¤¶èêy¾Y°ü½áêø¿ØÖÆ′«êä
UEP0_CTRL = UEP_R_RES_ACK | UEP_T_RES_NAK;
break;
}
break;
运行截图如下:
这是把开发板插上,识别出的CH341A
以下是我发0X12,收也是0x12,发几次后又发8个字节,也是收到
看来CH554模仿CH341很成功。
此内容由EEWORLD论坛网友ddllxxrr原创,如需转载或用于商业用途需征得作者同意并注明出处
</div><script> var loginstr = '<div class="locked">查看本帖全部内容,请<a href="javascript:;" style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
if(parseInt(discuz_uid)==0){
(function($){
var postHeight = getTextHeight(400);
$(".showpostmsg").html($(".showpostmsg").html());
$(".showpostmsg").after(loginstr);
$(".showpostmsg").css({height:postHeight,overflow:"hidden"});
})(jQuery);
} </script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script> :victory::victory:
页:
[1]