Developer World
Spresense SDK Library
v3.2.0-ebc0364
message_type.h
1
/****************************************************************************
2
* modules/include/memutils/message/message_type.h
3
*
4
* Copyright 2018 Sony Semiconductor Solutions Corporation
5
*
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
* 1. Redistributions of source code must retain the above copyright
11
* notice, this list of conditions and the following disclaimer.
12
* 2. Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in
14
* the documentation and/or other materials provided with the
15
* distribution.
16
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
17
* the names of its contributors may be used to endorse or promote
18
* products derived from this software without specific prior written
19
* permission.
20
*
21
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
* POSSIBILITY OF SUCH DAMAGE.
33
*
34
****************************************************************************/
35
36
#ifndef __APPS_MEMUTILS_MESSAGE_INCLUDE_MESSAGE_TYPE_H
37
#define __APPS_MEMUTILS_MESSAGE_INCLUDE_MESSAGE_TYPE_H
38
39
/***********************************************************************
40
*
41
* [type]
42
*
43
* D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
44
* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
45
* |REQ| MSG_USER | MSG_CATEGORY | MSG_SUB_TYPE | MSG_PARAM |
46
* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
47
*
48
* D15: MSG_TYPE_REQUEST
49
* 0: response
50
* 1: request
51
* +-----------+ request message +---------+
52
* | message |----------------->| message |
53
* | initiator |<-----------------| target |
54
* +-----------+ response message +---------+
55
*
56
* D14-D12: MSG_USER
57
* 0-5: (reserved)
58
* 6: Audio Sub System
59
* 7: Sensor Sub System
60
*
61
* D11-D8: MSG_CATEGORY
62
* 0-15: (reserved) defined by each user
63
*
64
* D7-D0: MSG_SUB_TYPE
65
* 0-32: (reserved) defined by each category
66
*
67
* D7-D0: MSG_PARAM
68
* 0-7: (reserved) defined by each sub type
69
*
70
***********************************************************************
71
*/
72
typedef
unsigned
short
MSG_TYPE;
73
74
/************************************************************************
75
*
76
* request / response
77
*
78
************************************************************************
79
*/
80
#define MSG_TYPE_REQUEST_FIELD_SIZE (0x1)
81
#define MSG_TYPE_REQUEST_FIELD_OFFSET (15)
82
83
#define MSG_TYPE_RESPONSE (0x0 << MSG_TYPE_REQUEST_FIELD_OFFSET)
84
#define MSG_TYPE_REQUEST (0x1 << MSG_TYPE_REQUEST_FIELD_OFFSET)
85
86
/************************************************************************
87
*
88
* user
89
*
90
************************************************************************
91
*/
92
93
#define MSG_TYPE_USER_FIELD_SIZE (0x7)
94
#define MSG_TYPE_USER_FIELD_OFFSET (12)
95
96
#define MSG_TYPE_USER (MSG_TYPE_USER_FIELD_SIZE << MSG_TYPE_USER_FIELD_OFFSET)
97
98
#define MSG_TYPE_USER_AUDIO_UTIL (0x6 << MSG_TYPE_USER_FIELD_OFFSET)
99
#define MSG_TYPE_USER_SENSOR_UTIL (0x7 << MSG_TYPE_USER_FIELD_OFFSET)
100
101
/************************************************************************
102
*
103
* category
104
*
105
************************************************************************
106
*/
107
108
#define MSG_TYPE_CATEGORY_FIELD_SIZE (0xf)
109
#define MSG_TYPE_CATEGORY_FIELD_OFFSET (8)
110
111
#define MSG_TYPE_CATEGORY (MSG_TYPE_CATEGORY_FIELD_SIZE << MSG_TYPE_CATEGORY_FIELD_OFFSET)
112
113
/************************************************************************
114
*
115
* Sub type
116
*
117
************************************************************************
118
*/
119
120
#define MSG_TYPE_SUBTYPE_FIELD_SIZE (0x1f)
121
#define MSG_TYPE_SUBTYPE_FIELD_OFFSET (3)
122
123
#define MSG_TYPE_SUBTYPE (MSG_TYPE_SUBTYPE_FIELD_SIZE << MSG_TYPE_SUBTYPE_FIELD_OFFSET)
124
125
/************************************************************************
126
*
127
* Parame Type
128
*
129
************************************************************************
130
*/
131
132
#define MSG_TYPE_PARAM_FIELD_SIZE (0x7)
133
#define MSG_TYPE_PARAM_FIELD_OFFSET (0)
134
135
#define MSG_TYPE_PARAM (MSG_TYPE_PARAM_FIELD_SIZE << MSG_TYPE_PARAM_FIELD_OFFSET)
136
137
/************************************************************************
138
*
139
* MACRO
140
*
141
************************************************************************
142
*/
143
#define MSG_SET_CATEGORY(x) (((x) & MSG_TYPE_CATEGORY_FIELD_SIZE) << MSG_TYPE_CATEGORY_FIELD_OFFSET)
144
#define MSG_SET_SUBTYPE(x) (((x) & MSG_TYPE_SUBTYPE_FIELD_SIZE ) << MSG_TYPE_SUBTYPE_FIELD_OFFSET)
145
#define MSG_SET_PARAM(x) (((x) & MSG_TYPE_PARAM_FIELD_SIZE ) << MSG_TYPE_PARAM_FIELD_OFFSET)
146
147
#define MSG_GET_USER(x) (MSG_TYPE_USER & (MSG_TYPE)x)
148
#define MSG_GET_CATEGORY(x) (MSG_TYPE_CATEGORY & (MSG_TYPE)x)
149
#define MSG_GET_SUBTYPE(x) ((MSG_TYPE_SUBTYPE & (MSG_TYPE)x) >> MSG_TYPE_SUBTYPE_FIELD_OFFSET)
150
#define MSG_GET_PARAM(x) ((MSG_TYPE_PARAM & (MSG_TYPE)x) >> MSG_TYPE_PARAM_FIELD_OFFSET)
151
#define MSG_IS_REQUEST(x) (MSG_TYPE_REQUEST & (MSG_TYPE)x)
152
153
#endif
/* __APPS_MEMUTILS_MESSAGE_INCLUDE_MESSAGE_TYPE_H */
spresense
sdk
modules
include
memutils
message
message_type.h
Generated by
1.9.4