comparison src/cs/drivers/drv_app/pwr/pwr_messages.c @ 145:246f4a7dd92b

src/cs/drivers/drv_app/pwr: import from MV100 source
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 09 Oct 2016 05:59:14 +0000
parents
children c93a236e0d50
comparison
equal deleted inserted replaced
144:fd8227e3047d 145:246f4a7dd92b
1 /*******************************************************************************
2 *
3 * pwr_messages.c
4 *
5 * Purpose: Contains functions used by PWR to send events
6 * to the upper layer (MMI)
7 *
8 * Author Candice Bazanegue (c-brille@ti.com)
9 *
10 * (C) Texas Instruments 2001
11 *
12 ******************************************************************************/
13
14 #include "rv_defined_swe.h" // for RVM_PWR_SWE
15
16 #ifdef RVM_PWR_SWE
17
18 #include "rvm_use_id_list.h"
19 #include "rvf_api.h"
20 #include "pwr_messages.h"
21 #include "rv_general.h"
22 #include "spi_env.h"
23
24
25
26 /*******************************************************************************
27 **
28 ** Function pwr_send_charger_plug_event
29 **
30 ** Description This function is used to send a 'POWER_CHARGER_PLUG_IND'
31 ** event to the upper layer.
32 **
33 *******************************************************************************/
34 T_RV_RET pwr_send_charger_plug_event(void)
35 {
36 T_RV_HDR *msg_p;
37
38 if (pwr_env_ctrl_blk->power_info.info_enable == TRUE)
39 {
40 if (rvf_get_buf (pwr_env_ctrl_blk->prim_id, sizeof (T_RV_HDR),(void **) &msg_p) == RVF_RED)
41 {
42 rvf_send_trace ("PWR ERROR: Not enough memory",
43 28,
44 NULL_PARAM,
45 RV_TRACE_LEVEL_ERROR,
46 PWR_USE_ID);
47
48 return (RV_MEMORY_ERR);
49 }
50
51 msg_p->msg_id = POWER_CHARGER_PLUG_IND;
52 msg_p->callback_func = NULL;
53
54 PWR_SEND_MESSAGE(pwr_env_ctrl_blk->power_info.return_path, msg_p);
55
56 }
57
58 return (RV_OK);
59 }
60
61
62 /*******************************************************************************
63 **
64 ** Function pwr_send_charger_unplug_event
65 **
66 ** Description This function is used to send a 'POWER_CHARGER_UNPLUG_IND'
67 ** event to the upper layer.
68 **
69 **
70 *******************************************************************************/
71 T_RV_RET pwr_send_charger_unplug_event(void)
72 {
73 T_RV_HDR *msg_p;
74
75 if (pwr_env_ctrl_blk->power_info.info_enable == TRUE)
76 {
77 if (rvf_get_buf (pwr_env_ctrl_blk->prim_id, sizeof (T_RV_HDR),(void **) &msg_p) == RVF_RED)
78 {
79 rvf_send_trace ("PWR ERROR: Not enough memory",
80 28,
81 NULL_PARAM,
82 RV_TRACE_LEVEL_ERROR,
83 PWR_USE_ID);
84
85 return (RV_MEMORY_ERR);
86 }
87
88 msg_p->msg_id = POWER_CHARGER_UNPLUG_IND;
89 msg_p->callback_func = NULL;
90
91 PWR_SEND_MESSAGE(pwr_env_ctrl_blk->power_info.return_path, msg_p);
92
93 }
94
95 return (RV_OK);
96 }
97
98
99 /*******************************************************************************
100 **
101 ** Function pwr_send_CI_charge_start_event
102 **
103 ** Description This function is used to send a 'POWER_BAT_CI_CHARGE_START_IND'
104 ** event to the upper layer.
105 **
106 **
107 *******************************************************************************/
108 T_RV_RET pwr_send_CI_charge_start_event(void)
109 {
110 T_RV_HDR *msg_p;
111
112 if (pwr_env_ctrl_blk->power_info.info_enable == TRUE)
113 {
114 if (rvf_get_buf (pwr_env_ctrl_blk->prim_id, sizeof (T_RV_HDR),(void **) &msg_p) == RVF_RED)
115 {
116 rvf_send_trace ("PWR ERROR: Not enough memory",
117 28,
118 NULL_PARAM,
119 RV_TRACE_LEVEL_ERROR,
120 PWR_USE_ID);
121
122 return (RV_MEMORY_ERR);
123 }
124
125 msg_p->msg_id = POWER_BAT_CI_CHARGE_START_IND;
126 msg_p->callback_func = NULL;
127
128 PWR_SEND_MESSAGE(pwr_env_ctrl_blk->power_info.return_path, msg_p);
129
130 }
131
132 return (RV_OK);
133 }
134
135
136 /*******************************************************************************
137 **
138 ** Function pwr_send_CV_charge_start_event
139 **
140 ** Description This function is used to send a 'POWER_BAT_CV_CHARGE_START_IND'
141 ** event to the upper layer.
142 **
143 **
144 *******************************************************************************/
145 T_RV_RET pwr_send_CV_charge_start_event(void)
146 {
147 T_RV_HDR *msg_p;
148
149 if (pwr_env_ctrl_blk->power_info.info_enable == TRUE)
150 {
151 if (rvf_get_buf (pwr_env_ctrl_blk->prim_id, sizeof (T_RV_HDR),(void **) &msg_p) == RVF_RED)
152 {
153 rvf_send_trace ("PWR ERROR: Not enough memory",
154 28,
155 NULL_PARAM,
156 RV_TRACE_LEVEL_ERROR,
157 PWR_USE_ID);
158
159 return (RV_MEMORY_ERR);
160 }
161
162 msg_p->msg_id = POWER_BAT_CV_CHARGE_START_IND;
163 msg_p->callback_func = NULL;
164
165 PWR_SEND_MESSAGE(pwr_env_ctrl_blk->power_info.return_path, msg_p);
166
167 }
168
169 return (RV_OK);
170 }
171
172
173 /*******************************************************************************
174 **
175 ** Function pwr_send_charge_stop_event
176 **
177 ** Description This function is used to send a 'POWER_BAT_CHARGE_STOP_IND'
178 ** event to the upper layer.
179 **
180 **
181 *******************************************************************************/
182 T_RV_RET pwr_send_charge_stop_event(void)
183 {
184 T_RV_HDR *msg_p;
185
186 if (pwr_env_ctrl_blk->power_info.info_enable == TRUE)
187 {
188 if (rvf_get_buf (pwr_env_ctrl_blk->prim_id, sizeof (T_RV_HDR),(void **) &msg_p) == RVF_RED)
189 {
190 rvf_send_trace ("PWR ERROR: Not enough memory",
191 28,
192 NULL_PARAM,
193 RV_TRACE_LEVEL_ERROR,
194 PWR_USE_ID);
195
196 return (RV_MEMORY_ERR);
197 }
198
199 msg_p->msg_id = POWER_BAT_CHARGE_STOP_IND;
200 msg_p->callback_func = NULL;
201
202 PWR_SEND_MESSAGE(pwr_env_ctrl_blk->power_info.return_path, msg_p);
203
204 }
205
206 return (RV_OK);
207 }
208
209
210 /*******************************************************************************
211 **
212 ** Function pwr_send_charge_not_possible_event
213 **
214 ** Description This function is used to send a 'POWER_BAT_CHARGE_NOT_POSSIBLE_IND'
215 ** event to the upper layer.
216 **
217 **
218 *******************************************************************************/
219 T_RV_RET pwr_send_charge_not_possible_event(T_BAT_PROBLEM charge_problem)
220 {
221 T_PWR_BAT_CHARGE_NOT_POSSIBLE *msg_p;
222
223 if (pwr_env_ctrl_blk->power_info.info_enable == TRUE)
224 {
225 if (rvf_get_buf (pwr_env_ctrl_blk->prim_id, sizeof (T_PWR_BAT_CHARGE_NOT_POSSIBLE),(void **) &msg_p) == RVF_RED)
226 {
227 rvf_send_trace ("PWR ERROR: Not enough memory",
228 28,
229 NULL_PARAM,
230 RV_TRACE_LEVEL_ERROR,
231 PWR_USE_ID);
232
233 return (RV_MEMORY_ERR);
234 }
235
236 (msg_p->hdr).msg_id= POWER_BAT_CHARGE_NOT_POSSIBLE_IND;
237 (msg_p->hdr).callback_func= NULL;
238 msg_p->problem= charge_problem;
239
240 PWR_SEND_MESSAGE(pwr_env_ctrl_blk->power_info.return_path, msg_p);
241
242 }
243
244 return (RV_OK);
245 }
246
247
248 /*******************************************************************************
249 **
250 ** Function pwr_send_bat_discharge_event
251 **
252 ** Description This function is used to send a 'POWER_BAT_DISCHARGE_LEVEL_IND'
253 ** event to the upper layer.
254 **
255 **
256 *******************************************************************************/
257 T_RV_RET pwr_send_bat_discharge_event(T_PWR_PERCENT remaining_capacity)
258 {
259 T_PWR_BAT_DISCHARGE_LEVEL *msg_p;
260
261 if (pwr_env_ctrl_blk->power_info.info_enable == TRUE)
262 {
263 if (rvf_get_buf (pwr_env_ctrl_blk->prim_id, sizeof (T_PWR_BAT_DISCHARGE_LEVEL),(void **) &msg_p) == RVF_RED)
264 {
265 rvf_send_trace ("PWR ERROR: Not enough memory",
266 28,
267 NULL_PARAM,
268 RV_TRACE_LEVEL_ERROR,
269 PWR_USE_ID);
270
271 return (RV_MEMORY_ERR);
272 }
273
274 (msg_p->hdr).msg_id= POWER_BAT_DISCHARGE_LEVEL_IND;
275 (msg_p->hdr).callback_func= NULL;
276 msg_p->remaining_capacity= remaining_capacity;
277
278 PWR_SEND_MESSAGE(pwr_env_ctrl_blk->power_info.return_path, msg_p);
279
280 }
281
282 return (RV_OK);
283 }
284
285
286 /*******************************************************************************
287 **
288 ** Function pwr_send_low_bat_event
289 **
290 ** Description This function is used to send a 'POWER_LOW_BAT_ALERT_IND'
291 ** event to the upper layer.
292 **
293 **
294 *******************************************************************************/
295 T_RV_RET pwr_send_low_bat_event(T_PWR_PERCENT remaining_capacity)
296 {
297 T_PWR_LOW_BAT_ALERT *msg_p;
298
299 if (rvf_get_buf (pwr_env_ctrl_blk->prim_id, sizeof (T_PWR_LOW_BAT_ALERT),(void **) &msg_p) == RVF_RED)
300 {
301 rvf_send_trace ("PWR ERROR: Not enough memory",
302 28,
303 NULL_PARAM,
304 RV_TRACE_LEVEL_ERROR,
305 PWR_USE_ID);
306
307 return (RV_MEMORY_ERR);
308 }
309
310 (msg_p->hdr).msg_id= POWER_LOW_BAT_ALERT_IND;
311 (msg_p->hdr).callback_func = NULL;
312 msg_p->remaining_capacity= remaining_capacity;
313
314 PWR_SEND_MESSAGE(pwr_env_ctrl_blk->power_alert.return_path, msg_p);
315
316 return (RV_OK);
317 }
318
319
320 /*******************************************************************************
321 **
322 ** Function pwr_send_battery_info
323 **
324 ** Description This function is used to send a 'POWER_BAT_INFO_STATUS'
325 ** event to the upper layer.
326 **
327 **
328 *******************************************************************************/
329 T_RV_RET pwr_send_battery_info(UINT16 battery_voltage, UINT16 battery_temperature,
330 UINT16 battery_charger_current,
331 BOOLEAN is_charger_plugged,
332 T_PWR_CHARGING_STATE is_charge_started,
333 T_PWR_PERCENT remaining_capacity)
334 {
335 T_PWR_BAT_INFO_STATUS *msg_p;
336
337 if (rvf_get_buf (pwr_env_ctrl_blk->prim_id, sizeof (T_PWR_BAT_INFO_STATUS),(void **) &msg_p) == RVF_RED)
338 {
339 rvf_send_trace ("PWR ERROR: Not enough memory",
340 28,
341 NULL_PARAM,
342 RV_TRACE_LEVEL_ERROR,
343 PWR_USE_ID);
344
345 return (RV_MEMORY_ERR);
346 }
347
348 (msg_p->hdr).msg_id= POWER_BAT_INFO_STATUS;
349 (msg_p->hdr).callback_func= NULL;
350 msg_p->bat_info.battery_voltage= battery_voltage;
351 msg_p->bat_info.battery_temperature= battery_temperature;
352 msg_p->bat_info.battery_charger_current= battery_charger_current;
353 msg_p->bat_info.charger_plugged= is_charger_plugged;
354 msg_p->bat_info.charge_started= is_charge_started;
355 msg_p->bat_info.remaining_capacity= remaining_capacity;
356
357
358
359 PWR_SEND_MESSAGE(pwr_env_ctrl_blk->power_info.return_path, msg_p);
360
361 return (RV_OK);
362 }
363
364 #endif /* #ifdef RVM_PWR_SWE */