2 /*
3 Copyright (c) 2016, Texas Instruments Incorporated - http://www.ti.com/
4 All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
36 #ifndef _ASP_MSG_MASTER_H_
37 #define _ASP_MSG_MASTER_H_
39 #include <xdc/std.h>
40 #include <ti/sysbios/heaps/HeapBuf.h>
41 #include <ti/ipc/MessageQ.h>
43 #define ASP_MSG_MASTER_SOK ( 0 )
44 #define ASP_MSG_MASTER_HEAPBUF_CREATE_FAIL ( -1 )
45 #define ASP_MSG_MASTER_MSGQ_REGHEAP_FAIL ( -2 )
46 #define ASP_MSG_MASTER_MASTER_MSGQ_CREATE_FAIL ( -3 )
47 #define ASP_MSG_MASTER_SLAVE_MSGQ_OPEN_FAIL ( -4 )
49 #define ASP_MSG_MASTER_DEF_NUMMSGS ( 4 )
51 /* Error messages for function AspMsgSend */
52 #define ASP_MSG_NO_ERR ( 0 )
53 #define ASP_MSG_ERR_QUEUE_ALLOC ( -1 )
54 #define ASP_MSG_ERR_QUEUE_PUT ( -2 )
55 #define ASP_MSG_ERR_QUEUE_GET ( -3 )
56 #define ASP_MSG_ERR_QUEUE_FREE ( -4 )
57 #define ASP_MSG_ERR_ACKNOWLEDGE ( -5 )
59 /* module structure */
60 typedef struct AspMsgMaster_Module
61 {
62 UInt16 masterProcId; // master processor id
63 UInt16 slaveProcId; // slave processor id
64 MessageQ_Handle masterQue; // created locally
65 MessageQ_QueueId slaveQue; // opened remotely
66 UInt16 heapId; // MessageQ heapId
67 HeapBuf_Handle heap; // message heap
68 Int msgSize; // aligned size of message
69 Int poolSize; // size of message pool
70 Ptr store; // memory store for message pool
71 UInt32 messageId; // MS bit: reply bit, LS 31 bits: message id
72 } AspMsgMaster_Module;
74 /* module handle */
75 typedef AspMsgMaster_Module * AspMsgMaster_Handle;
77 /* Initialize ASP master messaging */
78 Int AspMsgMaster_init(
79 AspMsgMaster_Handle hAspMsgMaster,
80 UInt16 remoteProcId,
81 UInt16 numMsgs
82 );
84 extern AspMsgMaster_Handle hAspMsgMaster;
86 /* ASP message sending function
87 * Description: This function can be used to send message from the master processor
88 * to slave processor. It uses the global handle hAspMsgMaster for
89 * message passing.
90 */
91 Int // returned error message
92 AspMsgSend(
93 UInt32 sndCmd, // command that is sent from master to slave
94 UInt32 ackCmd, // acknowledgement that comes back from slave to master
95 char *sndMsgBuf, // message buffer for message sent to slave
96 char *ackMsgBuf); // message buffer for acknowledgement from slave
98 #endif /* _ASP_MSG_MASTER_H_ */