Developer World
Spresense SDK Library v2.3.1-e7b66ec
sensor_api.h
1 /****************************************************************************
2  * modules/include/sensing/sensor_api.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 __INCLUDE_SENSING_SENSOR_API_H
37 #define __INCLUDE_SENSING_SENSOR_API_H
38 
44 /****************************************************************************
45  * Included Files
46  ****************************************************************************/
47 
48 #include <sdk/config.h>
49 
50 #ifdef __cplusplus
51 /* MemoryManager can used only C++.
52  * If you use Memory Manager Library
53  * to be selected from kconfig
54  */
56 #endif
57 #include "memutils/message/MsgPacket.h"
58 
59 /****************************************************************************
60  * Public Types
61  ****************************************************************************/
62 
63 /*--------------------------------------------------------------------
64  * Command Structure
65  *
66  * This is Sensor Control Command for Sensor Manager
67  *
68  * the Sensor Manager is controlled from commands.
69  * follow is these commands.
70  --------------------------------------------------------------------*/
76 typedef struct
77 {
78  unsigned int size : 8;
79  unsigned int code : 8;
80  unsigned int reserve : 16;
82 #ifdef __cplusplus
83 
84  unsigned int get_code(void)
85  {
86  return(code);
87  }
88 #endif /* __cplusplus */
89 
91 
92 /*--------------------------------------------------------------------------*/
98 typedef struct
99 {
102  unsigned int self : 8;
103  unsigned int time : 24;
104  unsigned int fs : 16;
105  unsigned int size : 16;
107  bool is_ptr;
109  union
110  {
111  uint32_t data;
112  void* adr;
113  };
114 
115 #ifdef __cplusplus
116 
117  unsigned int get_self(void)
118  {
119  return self;
120  }
121 #endif /* __cplusplus */
122 
124 
125 /*--------------------------------------------------------------------------*/
126 #ifdef __cplusplus
127 
133 typedef struct
134 {
136  unsigned int self : 8;
137  unsigned int time : 24;
138  unsigned int fs : 16;
139  unsigned int size : 16;
141 /* If you use Memory Manager Library to be selected from kconfig */
142 
145  unsigned int get_self(void)
146  {
147  return self;
148  }
150 
151 #endif /* __cplusplus */
152 
153 /*--------------------------------------------------------------------------*/
159 
160 /*--------------------------------------------------------------------------*/
166 
167 
168 /*--------------------------------------------------------------------------*/
169 #ifdef CONFIG_SENSING_MANAGER_POWERCTRL
170 
174 typedef bool (*sensor_power_callback_t)(bool);
175 #endif /* CONFIG_SENSING_MANAGER_POWERCTRL */
176 
177 /*--------------------------------------------------------------------------*/
182 typedef void (*api_response_callback_t)(unsigned int code,
183  unsigned int ercd,
184  unsigned int self_id);
185 
186 /*--------------------------------------------------------------------------*/
191 typedef struct
192 {
195  unsigned int self: 8;
196  unsigned int subscriptions: 24;
200 #ifdef CONFIG_SENSING_MANAGER_POWERCTRL
202 #endif /* CONFIG_SENSING_MANAGER_POWERCTRL */
203 
204  unsigned int get_self(void)
205  {
206  return self;
207  }
208 
209  unsigned int get_subscriptions(void)
210  {
211  return subscriptions;
212  }
214 
215 /*--------------------------------------------------------------------*/
220 typedef struct
221 {
223  unsigned int self;
225  unsigned int get_self(void)
226  {
227  return self;
228  }
230 
231 /*--------------------------------------------------------------------*/
236 typedef struct
237 {
239  unsigned int self : 8;
240  unsigned int subscriptions : 24;
241  bool add;
243  unsigned int get_self(void)
244  {
245  return self;
246  }
247 
248  unsigned int get_subscriptions(void)
249  {
250  return subscriptions;
251  }
253 
254 /*--------------------------------------------------------------------*/
259 typedef struct
260 {
263  unsigned int self : 8;
264  unsigned int time : 24;
265  unsigned int data;
267  unsigned int get_self(void)
268  {
269  return self;
270  }
272 
273 /*--------------------------------------------------------------------------*/
274 #ifdef CONFIG_SENSING_MANAGER_POWERCTRL
275 
279 typedef struct
280 {
283  unsigned int self: 8;
284  unsigned int subscriptions: 24;
286  unsigned int get_self(void)
287  {
288  return self;
289  }
290 
291  unsigned int get_subscriptions(void)
292  {
293  return subscriptions;
294  }
295 
297 
298 #endif /* CONFIG_SENSING_MANAGER_POWERCTRL */
299 
300 /*--------------------------------------------------------------------------*/
301 /*--------------------------------------------------------------------
302  Command(Evant) Code.
303  --------------------------------------------------------------------*/
309 {
314 #ifdef CONFIG_SENSING_MANAGER_POWERCTRL
315 
318 
322 #endif /* CONFIG_SENSING_MANAGER_POWERCTRL */
323 
327 
331 
335 
339 };
340 
341 /****************************************************************************
342  * Public Function Prototypes
343  ****************************************************************************/
344 
345 #ifdef __cplusplus
346 extern "C" {
347 #endif /* __cplusplus */
348 /*--------------------------------------------------------------------
349  External Sensor Manager Interface
350  --------------------------------------------------------------------*/
356 extern bool SS_ActivateSensorSubSystem(MsgQueId selfMId,
357  api_response_callback_t callback);
358 
363 extern bool SS_DeactivateSensorSubSystem();
364 
372 extern void SS_SendSensorData(FAR sensor_command_data_t *packet);
373 
381 extern void SS_SendSensorResult(FAR sensor_command_result_t *packet);
382 
393 extern void SS_SendSensorResister(FAR sensor_command_register_t *packet);
394 
395 #ifdef CONFIG_SENSING_MANAGER_POWERCTRL
396 
402 extern void SS_SendSensorSetPower(FAR sensor_command_power_t *packet);
403 extern void SS_SendSensorClearPower(FAR sensor_command_power_t *packet);
404 
405 #endif /* CONFIG_SENSING_MANAGER_POWERCTRL */
406 
413 extern void SS_SendSensorRelease(FAR sensor_command_release_t *packet);
414 
422 
423 #ifdef __cplusplus
424 
432 extern void SS_SendSensorDataMH(FAR sensor_command_data_mh_t *packet);
433 
434 } /* extern "C" */
435 #endif /* __cplusplus */
436 
441 #endif /* __INCLUDE_SENSING_SENSOR_API_H */
442 
sensor_command_header_t header
Definition: sensor_api.h:281
SensorCommandCode
Sensor Command Code for each sensors.
Definition: sensor_api.h:308
unsigned int size
Definition: sensor_api.h:139
Sensor Commnad Header. All sensor command has this header.
Definition: sensor_api.h:76
unsigned int time
Definition: sensor_api.h:137
Definition: sensor_api.h:312
unsigned int code
Definition: sensor_api.h:79
sensor_command_header_t header
Definition: sensor_api.h:222
bool add
Definition: sensor_api.h:241
unsigned int self
Definition: sensor_api.h:239
The command of change subscription of client.
Definition: sensor_api.h:236
sensor_data_mh_callback_t callback_mh
Definition: sensor_api.h:198
unsigned int self
Definition: sensor_api.h:136
The command of resister a sensor.
Definition: sensor_api.h:191
MemMgrLite::MemHandle mh
Definition: sensor_api.h:143
void SS_SendSensorDataMH(FAR sensor_command_data_mh_t *packet)
Sender function to Sensor Manager with MemHandle Send data is publish to own subscriber.
unsigned int fs
Definition: sensor_api.h:138
bool(* sensor_power_callback_t)(bool)
A function pointer for power control callback.
Definition: sensor_api.h:174
sensor_command_header_t header
Definition: sensor_api.h:261
sensor_data_callback_t callback
Definition: sensor_api.h:197
The command of setting sleep mode to sensor.
Definition: sensor_api.h:279
Memory Handler API.
The command of send some sensor data with MemHandle to the sensor manager. This function only can cal...
Definition: sensor_api.h:133
The command of release the sensor.
Definition: sensor_api.h:259
unsigned int time
Definition: sensor_api.h:103
unsigned int self
Definition: sensor_api.h:102
unsigned int data
Definition: sensor_api.h:265
The command of send some sensor data without MemHandle to the sensor manager.
Definition: sensor_api.h:98
unsigned int reserve
Definition: sensor_api.h:80
Definition: sensor_api.h:330
void SS_SendSensorData(FAR sensor_command_data_t *packet)
Sender function to Sensor Manager without MemHandle. Send data is publish to own subscriber.
void SS_SendSensorChangeSubscription(FAR sensor_command_change_subscription_t *packet)
Change subscriptions of sensor client.
bool SS_ActivateSensorSubSystem(MsgQueId selfMId, api_response_callback_t callback)
Activation function for sensor manager. Before using a sensor manager, it is necessary to call this A...
void SS_SendSensorSetPower(FAR sensor_command_power_t *packet)
When sensor power mode are controlled, this function can set. (If you enable CONFIG_SENSING_MANAGER_P...
Definition: sensor_api.h:338
sensor_command_header_t header
Definition: sensor_api.h:193
void(* api_response_callback_t)(unsigned int code, unsigned int ercd, unsigned int self_id)
A function pointer for API response callback.
Definition: sensor_api.h:182
Memory Handler Class for "Memory Manager Lite". This is only wrapper class for convert project-specif...
Definition: MemManager.h:107
bool SS_DeactivateSensorSubSystem()
Deativation function for sensor manager.
Definition: sensor_api.h:321
Definition: sensor_api.h:334
void * adr
Definition: sensor_api.h:112
Definition: sensor_api.h:317
unsigned int size
Definition: sensor_api.h:78
unsigned int subscriptions
Definition: sensor_api.h:240
Definition: sensor_api.h:311
bool(* sensor_data_callback_t)(sensor_command_data_t &)
A function pointer for sensor data (without mem handle) callback.
Definition: sensor_api.h:158
unsigned int fs
Definition: sensor_api.h:104
void SS_SendSensorResult(FAR sensor_command_result_t *packet)
Sender function to Sensor Manager without MemHandle. Send result data is publish to own subscriber...
bool is_ptr
Definition: sensor_api.h:107
unsigned int get_self(void)
Definition: sensor_api.h:117
uint32_t data
Definition: sensor_api.h:111
unsigned int self
Definition: sensor_api.h:263
unsigned int get_code(void)
Definition: sensor_api.h:84
Definition: sensor_api.h:326
unsigned int time
Definition: sensor_api.h:264
sensor_command_header_t header
Definition: sensor_api.h:100
void SS_SendSensorResister(FAR sensor_command_register_t *packet)
Resister a sensor client to Sensor Manager as subscriber. Registed sensor can recieve a "publish data...
unsigned int subscriptions
Definition: sensor_api.h:284
The command of release the sensor.
Definition: sensor_api.h:220
unsigned int subscriptions
Definition: sensor_api.h:196
sensor_power_callback_t callback_pw
Definition: sensor_api.h:201
unsigned int size
Definition: sensor_api.h:105
Definition: sensor_api.h:310
void SS_SendSensorRelease(FAR sensor_command_release_t *packet)
Unresister the sensor client from Sensor Manager.
sensor_command_header_t header
Definition: sensor_api.h:238
sensor_command_header_t header
Definition: sensor_api.h:135
bool(* sensor_data_mh_callback_t)(sensor_command_data_mh_t &)
A function pointer for sensor data with MemHandle callback.
Definition: sensor_api.h:165