Files
kunlun/driver/inc/power_mgmt.h
2024-09-28 14:24:04 +08:00

105 lines
3.4 KiB
C

/****************************************************************************
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
be copied by any method or incorporated into another program without
the express written consent of Aerospace C.Power. This Information or any portion
thereof remains the property of Aerospace C.Power. The Information contained herein
is believed to be accurate and Aerospace C.Power assumes no responsibility or
liability for its use in any way and conveys no license or title under
any patent or copyright and makes no representation or warranty that this
Information is free from patent or copyright infringement.
****************************************************************************/
#ifndef _POWER_MGMT_H
#define _POWER_MGMT_H
#ifdef __cplusplus
extern "C" {
#endif
#define POWER_12V_DETECT_CNT 10
#define POWER_12V_DETECT_FAIL_THR (POWER_12V_DETECT_CNT/2)
#define POWER_CHARGE_COUNT_MAX 7200 //100ms *7200 = 720s = 12m
#define POWER_AUX_CHECK_COUNT_MAX 3
#define POWER_SAMPLE_COUNT_MAX 2
#define POWER_SADC_DISABLE_COUNT_MAX 100
#define POWER_MANAGEMENT_DEBUG 0
typedef enum {
POWER_TYPE_12V,
POWER_TYPE_3V,
POWER_TYPE_GND,
} power_type_t;
/**
* @brief power_get_supply_high_volt_thr() - get threshold of supply high voltage.
* voltage less than this means module is power down.
* @retval threshold voltage, unit:mV.
*/
int32_t power_get_supply_high_volt_thr();
/**
* @brief power_get_supply_low_volt_thr() - get threshold of supply low voltage.
* voltage less than this means module is pulled out or wrong.
* @retval threshold voltage, unit:mV.
*/
int32_t power_get_supply_low_volt_thr();
/**
* @brief power_get_supply_normal_volt_thr() - get threshold of supply normal voltage.
* voltage less than this means power is abnormal.
* @retval threshold voltage, unit:mV.
*/
int32_t power_get_supply_normal_volt_thr();
/**
* @brief power_get_charge_volt_thr() - get threshold of charging voltage.
* @param start_thr: pointer of start charging threshold voltage, unit:mV.
* @param stop_thr: pointer of stop charging threshold voltage, unit:mV.
* @retval none.
*/
void power_get_charge_volt_thr(int16_t *start_thr, int16_t *stop_thr);
/**
* @brief power_get_event_detection_enable() - get event detection enable or not.
* @retval 1: event detection enable;
* 0: event detection not enable.
*/
uint8_t power_get_event_detection_enable();
/**
* @brief power_get_3v_lowest_volt_thr() - get threshold of super capacitor lowest voltage.
* voltage less than this means charge circuit is bad, need disable charge.
* @retval threshold voltage, unit:mV.
*/
int32_t power_get_3v_lowest_volt_thr();
/**
* @brief power_get_gnd_low_volt_thr() - get threshold of gnd low voltage.
* @retval threshold voltage, unit:mV.
*/
int32_t power_get_gnd_low_volt_thr();
/**
* @brief power_get_volt() - get voltage by type.
* @param type, power type, refs to POWER_TYPE_xxx().
* @param ch, the adc channel of power type.
* @param err_num: err_num return value:
0 - normal. data is OK;
1 - abnormal, data is not OK;
2 - device in use;
* @retval voltage, unit:mV.
*/
int32_t power_get_volt(power_type_t type, uint32_t ch, uint8_t *err_num);
#ifdef __cplusplus
}
#endif
#endif /* _POWER_MGMT_H */