• 帅帅的帅哥
    了解作者
  • C/C++
    开发工具
  • 8KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 26
    下载次数
  • 2006-11-05 19:38
    上传日期
这是单片机C语言位操作函数!给大家参考使用,可以直接在单片机中引用,不需要自己去编写,弥补了C语言位操作没有汇编灵活的缺点
Cbitfunction.rar
  • Cbitfunction.pdf
    19.9KB
  • www.pudn.com.txt
    218B
内容介绍
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <meta name="generator" content="pdf2htmlEX"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <link rel="stylesheet" href="https://static.pudn.com/base/css/base.min.css"> <link rel="stylesheet" href="https://static.pudn.com/base/css/fancy.min.css"> <link rel="stylesheet" href="https://static.pudn.com/prod/directory_preview_static/622b340381ded46b7f3e81a4/raw.css"> <script src="https://static.pudn.com/base/js/compatibility.min.js"></script> <script src="https://static.pudn.com/base/js/pdf2htmlEX.min.js"></script> <script> try{ pdf2htmlEX.defaultViewer = new pdf2htmlEX.Viewer({}); }catch(e){} </script> <title></title> </head> <body> <div id="sidebar" style="display: none"> <div id="outline"> </div> </div> <div id="pf1" class="pf w0 h0" data-page-no="1"><div class="pc pc1 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/622b340381ded46b7f3e81a4/bg1.jpg"><div class="t m0 x1 h2 y1 ff1 fs0 fc0 sc0 ls0 ws0">&#32473;<span class="_ _0"> </span><span class="ff2 sc1">C<span class="_ _0"> </span></span><span class="ls1">&#35821;&#35328;&#22686;&#21152;&#20960;&#20010;&#20301;&#25805;&#20316;&#20989;&#25968;</span><span class="ff2 sc1"> </span></div><div class="t m0 x2 h3 y2 ff3 fs1 fc0 sc1 ls0 ws0">&#22312;&#27719;&#32534;&#35821;&#35328;&#20013;&#26377;&#30452;&#25509;&#23545;&#20301;&#36827;&#34892;&#25805;&#20316;&#30340;&#25351;&#20196;&#65292;&#22914;&#32622;&#20301;&#12289;&#22797;&#20301;&#12289;&#20301;&#21462;&#21453;&#12289;&#27979;&#35797;&#26576;&#19968;&#20301;&#31561;&#65292;&#36825;</div><div class="t m0 x3 h3 y3 ff3 fs1 fc0 sc1 ls0 ws0">&#23545;&#20110;&#30828;&#20214;&#25805;&#20316;&#21313;&#20998;&#26041;&#20415;&#65292;&#22312;<span class="_ _1"> </span><span class="ff4">C<span class="_ _1"> </span></span>&#35821;&#35328;&#20013;&#23613;&#31649;&#20063;&#25552;&#20379;&#20102;&#19968;&#20123;&#20301;&#25805;&#20316;&#25163;&#27573;&#65292;&#22914;&#25353;&#20301;&#19982;&#12289;&#25353;&#20301;&#25110;&#12289;&#25353;</div><div class="t m0 x3 h3 y4 ff3 fs1 fc0 sc1 ls0 ws0">&#20301;&#21462;&#21453;&#31561;&#65292;&#20294;&#23427;&#20204;&#26159;&#23545;&#19968;&#20010;&#23383;&#33410;&#36827;&#34892;&#25805;&#20316;&#65292;&#22914;&#35201;&#23545;&#20855;&#20307;&#30340;&#19968;&#20301;&#25805;&#20316;&#65292;&#20173;&#26087;&#19981;&#26041;&#20415;&#65292;&#20197;&#19979;&#32473;&#20986;</div><div class="t m0 x3 h3 y5 ff3 fs1 fc0 sc1 ls0 ws0">&#20102;&#19968;&#20123;&#20989;&#25968;&#65292;&#21487;&#20197;&#27169;&#20223;&#27719;&#32534;&#35821;&#35328;&#30340;&#19968;&#20123;&#20301;&#25805;&#20316;&#21151;&#33021;&#12290;<span class="ff4"> </span></div><div class="t m0 x3 h4 y6 ff5 fs1 fc0 sc1 ls2 ws1">#define uchar unsigned char </div><div class="t m0 x3 h4 y7 ff5 fs1 fc0 sc1 ls3 ws0">/*<span class="ff3 ls0">&#27979;&#35797;&#21464;&#37327;&#26576;&#19968;&#20301;&#26159;&#21542;&#20026;&#8216;<span class="ff5">1</span>&#8217;&#65292;&#26159;&#36820;&#22238;&#30495;&#65292;&#21542;&#36820;&#22238;&#20551;&#65292;</span><span class="ls4">num<span class="_"> </span><span class="ff3 ls0">&#20026;&#24453;&#27979;&#35797;&#30340;&#25968;&#65292;</span><span class="ls5">bit<span class="_ _1"> </span><span class="ff3 ls0">&#20026;&#20301;&#25968;&#65292;&#20854;</span></span></span></div><div class="t m0 x3 h4 y8 ff3 fs1 fc0 sc1 ls0 ws0">&#20540;&#20174;<span class="_ _1"> </span><span class="ff5">0<span class="_"> </span></span>&#21040;<span class="_ _1"> </span><span class="ff5">7</span>&#65292;&#19979;&#21516;<span class="ff5 ls5">*/ </span></div><div class="t m0 x3 h4 y9 ff5 fs1 fc0 sc1 ls6 ws2">uchar bittest(uchar <span class="_ _2"></span>num,uchar <span class="_ _2"></span>bit) </div><div class="t m0 x3 h4 ya ff5 fs1 fc0 sc1 ls7 ws3">{ if(num&gt;&gt;bit&amp;0x01==1) </div><div class="t m0 x3 h4 yb ff5 fs1 fc0 sc1 ls6 ws2"> <span class="_ _3"> </span> return <span class="_ _2"></span>1; </div><div class="t m0 x3 h4 yc ff5 fs1 fc0 sc1 ls7 ws4"> else </div><div class="t m0 x3 h4 yd ff5 fs1 fc0 sc1 ls6 ws2"> <span class="_ _3"> </span> return <span class="_ _2"></span>0; </div><div class="t m0 x3 h4 ye ff5 fs1 fc0 sc1 ls0 ws0">} </div><div class="t m0 x3 h4 yf ff5 fs1 fc0 sc1 ls6 ws2">uchar <span class="_ _2"></span>bitclr(uchar <span class="_ _2"></span>num,uchar <span class="_ _2"></span>bit) /*<span class="ff3 ls0 ws0">&#28165;&#38500;&#26576;&#19968;&#20301;<span class="ff5 ls5">*/ </span></span></div><div class="t m0 x3 h4 y10 ff5 fs1 fc0 sc1 ls0 ws0">{ </div><div class="t m0 x3 h4 y11 ff5 fs1 fc0 sc1 ls8 ws5"> <span class="_ _3"> </span>uchar bit_value[]={1,2,4,8,16,32,64,128}; </div><div class="t m0 x3 h4 y12 ff5 fs1 fc0 sc1 ls9 ws6"> return <span class="_ _4"></span>num&amp;~bit_value[bit]; </div><div class="t m0 x3 h4 y13 ff5 fs1 fc0 sc1 ls0 ws0">} </div><div class="t m0 x3 h4 y14 ff5 fs1 fc0 sc1 lsa ws7">uchar <span class="_ _2"></span>bitset(uchar <span class="_ _2"></span>num,uchar <span class="_ _2"></span>bit) /*<span class="ff3 ls0 ws0">&#35774;&#32622;&#26576;&#19968;&#20301;<span class="ff5 ls5">*/ </span></span></div><div class="t m0 x3 h4 y15 ff5 fs1 fc0 sc1 ls0 ws0">{ </div><div class="t m0 x3 h4 y16 ff5 fs1 fc0 sc1 ls8 ws8"> uchar <span class="_ _4"></span>bit_value[]={1,2,4,8,16,32,64,128}; </div><div class="t m0 x3 h4 y17 ff5 fs1 fc0 sc1 ls3 ws9"> return <span class="_ _4"></span>num|bit_value[bit]; </div><div class="t m0 x3 h4 y18 ff5 fs1 fc0 sc1 ls0 ws0">} </div><div class="t m0 x3 h4 y19 ff5 fs1 fc0 sc1 ls2 ws1">uchar bitcpl(uchar num,uchar bit) <span class="_"> </span> <span class="_ _1"> </span> <span class="_ _1"> </span>/*<span class="ff3 ls0 ws0">&#21462;&#21453;&#26576;&#19968;&#20301;<span class="ff5 ls5">*/ </span></span></div><div class="t m0 x3 h4 y1a ff5 fs1 fc0 sc1 ls0 ws0">{ </div><div class="t m0 x3 h4 y1b ff5 fs1 fc0 sc1 ls8 ws8"> uchar <span class="_ _4"></span>bit_value[]={1,2,4,8,16,32,64,128}; </div><div class="t m0 x3 h4 y1c ff5 fs1 fc0 sc1 ls6 wsa"> if(num&gt;&gt;bit&amp;0x01==1) </div><div class="t m0 x3 h4 y1d ff5 fs1 fc0 sc1 ls9 wsb"> <span class="_ _3"> </span> return <span class="_ _2"></span>num&amp;~bit_value[bit]; </div><div class="t m0 x3 h4 y1e ff5 fs1 fc0 sc1 ls7 ws4"> else </div><div class="t m0 x3 h4 y1f ff5 fs1 fc0 sc1 ls3 wsc"> <span class="_ _3"> </span> return <span class="_ _2"></span>num|bit_value[bit]; </div><div class="t m0 x3 h4 y20 ff5 fs1 fc0 sc1 ls0 ws0">} </div><div class="t m0 x3 h4 y21 ff5 fs1 fc0 sc1 ls3 ws0">/*<span class="ff3 ls0">&#20197;&#19979;&#20027;&#31243;&#24207;&#28436;&#31034;&#65292;&#35843;&#29992;&#26102;&#65292;&#21487;&#20197;&#30452;&#25509;&#32473;&#20986;&#25968;&#20540;&#65292;&#20063;&#21487;&#20197;&#32473;&#20986;&#21464;&#37327;&#21517;</span><span class="ls5">*/ </span></div><div class="t m0 x3 h4 y22 ff5 fs1 fc0 sc1 ls8 wsd">void main(void) </div><div class="t m0 x3 h4 y23 ff5 fs1 fc0 sc1 ls0 ws0">{ </div><div class="t m0 x3 h4 y24 ff5 fs1 fc0 sc1 lsa wse"> uchar <span class="_ _4"></span>xx=0xfe; </div><div class="t m0 x3 h4 y25 ff5 fs1 fc0 sc1 ls2 wsf"> xx=bitset(xx,0); </div><div class="t m0 x3 h4 y26 ff5 fs1 fc0 sc1 lsb ws10"> <span class="_ _5"> </span>printf("The set out is %x ",xx); </div><div class="t m0 x3 h4 y27 ff5 fs1 fc0 sc1 lsb ws10"> <span class="_ _5"> </span>printf("The clr out is %x ",bitclr(255,0)); </div><div class="t m0 x3 h4 y28 ff5 fs1 fc0 sc1 lsb ws11"> <span class="_ _5"> </span>printf("The test out is %x ",bittest(0xff,0)); </div><div class="t m0 x3 h4 y29 ff5 fs1 fc0 sc1 lsa ws12"> <span class="_ _5"> </span>printf("The cpl out is %x ",bitcpl(0x00,7)); </div><div class="t m0 x3 h4 y2a ff5 fs1 fc0 sc1 ls0 ws0">} </div><div class="t m0 x3 h4 y2b ff5 fs1 fc0 sc1 ls0 ws0"> </div><div class="t m0 x4 h5 y2c ff6 fs2 fc1 sc2 lsc ws0">&#24179;&#20961;&#21333;&#29255;&#26426;&#24037;&#20316;&#23460;<span class="ff7 fc0 sc0 ls0"> </span></div><div class="t m0 x5 h4 y2d ff6 fs1 fc0 sc1 lsd ws0">&#26412;&#25991;&#21457;&#34920;&#20110;&#12298;&#30005;&#23376;&#25253;&#12299;<span class="ff5 ls0"> </span></div><div class="t m0 x6 h4 y2e ff5 fs1 fc0 sc1 ls0 ws0"> </div><a class="l" rel='nofollow' onclick='return false;'><div class="d m1"></div></a></div><div class="pi" data-data='{"ctm":[1.611639,0.000000,0.000000,1.611639,0.000000,0.000000]}'></div></div> </body> </html>
评论
    相关推荐
    • 单片机C语言编程课件
      单片机C语言编程与实践课件,里面有各种程序实现的代码 实现的方法 AD转换器 wire总线 串行通信 按键接口 中断定时 数码管显示等
    • 经典单片机C语言教程
      经典单片机C语言教程,经典不容错过! 经典单片机C语言教程,经典不容错过! 经典单片机C语言教程,经典不容错过! 经典单片机C语言教程,经典不容错过! 经典单片机C语言教程,经典不容错过!
    • 单片机C语言轻松入门:单片机c语言
      描述了单片机的基本概念和C语言编程实现方法,其中有很多实例分析,让你在案例中掌握单片机的使用技巧,可以很好的与仿真软件keil连接使用。
    • 单片机C语言入门教程
      详细解析单片机各功能部件;结合C语言,通过实例教授如何编写单片机内部功能及其与外围器件连接的程序;介绍了KEIL软件和在此平台上如何编写程序。
    • 单片机C语言
      单片机C语言编程与实例》的代码
    • 单片机C语言开发程序
      经典单片机仿真实验板仿真实例,内容非常详细,祝你一臂之力,单片机C语言开发程序
    • 单片机c语言源码
      单片机c语言开发方面的数码管,按键扫描,lcd显示,串口通信,I2C通信,温度监控系统等
    • 单片机c语言学习资料
      用于单片机的学习资料,讲解内容详细,实例较多,不错的资料
    • 51单片机C语言51单片机C语言
      51单片机C语言51单片机C语言51单片机C语言51单片机C语言
    • PIC单片机C语言编程
      PIC单片机C语言编程教程,电子书籍。很详细,有实例