运营商与QUOT; |"用法是C PI咂舌 [英] Operator "|" usage is c raspberry pi

查看:196
本文介绍了运营商与QUOT; |"用法是C PI咂舌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的树莓派读取数据的陀螺仪。是新来的,但到目前为止,据我所知,我从除了利用我的基础code一切|在里面。
当寻找它,它说,它按位或运算符但在我的情况它没有什么意义,不是再次我不明白,在维基百科上的解释。

这是使用它看起来如下行

 参考readBlock(0x80的| OUT_X_L_G,sizeof的(块),块);

参考readBlock是用户自定义函数如下:

 参考readBlock(uint8_t有命令,uint8_t有大小,uint8_t有*数据){
INT结果= i2c_smbus_read_i2c_block_data(文件,命令,大小的数据);
}


解决方案

这位前pression 0x80的| OUT_X_L_G 与位数返回 OUT_X_L_G 的值 7 设置:

  OUT_X_L_G = XXXX XXXX
  按位或
0x80的= 1000 0000
---------------------
结果= 1XXX XXXX

整个函数调用背后的逻辑应该由你不提供上下文来决定。

I am using raspberry pi to read a gyroscopic data. Am new to it but so far I understand everything that I am basing my code from besides the use of "|" in it. When looking it up it says its "bitwise OR" operator but in my situation it doesnt make sense, than again I don't understand the explanation on Wikipedia.

The line that uses it looks as follows

readBlock(0x80 | OUT_X_L_G, sizeof(block), block);

readBlock is user defined function as follows.

readBlock(uint8_t command, uint8_t size, uint8_t *data) {
int result = i2c_smbus_read_i2c_block_data(file, command, size, data);
}

解决方案

The expression 0x80 | OUT_X_L_G is returning a value of OUT_X_L_G with a bit number 7 set:

OUT_X_L_G = xxxx xxxx
  bitwise or
0x80      = 1000 0000
---------------------
result    = 1xxx xxxx

The logic behind the whole function call should be determined by the context you are not providing.

这篇关于运营商与QUOT; |"用法是C PI咂舌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆