daily pastebin goal
9%
SHARE
TWEET

Untitled

a guest Feb 25th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bool isl29125_init(I2C_HandleTypeDef* hi2c_x)
  2. {
  3.     bool ret = true;
  4.  
  5.     if(HAL_I2C_IsDeviceReady(hi2c_x, ISL_I2C_ADDR<<1, 10, 1000) != HAL_OK) {
  6.         ret &= false;
  7.     }
  8.  
  9.     uint8_t receive_data[1];
  10.     uint8_t send_data = DEVICE_ID;
  11.  
  12.     HAL_I2C_Master_Transmit(hi2c_x,ISL_I2C_ADDR<<1,&send_data,1,1000);
  13.     HAL_Delay(15);
  14.  
  15.     HAL_I2C_Master_Receive(hi2c_x,ISL_I2C_ADDR<<1,receive_data,1,1000);
  16.  
  17.  
  18.     if (receive_data[0] != 0x7D) {
  19.         ret &= false;
  20.     }
  21.  
  22.     return(ret);
  23. }
  24.    
  25. static void MX_I2C1_Init(void)
  26. {
  27.   hi2c1.Instance = I2C1;
  28.   hi2c1.Init.Timing = 0x2000090E;
  29.   hi2c1.Init.OwnAddress1 = 0;
  30.   hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  31.   hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  32.   hi2c1.Init.OwnAddress2 = 0;
  33.   hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
  34.   hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  35.   hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top