Advertisement
Benny1994

ina libary error

Jun 2nd, 2021
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. /*
  2.  * ina.c
  3.  *
  4.  *  Created on: Jun 2, 2021
  5.  *      Author: Ben De Lathouwer
  6.  */
  7. #include "ina.h"
  8. #include "stm32h7xx_hal.h"
  9. #include <stdio.h>
  10. I2C_HandleTypeDef hi2c4;
  11. HAL_StatusTypeDef ret;
  12.  
  13. static const int ina_adder = 0x40;// slave addres of the ina219
  14. //internal registers of the ina219
  15. static const uint8_t config_reg     = 0x00;
  16. //static const uint8_t Shunt_Volt_Reg = 0x01;
  17. //static const uint8_t Bus_Volt_Reg   = 0x02;
  18. //static const uint8_t Power_reg     = 0x03;
  19. //static const uint8_t Current_reg  = 0x04;
  20. //static const uint8_t Cal_Reg       = 0x05;
  21.  
  22. uint8_t buf[12];
  23.  
  24.  
  25. //configuring the ina219
  26. int Config_INA(void)
  27. {
  28.     buf[0]=config_reg;
  29.     ret = HAL_I2C_Master_Transmit(&hi2c4, ina_adder, buf, 1, 1000);
  30.     if(ret != HAL_OK)
  31.     {
  32.         return 0;
  33.  
  34.     }
  35.     else
  36.     {
  37.         return 1;
  38.     }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement