config.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include <stdint.h>
  2. #include <stdbool.h>
  3. #ifndef CONFIG_H_
  4. #define CONFIG_H_
  5. #define I2C_TX_MAX_PACKET_SIZE (8)
  6. #define I2C_RX_MAX_PACKET_SIZE (12)
  7. #define BATTERY_THRESHOLD (20)
  8. #define TEMPERATURE_MAX_C (60)
  9. #define MAX_CYCLES (2)
  10. #define TARGET_BASE_ADDRESS (0x48)
  11. #define MEASUREMENT_CHECK_INTERVAL 320000 //Do not know yet the exact timing
  12. #define HEALTHY_BATTERY_VALUE (3800)
  13. //PWM Value:
  14. #define INITIAL_PWM_VALUE (0)
  15. #define PWM_INCREMENT_VALUE (1)
  16. #define PWM_DECREMENT_VALUE (1)
  17. #define PWM_MAX_VALUE (320)
  18. // soft overvoltage treshold before getting into the soft overvoltage state
  19. #define SOV_THRESHOLD_MV 6000
  20. // hard overvoltage treshold for getting into the hard overvoltage state (error)
  21. #define HOV_THRESHOLD_MV 8000
  22. // define the temperature error state
  23. #define OVERTEMPERATURE_TRESHOLD 43
  24. #define CONTROLLER_HYSTERESIS 5
  25. typedef struct{
  26. uint8_t txBuffer[I2C_TX_MAX_PACKET_SIZE];
  27. uint8_t txLen;
  28. uint8_t txCount;
  29. bool txComplete;
  30. }tx_Packet;
  31. typedef struct{
  32. uint8_t rxBuffer[I2C_RX_MAX_PACKET_SIZE];
  33. uint8_t rxLen;
  34. uint8_t rxCount;
  35. bool rxComplete;
  36. }rx_Packet;
  37. // Global variables declared in i2c_hal.c
  38. extern tx_Packet txPacket;
  39. extern rx_Packet rxPacket;
  40. #endif