是否可以使用两种不同的IDE进行I2C通信?

时间:2017-04-20 15:18:01

标签: arduino ide i2c

我有一个Atmel AVR作为I2C主设备和一个Arduino作为从设备。 AVR在Atmel Studio和Arduino IDE中的Arduino中编程。这种沟通可能吗?如果没有,怎么办?我的问题是用于I2C事务的Atmel控制器使用一种格式来读/写命令。但我在Arduino中找不到任何特殊命令。我怎么能这样做?

typedef struct {
  /* ! TWI chip address to communicate with. */
  char chip;
  /* ! TWI address/commands to issue to the other chip (node). */
  uint8_t addr[3];
  /* ! Length of the TWI data address segment (1-3 bytes). */
  int addr_length;
  /* ! Where to find the data to be written. */
  uint8_t *buffer;
  /* ! How many bytes do we want to write. */
  unsigned int length;
} twi_package_t; 

此代码是传入I2C主设备的参数,即AVR。我的问题是第二个参数。任何想法我应该在这做什么?

感谢。

1 个答案:

答案 0 :(得分:1)

I2C是一种不依赖IDE的标准协议。 Arduino IDE有一个软件层,可以隐藏(临时)用户的内容,使他们能够实现I2C通信等功能。只要你的代码在两台机器上都是正确的,绝对没有问题。