hal_battery.h 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. #ifndef __HAL_BATTERY_H__
  2. #define __HAL_BATTERY_H__
  3. /*********************************************************************
  4. * INCLUDES
  5. */
  6. #include "usr_config.h"
  7. #include "bsp_adc.h"
  8. #include "bsp_time.h"
  9. #include "system.h"
  10. #define ADC_REF_VOLTAGE_IN_MILLIVOLTS 600 /**< Reference voltage (in milli volts) used by ADC while doing conversion. */
  11. #define ADC_PRE_SCALING_COMPENSATION 6 /**< The ADC is configured to use VDD with 1/3 prescaling as input. And hence the result of conversion is to be multiplied by 3 to get the actual value of the battery voltage.*/
  12. #define ADC_RES_10BIT 4096 /**< Maximum digital value for 10-bit ADC conversion. */
  13. #define ADC_RESULT_IN_MILLI_VOLTS(ADC_VALUE)\
  14. ((((ADC_VALUE) * ADC_REF_VOLTAGE_IN_MILLIVOLTS) / ADC_RES_10BIT) * ADC_PRE_SCALING_COMPENSATION)
  15. /*********************************************************************
  16. * API
  17. */
  18. void Battery_Initialize(void);
  19. uint8_t GetBatteryPersent(void);
  20. void hal_battery_init(void);
  21. int16_t hal_GetBatttery_Adc(void);
  22. #endif