i2c_pi_target.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef I2C_PI_TARGET_H
  2. #define I2C_PI_TARGET_H
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #include "src/battery_data/battery.h"
  6. // I2C command codes
  7. #define CMD_GET_BATTERY_STATUS 0x01 // Request battery state
  8. #define CMD_GET_BATTERY_DATA 0x02 // Request battery data
  9. #define CMD_SET_BATTERY_LIMIT 0x03 // SET min/max voltage, cutoff current limits
  10. typedef struct __attribute__((packed)){
  11. uint16_t voltage;
  12. int16_t current;
  13. uint16_t temperature;
  14. uint8_t cycle_number;
  15. BatteryChargingState cycle_state;
  16. } BatteryData;
  17. typedef struct __attribute__((packed)){
  18. uint16_t min_voltage;
  19. uint16_t max_voltage;
  20. uint8_t charge_fraction;
  21. uint16_t capacitance;
  22. uint8_t cut_off_current;
  23. uint8_t previous_cycle_number;
  24. } BatteryLimitMsg;
  25. typedef enum{
  26. SUCCESS = 0x00,
  27. INVALID_CYCLE= 0x01,
  28. ERROR= 0x02
  29. }statusResponse;
  30. typedef struct{
  31. statusResponse status_response;
  32. }statusResponsePi;
  33. void dynamic_gpio_addressing();
  34. void pi_i2c_mcu();
  35. #endif