1234567891011121314151617181920212223242526272829303132 |
- #ifndef __HAL_BATTERY_H__
- #define __HAL_BATTERY_H__
- /*********************************************************************
- * INCLUDES
- */
- #include "usr_config.h"
- #include "bsp_adc.h"
- #include "bsp_time.h"
- #include "system.h"
- #define ADC_REF_VOLTAGE_IN_MILLIVOLTS 600 /**< Reference voltage (in milli volts) used by ADC while doing conversion. */
- #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.*/
- #define ADC_RES_10BIT 4096 /**< Maximum digital value for 10-bit ADC conversion. */
- #define ADC_RESULT_IN_MILLI_VOLTS(ADC_VALUE)\
- ((((ADC_VALUE) * ADC_REF_VOLTAGE_IN_MILLIVOLTS) / ADC_RES_10BIT) * ADC_PRE_SCALING_COMPENSATION)
- /*********************************************************************
- * API
- */
- void Battery_Initialize(void);
- void Battery_Enable(bool value);
- uint8_t GetBatteryPersent(void);
- uint8_t Battery_BatteryIs_0(void);
- int16_t ADC_GetValue(uint32_t channel);
- #endif
|