Is there a general I2C command to see if a device is still present on the bus?

تعرفه تبلیغات در سایت
عنوان عکس
عنوان عکس
عنوان عکس
عنوان عکس
عنوان عکس

آرشیو مطالب

جستجوگر

یافته ها در جستجو

    امکانات وب

    برچسب ها

    Is there a general I2C command to see if a device is still present on the bus after it is initialized once? For example an OLED display. The reason I ask this is to avoid the main program will freeze (when a device is disconnected) because of infinite loops present in the library code, in for example, the Wire library.

    At startup of the MCU I want to check if a device is available or not and initialized when it is available. I do this with this function and works fine .....

    bool MyClass::isPnpDeviceAvailable( uint8_t iAddress, bool bIsInitOnce = false )
    {
         // Try to start connection
        Wire.beginTransmission( iAddress );
    
         // End connection without STOP command if already is initialized
        return ( Wire.endTransmission( !bIsInitOnce ) == 0x00 ); // No Error?, return true
    }
    
    

    .... however, when I want to check if a device is still there, before I perform an update, when I do this:

    // 1.
    if( isPnpDeviceAvailable( 0x3C, true )) 
     { /* Cause program hang */ }
    // 2.
    if( isPnpDeviceAvailable( 0x3C )) 
     { /* Cause display to turn off  */ }
    
    

    Is there a general command available, to say/send just a "Hello, are you there" and wait for a reply without sending START and STOP commands and without interrupting device/bus status?


    Here is the proto-type device I made with attached (optional PNP I2C) display.

    Device with PNP I2C display

    نویسنده : استخدام کار بازدید : 16 تاريخ : دوشنبه 13 شهريور 1396 ساعت: 16:28
    برچسب‌ها :

    خبرنامه

    عضویت

    نام کاربري :
    رمز عبور :