comparison src/cs/drivers/drv_app/kpd/kpd_power_api.c @ 0:92470e5d0b9e

src: partial import from FC Selenite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 15 May 2020 01:28:16 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:92470e5d0b9e
1 /**
2 * @file kpd_power_api.c
3 *
4 * Implementation of bridge function for PWR SWE interface.
5 *
6 * @author Laurent Sollier (l-sollier@ti.com)
7 * @version 0.1
8 */
9
10 /*
11 * History:
12 *
13 * Date Author Modification
14 * ----------------------------------------
15 * 11/02/2001 L Sollier Create
16 *
17 *
18 * (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved
19 */
20
21 #include "kpd/kpd_power_api.h"
22 #include "kpd/kpd_messages_i.h"
23 #include "kpd/kpd_physical_key_def.h"
24 #include "kpd/kpd_env.h"
25
26 #include "rvm/rvm_use_id_list.h"
27
28 /* External declaration */
29 extern T_KPD_ENV_CTRL_BLK* kpd_env_ctrl_blk;
30
31 /* This variable ius defined here but is used by the PWR SWE */
32 T_KPD_KEYPAD Kp = {0};
33
34
35 /**
36 * @name Functions implementation
37 *
38 */
39 /*@{*/
40
41
42 /**
43 * function: kpd_power_key_pressed
44 */
45 T_RV_RET kpd_power_key_pressed(void)
46 {
47 T_RV_RET ret = RV_OK;
48
49 T_RVF_MB_STATUS mb_status;
50 T_KPD_KEY_PRESSED_MSG* msg_key_pressed;
51
52 /* Check if initialization has been correctly done */
53 if ( (kpd_env_ctrl_blk == 0) || (kpd_env_ctrl_blk->swe_is_initialized == FALSE) )
54 {
55 KPD_SEND_TRACE("KPD: Initialization is not yet done or failed", RV_TRACE_LEVEL_ERROR);
56 return RV_INTERNAL_ERR;
57 }
58
59 /* Reserve memory for message */
60 mb_status = rvf_get_buf (kpd_env_ctrl_blk->prim_id, sizeof(T_KPD_KEY_PRESSED_MSG), (void **) &msg_key_pressed);
61
62 if (mb_status == RVF_GREEN) /* Memory allocation success */
63 {
64 /* Fill the message */
65 msg_key_pressed->hdr.msg_id = KPD_KEY_PRESSED_MSG;
66 msg_key_pressed->value = KPD_SHORT_PRESS_PWR_KEY;
67 msg_key_pressed->key_to_process = TRUE;
68
69 /* Send message to the keypad task */
70 rvf_send_msg(kpd_env_ctrl_blk->addr_id, msg_key_pressed);
71 }
72 else
73 {
74 KPD_SEND_TRACE("KPD: Memory allocation error", RV_TRACE_LEVEL_ERROR);
75 if (mb_status == RVF_YELLOW)
76 rvf_free_buf(msg_key_pressed);
77 ret = RV_MEMORY_ERR;
78 }
79
80
81 return ret;
82 }
83
84
85 /*@}*/