drv_charger.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _DRV_CHARGER_H_
  13. #define _DRV_CHARGER_H_
  14. #include <stdint.h>
  15. #include <stdbool.h>
  16. #include <stddef.h>
  17. #include "quec_proj_config.h"
  18. #ifdef CONFIG_QUEC_PROJECT_FEATURE_USB_CHARGE
  19. #include "ql_power.h"
  20. #endif
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. typedef enum
  25. {
  26. DRV_CHARGER_TYPE_NONE,
  27. DRV_CHARGER_TYPE_SDP,
  28. DRV_CHARGER_TYPE_DCP,
  29. DRV_CHARGER_TYPE_CDP,
  30. DRV_CHARGER_TYPE_UNKOWN //no use adapter
  31. } drvChargerType_t;
  32. typedef void (*drvChargerPlugCB_t)(void *ctx, bool plugged);
  33. typedef void (*drvChargerNoticeCB_t)(void);
  34. void drvChargerInit(void);
  35. void drvChargerSetNoticeCB(drvChargerNoticeCB_t notice_cb);
  36. void drvChargerSetCB(drvChargerPlugCB_t cb, void *ctx);
  37. drvChargerType_t drvChargerGetType(void);
  38. /**
  39. * @brief return the charger and battery info.
  40. *
  41. * @param nBcs set the channel to measue
  42. * 0 No charging adapter is connected
  43. * 1 Charging adapter is connected
  44. * 2 Charging adapter is connected, charging in progress
  45. * 3 Charging adapter is connected, charging has finished
  46. * 4 Charging error, charging is interrupted
  47. * 5 False charging temperature, charging is interrupted while temperature is beyond allowed range
  48. * @param nBcl percent of remaining capacity.
  49. */
  50. void drvChargerGetInfo(uint8_t *nBcs, uint8_t *nBcl);
  51. void drvChargeEnable(void);
  52. void drvChargeDisable(void);
  53. uint16_t drvChargerGetVbatRT();
  54. #ifdef CONFIG_QUEC_PROJECT_FEATURE
  55. uint32_t quec_get_bat_capicity();
  56. #endif
  57. #ifdef CONFIG_QUEC_PROJECT_FEATURE_USB_CHARGE
  58. uint32_t quec_get_vchg_vol();
  59. uint32_t quec_get_vbat_vol();
  60. uint32_t quec_get_vbat_cur();
  61. uint32_t quec_get_chg_status();
  62. bool quec_get_charger_state();
  63. void quec_charge_set_config(ql_charge_config_t *charge_config);
  64. void quec_charge_get_config(ql_charge_config_t *charge_config);
  65. void quec_charge_set_over_temp(bool over_temp);
  66. #endif
  67. #ifdef __cplusplus
  68. }
  69. #endif
  70. #endif