⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 单片机c51编程几个有用的模块--祥子的天空.htm

📁 ucos的资料以及单片机dsp的经典移植程序
💻 HTM
📖 第 1 页 / 共 4 页
字号:
                        接收4个字节长的数据包<BR>}<BR>}<BR><BR>// 在中断外部响应时钟中断事件<BR>void 
                        OnTimerEvent()            <BR>{<BR>  // do 
                        nothing<BR>}<BR><BR>// 控制外部灯<BR>static void 
                        TriggerLamp(BIT bEnable)  <BR>{<BR>  P10 = 
                        ~bEnable;            // 需要反相控制<BR>}<BR><BR>// 
                        键扫描回调函数<BR>BYTE KBScan()  <BR>{<BR>  BIT b;<BR>  P11 = 
                        1;                // 读之前拉高引脚电平<BR>  b = 
                        P11;                // 读入引脚状态<BR>  return 
                        ~b;                // 数据反相做扫描码<BR>}<BR><BR>// 
                        计算校验和<BR>static BYTE CalcCheckSum(BYTE* pbyBuf, BYTE 
                        byLen)<BR>{<BR>  BYTE by, bySum = 0;<BR>  for(by = 0; by 
                        &lt; byLen; by++)<BR>    bySum += 
                        pbyBuf[by];<BR>  return 0 – bySum;<BR>}<BR><BR>// 
                        接收到键盘消息回调函数<BR>void onKeyPressed(BYTE byValue, BYTE 
                        byState)<BR>{<BR>  BYTE by[4];<BR>  if(byState == 
                        0)<BR>  {<BR>    switch(byValue)<BR>    {<BR>    case 
                        0x01:<BR>      gbitLampState = ~g  bitLampState;  // 
                        灯状态取反<BR>      TriggerLamp(gbitLampState);  // 
                        执行控制<BR>      by[0] = 0xff;          // 
                        构造数据包<BR>      by[1] = 0x12;<BR>      by[2] = 
                        (BYTE)gbitLampState;<BR>      by[3] = CalcCheckSum(by, 
                        3);  // 求校验和<BR>      SendPackage(by, 4);      // 
                        发送数据包<BR>      break;<BR>    // 
                        处理其它扫描码<BR>    default:<BR>      break;<BR>  }<BR>}<BR><BR>// 
                        接收到数据包回调函数<BR>void OnRecePackage(BYTE* pbyBuf, BYTE 
                        byBufLen)<BR>{<BR>  BYTE by[4];<BR>  by[0] = 
                        0xff;<BR>  by[1] = 0x11;<BR>  if(byBufLen != 4 || 
                        pbyBuf[3] != CalcCheckSum(pbyBuf, 
                        3))<BR>  {<BR>    by[2] = 0;<BR>    by[3] = 
                        CalcCheckSum(by, 3);<BR>    SendPackage(by, 4);         
                        // 
                        处理长度或校验和不正确<BR>  }<BR><BR>  switch(pbyBuf[1])<BR>  {<BR>  case 
                        0x10:<BR>    gbitLampState = 
                        (BIT)pbyBuf[2];<BR>    TriggerLamp(gbitLampState);<BR>    by[2] 
                        = 1;<BR>    by[3] = CalcCheckSum(by, 
                        3);<BR>    SendPackage(by, 4);        // 
                        发送成功执行通知<BR>    break;<BR><BR>  default:                // 
                        不知道的命令<BR>    by[2] = 0;<BR>    by[3] = CalcCheckSum(by, 
                        3);<BR>    SendPackage(by, 4);        // 
                        发送没有成功执行通知<BR>    break;<BR></FONT></SPAN></SPAN></DIV></SPAN></TD></TR></TBODY></TABLE>
                  <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                    <TBODY>
                    <TR>
                      <TD height=3>&nbsp;</TD></TR></TBODY></TABLE>
                  <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                    <TBODY>
                    <TR>
                      <TD class=seyle5 height=13>
                        <DIV align=right><SPAN class=textbox-urls><A 
                        href="http://www.mcublog.com/blog/user1/7352/archives/2007/26141.html#">阅读全文<SPAN 
                        id=ob_logreaded></SPAN></A> | <A 
                        href="http://www.mcublog.com/blog/user1/7352/archives/2007/26141.html#cmt">回复(1)</A> 
                        <SPAN id=ob_logm26141></SPAN>| <A 
                        href="http://www.mcublog.com/blog/showtb.asp?id=26141" 
                        target=_blank>引用通告<SPAN id=ob_tbnum></SPAN></A> | <A 
                        href="http://www.mcublog.com/blog/user_post.asp?logid=26141" 
                        target=_blank>编辑</A></SPAN></DIV></TD></TR></TBODY></TABLE>
                  <TABLE height=14 cellSpacing=0 cellPadding=0 width="100%" 
                  align=center border=0>
                    <TBODY>
                    <TR>
                      <TD>&nbsp;</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
            <DIV id=blogaddon>
            <LI>标签:<SPAN><A 
            href="http://www.mcublog.com/blog/user1/7352/cmd.html?uid=7352&amp;do=tag_blogs&amp;id=579">C51编程</A></SPAN>&nbsp;<SPAN><A 
            href="http://www.mcublog.com/blog/user1/7352/cmd.html?uid=7352&amp;do=tag_blogs&amp;id=4473">常用模块</A></SPAN>&nbsp;</LI></DIV>
            <DIV id=morelog>
            <UL>
              <LI>上一篇:<A 
              href="http://www.mcublog.com/blog/user1/7352/archives/2007/26140.html">uC/OS开发方法(续)</A> 

              <LI>下一篇:<A 
              href="http://www.mcublog.com/blog/user1/7352/archives/2007/26142.html">PWM控制LED灯渐亮渐灭源程序</A> 
              </LI></UL></DIV>
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
              <TBODY>
              <TR>
                <TD>
                  <TABLE class=seyle4 cellSpacing=0 cellPadding=0 width="100%" 
                  border=0>
                    <TBODY>
                    <TR>
                      <TD>&nbsp;</TD></TR>
                    <TR>
                      <TD class=content9 
                        vAlign=center><STRONG>Re:单片机C51编程几个有用的模块<A 
                        name=10764></A></STRONG></TD></TR>
                    <TR>
                      <TD>
                        <DIV align=right><SPAN class=textbox-label>[ <SPAN 
                        id=t_10764>2007-12-8 20:07:46</SPAN> | By: <SPAN 
                        class=style3><SPAN id=n_10764>sky411615400</SPAN></SPAN> 
                        ]</SPAN></DIV></TD></TR></TBODY></TABLE>
                  <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                    <TBODY>
                    <TR>
                      <TD height=3>&nbsp;</TD></TR></TBODY></TABLE>
                  <TABLE style="TABLE-LAYOUT: fixed" cellSpacing=0 cellPadding=0 
                  width="100%" align=center border=0>
                    <TBODY>
                    <TR>
                      <TD><SPAN class=oblog_text><A 
                        href="http://www.mcublog.com/blog/go.asp?url=http://nike.mcublog.com" 
                        target=_blank><IMG class=ob_face height=48 
                        alt=sky411615400 
                        src="单片机C51编程几个有用的模块--祥子的天空.files/ico_default.gif" 
                        width=48 align=absMiddle></A><SPAN 
                        id=c_10764>非常好的东西,谢谢,希望有时候咄咄指教</SPAN> 
                    </SPAN></TD></TR></TBODY></TABLE>
                  <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                    <TBODY>
                    <TR>
                      <TD height=3>&nbsp;</TD></TR></TBODY></TABLE>
                  <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                    <TBODY>
                    <TR>
                      <TD class=seyle5 height=13>
                        <DIV align=right><SPAN class=textbox-urls><A 
                        href="http://www.mcublog.com/blog/go.asp?url=http://nike.mcublog.com" 
                        target=_blank>个人主页</A> | <A 
                        href="javascript:reply_quote('10764')">引用</A> | <A 
                        href="http://www.mcublog.com/blog/user1/7352/archives/2007/26141.html#top">返回</A> 
                        | <A 
                        href="http://www.mcublog.com/blog/user_comments.asp?action=del&amp;id=10764" 
                        target=_blank>删除</A> | <A 
                        href="http://www.mcublog.com/blog/user_comments.asp?action=modify&amp;re=true&amp;id=10764" 
                        target=_blank>回复</A></SPAN></DIV></TD></TR></TBODY></TABLE>
                  <TABLE height=14 cellSpacing=0 cellPadding=0 width="100%" 
                  align=center border=0>
                    <TBODY>
                    <TR>
                      <TD>&nbsp;</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
            <DIV id=form_comment>
            <DIV id=gg_usercomment></DIV><A name=cmt></A>
            <DIV class=title>发表评论:</DIV>
            <FORM id=commentform name=commentform 
            onsubmit="return Verifycomment()" 
            action=/blog/savecomment.asp?logid=26141 method=post>
            <DIV class=d1><LABEL>昵称:<INPUT id=UserName maxLength=20 
            name=UserName></LABEL></DIV>
            <DIV class=d2><LABEL>密码:<INPUT id=Password type=password 
            maxLength=20 name=Password> </LABEL></DIV>
            <DIV class=d3><LABEL>主页:<INPUT id=homepage maxLength=50 size=42 
            value=http:// name=homepage></LABEL></DIV>
            <DIV class=d4><LABEL>标题:<INPUT id=commenttopic maxLength=50 size=42 
            value=Re:单片机C51编程几个有用的模块 name=commenttopic></LABEL></DIV>
            <DIV class=d5><INPUT id=edit type=hidden name=edit> 
            <DIV id=oblog_edit>数据载入中...</DIV></DIV>
            <DIV class=d6><SPAN id=ob_code></SPAN><INPUT onclick='oblog_edittext.createTextRange().execCommand("Copy");' type=submit value=&nbsp;提&nbsp;交&nbsp;></DIV></FORM></DIV></TD></TR></TBODY></TABLE></DIV></TD>
    <TD width=112>&nbsp;</TD></TR></TBODY></TABLE>
<TABLE class=content6 cellSpacing=0 cellPadding=0 width=996 border=0>
  <TBODY>
  <TR>
    <TD width=182 height=37>&nbsp;</TD>
    <TD width=637>&nbsp;</TD>
    <TD width=177>&nbsp;</TD></TR>
  <TR>
    <TD height=84>&nbsp;</TD>
    <TD align=middle></TD>
    <TD>&nbsp;</TD></TR>
  <TR>
    <TD>&nbsp;</TD>
    <TD>&nbsp;</TD>
    <TD>&nbsp;</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><SPAN 
id=gg_userbot></SPAN>
<DIV id=powered><A href="http://www.mcublog.com/" target=_blank><IMG 
alt="Powered by Mcublog." src="单片机C51编程几个有用的模块--祥子的天空.files/oblog_powered.gif" 
border=0></A>
<SCRIPT language=javascript 
src="单片机C51编程几个有用的模块--祥子的天空.files/click.htm"></SCRIPT>
 </DIV>
<SCRIPT src="单片机C51编程几个有用的模块--祥子的天空.files/200712.htm"></SCRIPT>

<SCRIPT src="单片机C51编程几个有用的模块--祥子的天空.files/count.htm"></SCRIPT>

<SCRIPT src="单片机C51编程几个有用的模块--祥子的天空.files/commentedit.htm"></SCRIPT>

<SCRIPT src="F:\ucos\新资料\单片机C51编程几个有用的模块--祥子的天空.files\count(1).htm"></SCRIPT>

<SCRIPT src="单片机C51编程几个有用的模块--祥子的天空.files/login.htm"></SCRIPT>

<SCRIPT src="单片机C51编程几个有用的模块--祥子的天空.files/ShowXml.htm"></SCRIPT>

<SCRIPT src="F:\ucos\新资料\单片机C51编程几个有用的模块--祥子的天空.files\count(2).htm"></SCRIPT>
</BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -