annotate src/cs/services/vibr/vibr_api.c @ 294:e17bdedfbf2b

VIBR SWE initial implementation
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 27 Mar 2022 08:46:10 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
294
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * The implementation of our external API functions lives here.
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include "vibr/vibr_api.h"
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include "vibr/vibr_env.h"
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include "vibr/vibr_messages_i.h"
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include "rv/rv_general.h"
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include "rvf/rvf_api.h"
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include "rvm/rvm_use_id_list.h"
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 T_RV_RET vibr_pulse_train_start(UINT8 num_pulses, UINT8 vibr_level)
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 {
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 struct vibr_start_msg *msg;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 if (!vibr_env)
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 return RV_NOT_READY;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 if (rvf_get_buf(vibr_env->prim_id, sizeof(struct vibr_start_msg),
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 (T_RVF_BUFFER **)&msg) == RVF_RED) {
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 rvf_send_trace(
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 "rvf_get_buf() failed in vibr_pulse_train_start()", 48,
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 NULL_PARAM, RV_TRACE_LEVEL_ERROR, VIBR_USE_ID);
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 return RV_MEMORY_ERR;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 }
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 msg->hdr.msg_id = VIBR_START_REQ;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 msg->hdr.src_addr_id = vibr_env->addr_id;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 msg->hdr.dest_addr_id = vibr_env->addr_id;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 msg->hdr.callback_func = NULL;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 msg->num_pulses = num_pulses;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 msg->vibr_level = vibr_level;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 if (rvf_send_msg(vibr_env->addr_id, msg) != RV_OK) {
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 rvf_send_trace("vibr_pulse_train_start(): Send failed!", 38,
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 NULL_PARAM, RV_TRACE_LEVEL_ERROR, VIBR_USE_ID);
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 rvf_free_buf(msg);
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 return RV_INTERNAL_ERR;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 }
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 return RV_OK;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 }
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 T_RV_RET vibr_pulse_train_stop(void)
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 {
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 struct vibr_stop_msg *msg;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 if (!vibr_env)
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 return RV_NOT_READY;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 if (rvf_get_buf(vibr_env->prim_id, sizeof(struct vibr_stop_msg),
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 (T_RVF_BUFFER **)&msg) == RVF_RED) {
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 rvf_send_trace(
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 "rvf_get_buf() failed in vibr_pulse_train_stop()", 47,
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 NULL_PARAM, RV_TRACE_LEVEL_ERROR, VIBR_USE_ID);
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 return RV_MEMORY_ERR;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 }
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 msg->hdr.msg_id = VIBR_STOP_REQ;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 msg->hdr.src_addr_id = vibr_env->addr_id;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 msg->hdr.dest_addr_id = vibr_env->addr_id;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 msg->hdr.callback_func = NULL;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 if (rvf_send_msg(vibr_env->addr_id, msg) != RV_OK) {
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 rvf_send_trace("vibr_pulse_train_stop(): Send failed!", 37,
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 NULL_PARAM, RV_TRACE_LEVEL_ERROR, VIBR_USE_ID);
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 rvf_free_buf(msg);
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 return RV_INTERNAL_ERR;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 }
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 return RV_OK;
e17bdedfbf2b VIBR SWE initial implementation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 }