app zone I2C

5 thoughts on “app zone I2C

  1. Hi

    I want to use NO Blocking i2C mode

     

     unsigned char buf[10]; // is global variable

     int M2M_msgProc2(int type, long param1, long param2)
    {
        int res = 0;
    // Open address 0

       i2c_handle = m2m_hw_i2c_open (0);

       if (i2c_handle != M2M_HW_I2C_HANDLE_INVALID) {
          //Get the current device settings
          m2m_hw_i2c_ioctl(i2c_handle,M2M_HW_I2C_OPTIONS_GET,&arg);

          //Set the device setting while using master,100K speed and 7 bit address
         
    m2m_hw_i2c_ioctl(i2c_handle,M2M_HW_I2C_OPTIONS_SET,M2M_HW_I2C_MASTER |
    M2M_HW_I2C_NORMAL_SPEED | M2M_HW_I2C_7_BIT_ADDRESS);

     m2m_hw_i2c_ioctl ((i2c_handle, M2M_HW_I2C_IO_BLOCKING_SET, M2M_HW_I2C_IO_BLOCKING_OFF);

     

       }

       if (i2c_handle != M2M_HW_I2C_HANDLE_INVALID) {
          result = m2m_hw_i2c_read_register (i2c_handle,0,buf,2,&len_read);
       }

     

     

     

        return res;
    }

      

     

    I read buffer in  function belov , but buffor[0] and bufor[1] has wrong value, when i read in blocking mode, read buffor is OK, what is wrong?

     

    void M2M_onI2CEvent (int event, unsigned long handle, unsigned char* buffer, unsigned long length)
    {

        //Touch unused variables to avoid warnings
        (void)handle;
        (void)buffer;
        (void)length;

        switch (event) {
            case M2M_I2C_EVENT_READ_REGISTER_COMPLETE:

                    PrintToUart("bufor0=%x",buffor[0];

                    PrintToUart("bufor1=%x",buffor[1];

                break;
               
            case M2M_I2C_EVENT_READ_DATA_COMPLETE:
                break;

            case M2M_I2C_EVENT_WRITE_REGISTER_COMPLETE:
                break;

            case M2M_I2C_EVENT_WRITE_DATA_COMPLETE:
                break;
        }
    }

     

    1. Hello Tomek, 

       

      can you please send your application log to ‘or.prat@telit.com’ for analysis.

       

      thank you. 

      1. Hello Tomek, 

         

        can you please send your application log to ‘or.prat@telit.com’ for analysis.

         

        thank you. 

        How I get log? I don’t connect SPI interface?

        1. i meant the terminal log you receive using the ‘printToUart’ function.

          please send the logs from both runs of the applicaiton (with/without setting blocking

          mode to off).

           

          thanks.