我怎样才能获得设备地址?

时间:2018-05-04 05:50:14

标签: i2c

我想用i2c阅读触摸屏。但是当我调试这个代码时,比       while(I2C_GetFlagStatus(I2C1,I2C_ISR_TXIS)== RESET)行无法正常工作。我该怎么办?请帮助我

void EXTI1_IRQHandler(void)
    {
      if (EXTI_GetITStatus((EXTI_Line1) != RESET))
      {

        res = touch_i2c_read(0x3C, 0x00, i2c_buffer, 22);
        //  printf("deneme");
        if (!res)
        {
        }

        else
        {
        }
        EXTI_ClearITPendingBit(EXTI_Line0);
      }
    }    



static uint32_t touch_i2c_read(uint8_t DeviceAddr, uint8_t RegAddr, uint8_t *pBuffer, uint16_t len)
    { //uint8_t deviceaddr ,0x00,(uint8_t *)&buf, sizeof(buf)
      uint32_t timeout = I2C_TIMEOUT;
      while (I2C_GetFlagStatus(I2C1, I2C_ISR_BUSY) != RESET)
      {
        if ((timeout--) == 0)
          return 0;
      }

      I2C_TransferHandling(I2C1, DeviceAddr << 1, 1, I2C_SoftEnd_Mode, I2C_Generate_Start_Write);
      /* !(!! Wait until TXIS flag is set !!! */
      timeout = I2C_TIMEOUT;

      while (I2C_GetFlagStatus(I2C1, I2C_ISR_TXIS) == RESET)
      {

        if ((timeout--) == 0)
          return 0;
      }
      GPIO_SetBits(DEBUG_LED_PORT, DEBUG_LED_PIN);
    }

0 个答案:

没有答案