1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 5 #ifndef AOS_PM_H 6 #define AOS_PM_H 7 8 typedef enum { 9 AOS_CHARGER_STAT_SHUTDOWN = 0, 10 AOS_CHARGER_STAT_CHECK, 11 AOS_CHARGER_STAT_TRICKLE, 12 AOS_CHARGER_STAT_PRE, 13 AOS_CHARGER_STAT_CC, 14 AOS_CHARGER_STAT_CV, 15 AOS_CHARGER_STAT_TERMINAL, 16 AOS_CHARGER_STAT_FAULT 17 } aos_charger_state_t; 18 19 /** 20 * System enter sleep 21 * 22 * @return 0 : on success, negative number : if an error occurred with any step 23 */ 24 int aos_system_sleep(void); 25 26 /** 27 * Enable system autosleep interface 28 * 29 * @param[in] mode 1 - autosleep enable, 0 - autosleep disable 30 * 31 * @return 0 : on success, negative number : if an error occurred with any step 32 */ 33 int aos_system_autosleep(int mode); 34 35 /** 36 * Accquire wakelock 37 * 38 * @param[in] wakelock wakelock instance 39 * 40 * @return 0 : on success, negative number : if an error occurred with any step 41 */ 42 int aos_wakelock_lock(void *wakelock); 43 44 /** 45 * Release wakelock 46 * 47 * @param[in] wakelock wakelock instance 48 * 49 * @return 0 : on success, negative number : if an error occurred with any step 50 */ 51 int aos_wakelock_unlock(void *wakelock); 52 53 /** 54 * Accquire wakelock within given time 55 * 56 * @param[in] wakelock wakelock instance 57 * @param[in] msec wakelock keep time in ms 58 * 59 * @return 0 : on success, negative number : if an error occurred with any step 60 */ 61 int aos_wakelock_timedlock(void *wakelock, unsigned int msec); 62 63 /** 64 * Create wakelock 65 * 66 * @param[in] name wakelock name 67 * 68 * @return 0 : on success, negative number : if an error occurred with any step 69 */ 70 void *aos_wakelock_create(const char *name); 71 72 /** 73 * Destroy wakelock 74 * 75 * @param[in] wakelock wakelock instance 76 * 77 * @return 0 : on success, negative number : if an error occurred with any step 78 */ 79 void aos_wakelock_release(void *wakelock); 80 81 /** 82 * Register power key state notifier 83 * 84 * @param[in] cb power key notifier callback (argment: 1 - key down, 0 - key up) 85 * 86 * @return 0 : on success, negative number : if an error occurred with any step 87 */ 88 int aos_pwrkey_notify_register(void (*cb)(int)); 89 90 /** 91 * Device power down 92 * 93 * @return 0 : on success, negative number : if an error occurred with any step 94 */ 95 int aos_power_down(void); 96 97 /** 98 * Device power reset 99 * 100 * @return 0 : on success, negative number : if an error occurred with any step 101 */ 102 int aos_power_reset(void); 103 104 /** 105 * Get battery connection state 106 * 107 * @param[in] state (1 - connected, 0 - disconnected) 108 * 109 * @return 0 : on success, negative number : if an error occurred with any step 110 */ 111 int aos_battery_connect_state_get(int *state); 112 113 /** 114 * Get battery connection state 115 * 116 * @param[in] store voltage in mV 117 * 118 * @return 0 : on success, negative number : if an error occurred with any step 119 */ 120 int aos_battery_voltage_get(int *voltage); 121 122 /** 123 * Get battery level 124 * 125 * @param[in] store battery level (0 - 100) 126 * 127 * @return 0 : on success, negative number : if an error occurred with any step 128 */ 129 int aos_battery_level_get(int *level); 130 131 /** 132 * Get battery temperature 133 * 134 * @param[in] store temperature 135 * 136 * @return 0 : on success, negative number : if an error occurred with any step 137 */ 138 int aos_battery_temperature_get(int *temperature); 139 140 /** 141 * Get charger connection state 142 * 143 * @param[in] store connection state (1 - connected, 0 - disconnected) 144 * 145 * @return 0 : on success, negative number : if an error occurred with any step 146 */ 147 int aos_charger_connect_state_get(int *state); 148 149 /** 150 * Get charger state 151 * 152 * @param[in] store charger state 153 * 154 * @return 0 : on success, negative number : if an error occurred with any step 155 */ 156 int aos_charger_state_get(aos_charger_state_t *state); 157 158 /** 159 * Get charger current 160 * 161 * @param[in] store charger current in mA 162 * 163 * @return 0 : on success, negative number : if an error occurred with any step 164 */ 165 int aos_charger_current_get(int *current); 166 167 /** 168 * Set charger switch (1 - ON, 0 - OFF) 169 * 170 * @param[in] charger switch onoff 171 * 172 * @return 0 : on success, negative number : if an error occurred with any step 173 */ 174 int aos_charger_switch_set(int enable); 175 176 /** 177 * Register charger state notify 178 * 179 * @param[in] charger state notify callback (state: 0 - disconnect, 1 - connect) 180 * 181 * @return 0 : on success, negative number : if an error occurred with any step 182 */ 183 int aos_charger_state_notify_register(void (*cb)(int state)); 184 185 #endif /* AOS_PM_H */ 186 187