- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何使用 bcm2835 库更改 mlx90614 的从机地址?我尝试过以下代码...
int main()
{
// Buffer, where I store data which I'll send
unsigned char buf[6];
// bcm2835 i2c module intialisation code
bcm2835_init();
bcm2835_i2c_begin();
bcm2835_i2c_set_baudrate(25000);
bcm2835_i2c_setSlaveAddress(0x00);
// For debug purposes, I read what reason codes operations give.
bcm2835I2CReasonCodes why;
bcm2835_i2c_begin();
// function which reads and prints what value eeprom address 0x0e has.
// See below the main.
printf("Initial check\n");
check(); // this time it prints a factory default value 0x5a.
// To access eeprom, the command must start with 0x2X, where x determines the
// address, resulting 0x2e.
buf[0] = 0x2e;
// According to datasheet, I first have to clear the address before
// real write operation.
buf[1] = 0x00;
buf[2] = 0x00;
why = bcm2835_i2c_write(buf,3);
reason(why); // resolves and prints the reason code. This time it prints OK
// according to datasheet, eeprom needs 5ms to make a write operation,
// but I give it 2 seconds.
sleep(2);
// Then I check did the value in eeprom 0x0e change. IT DOESN'T!
printf("Check after clear\n");
check();
// Then I try to write a new address to the eeprom but since the clearing
// the register didn't work, this is very unlikely to work either.
buf[0] = 0x2e;
buf[1] = 0x4b;
buf[2] = 0x00;
why = bcm2835_i2c_write(buf,3);
reason(why);
sleep(2);
// The datasheet says that I have to reset the power supply and after that
// the device should respond to the new slave address.
// I do that by pluging off the jumper wires and reconnecting them
// after the program has finnished.
bcm2835_i2c_end();
return 0;
}
// The function I use to determine what the reason code was.
void reason(bcm2835I2CReasonCodes why)
{
printf("Reason is: ");
if(why == BCM2835_I2C_REASON_OK)
{
printf("OK");
}else if(why == BCM2835_I2C_REASON_ERROR_NACK){
printf("NACK");
}else if(why == BCM2835_I2C_REASON_ERROR_CLKT){
printf("Clock stretch");
}else if(why == BCM2835_I2C_REASON_ERROR_DATA ){
printf("Data error");
}else{
printf("Dunno lol");
}
printf("\n");
return;
}
// Here I read eeprom 0x2e.
void check()
{
unsigned char buf[6];
unsigned char reg = 0x2e;
bcm2835I2CReasonCodes why;
// better safe than sorry with the buffer :)
buf[0] = 0;
buf[1] = 0;
buf[2] = 0;
why = bcm2835_i2c_write (®, 1);
reason(why);
why = bcm2835_i2c_read_register_rs(®,&buf[0],3);
reason(why);
printf("Buffer values are: %x ; %x ; %x \n", buf[0], buf[1], buf[2]);
}
程序的输出如下:
Initial check
Reason is: OK
Reason is: OK
Buffer values are: 5a ; be ; dc
Reason is: OK
Check after clear
Reason is: OK
Reason is: OK
Buffer values are: 5a ; be ; dc
Reason is: OK
如果我在此之后运行 i2cdetect -y 1,该设备不会出现在表中,但它会响应从 0x00 或 0x5a 调用它的程序。我使用了这样的程序后,i2cDetect可以正常从地址0x5a检测到设备。
所以我想真正的问题是,为什么我无法清除并重写 eeprom 0x0e?
Mlx90614 SMBus 通信的说明如下。最相关的页面是 IMO 第 19 页,它实际上给出了我想要做的伪代码示例。 http://www.melexis.com/Assets/SMBus-communication-with-MLX90614-5207.aspx
这是 mlx90614 的数据表 http://www.melexis.com/Assets/IR-sensor-thermometer-MLX90614-Datasheet-5152.aspx
这是 bcm2835 的文档www.airspayce.com/mikem/bcm2835/group__i2c.html
最佳答案
您必须添加一个错误字节。看看这个网站的解释:https://sf264.wordpress.com/2011/03/10/howto-mlx90614-und-pwm/
计算 00002e4b00
的 CRC-8 得到 0xa3
。
我用这个网站来计算CRC-8:http://smbus.org/faq/crc8Applet.htm
我还没有测试过这个,但我认为这应该有效:
buf[0] = 0x2e;
buf[1] = 0x4b;
buf[2] = 0x00;
buf[3] = 0xa3;
why = bcm2835_i2c_write(buf,4);
关于通过 SMBus/I2C 更改带有 bcm2835 的 mlx90614 从机地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21690360/
在此NIC每秒可以接收多少个数据包而不丢弃任何UDP流量的情况下,还有其他人有基准吗?使用64字节UDP数据包,我看到大约每秒10万个数据包,直到丢包为止。 最佳答案 我已经完成了在HP DL785上
所以我在 c 中有这个函数(下面的代码)来检查数据库中的数据。如果该数据等于 255,我希望在树莓派上的一个 GPIO 引脚 (12) 上有一个 LED 亮起。 我首先尝试了没有 bcm 函数的代码,
虽然找到了许多关于如何使用 GPIO.BCM 模式设置 gpio 的示例(其中引脚编号等效于 RPI(参见图像和 nvidia/jetson-gpio),但我找不到在 GPIO.TEGRA_SOC 模
我一直在努力编写一个脚本,该脚本将 Pi 的 BCM 引脚 17、27 和 10 打开 1 秒,然后关闭 1 秒,连续 100 次。当我运行脚本时,LED1 会亮起然后熄灭,程序因以下错误而关闭: T
我是一名优秀的程序员,十分优秀!