简体   繁体   English

I2C:可以同时发生多个 I2C 错误吗?

[英]I2C: can multiple I2C errors occur simultaneously?

I write the driver for the I2C protocol, target microcontroller is STM32F413ZH .我为 I2C 协议编写驱动程序,目标微控制器是STM32F413ZH Don't ask me why I write my own driver (this is the project requirement).不要问我为什么要自己写驱动(这是项目要求)。

I want to create simple public API returning error state, but I wonder whether multiple I2C errors can occur at the same time.我想创建简单的公共 API 返回错误 state,但我想知道是否可以同时出现多个 I2C 错误。 If yes, my API cannot return just single enum type, but it should return something more complex like the structure consisting of bit fields of bool type or something else.如果是,我的 API 不能只返回单个枚举类型,但它应该返回更复杂的东西,比如由 bool 类型的位字段或其他东西组成的结构。

Anyway, the main question is:无论如何,主要问题是:

Can multiple I2C errors occur simultaneously (at the same time)?多个 I2C 错误可以同时(同时)发生吗?

number of I2C errors is limited (limited by the number of bits in the status register). I2C 错误的数量是有限的(受状态寄存器中的位数限制)。

More than one flag can be raised by the I2C hardware so usually I use bits for the particular error enum I2C 硬件可以引发多个标志,因此通常我将位用于特定的错误枚举

typedef enum
{
    I2C_OK      = 0,
    I2C_ERROR1  = 1 << 0,
    I2C_ERROR2  = 1 << 1,
    I2C_ERROR3  = 1 << 2,
    I2C_ERROR4  = 1 << 3,
     /* other */
}I2C_ERRORS_ENUMS;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM