Developer World
Spresense SDK Library v3.2.0-ebc0364
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 --------------------------------------------------------------------*/
76typedef struct
77{
78 unsigned int size : 8;
79 unsigned int code : 8;
80 unsigned int reserve : 16;
82#ifdef __cplusplus
84 unsigned int get_code(void)
85 {
86 return(code);
87 }
88#endif /* __cplusplus */
89
91
92/*--------------------------------------------------------------------------*/
98typedef 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
117 unsigned int get_self(void)
118 {
119 return self;
120 }
121#endif /* __cplusplus */
122
124
125/*--------------------------------------------------------------------------*/
126#ifdef __cplusplus
133typedef 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
174typedef bool (*sensor_power_callback_t)(bool);
175#endif /* CONFIG_SENSING_MANAGER_POWERCTRL */
176
177/*--------------------------------------------------------------------------*/
182typedef void (*api_response_callback_t)(unsigned int code,
183 unsigned int ercd,
184 unsigned int self_id);
185
186/*--------------------------------------------------------------------------*/
191typedef 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/*--------------------------------------------------------------------*/
220typedef struct
221{
223 unsigned int self;
225 unsigned int get_self(void)
226 {
227 return self;
228 }
230
231/*--------------------------------------------------------------------*/
236typedef 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/*--------------------------------------------------------------------*/
259typedef 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
279typedef 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
318
322#endif /* CONFIG_SENSING_MANAGER_POWERCTRL */
323
327
331
335
340
341/****************************************************************************
342 * Public Function Prototypes
343 ****************************************************************************/
344
345#ifdef __cplusplus
346extern "C" {
347#endif /* __cplusplus */
348/*--------------------------------------------------------------------
349 External Sensor Manager Interface
350 --------------------------------------------------------------------*/
356extern bool SS_ActivateSensorSubSystem(MsgQueId selfMId,
357 api_response_callback_t callback);
358
364
373
382
394
395#ifdef CONFIG_SENSING_MANAGER_POWERCTRL
403extern void SS_SendSensorClearPower(FAR sensor_command_power_t *packet);
404
405#endif /* CONFIG_SENSING_MANAGER_POWERCTRL */
406
414
422
423#ifdef __cplusplus
424
433
434} /* extern "C" */
435#endif /* __cplusplus */
436
441#endif /* __INCLUDE_SENSING_SENSOR_API_H */
442
Memory Handler API.
Memory Handler Class for "Memory Manager Lite". This is only wrapper class for convert project-specif...
Definition: MemManager.h:107
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...
void SS_SendSensorRelease(FAR sensor_command_release_t *packet)
Unresister the sensor client from Sensor Manager.
bool(* sensor_data_callback_t)(sensor_command_data_t &)
A function pointer for sensor data (without mem handle) callback.
Definition: sensor_api.h:158
SensorCommandCode
Sensor Command Code for each sensors.
Definition: sensor_api.h:309
void SS_SendSensorChangeSubscription(FAR sensor_command_change_subscription_t *packet)
Change subscriptions of sensor client.
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...
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
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_SendSensorDataMH(FAR sensor_command_data_mh_t *packet)
Sender function to Sensor Manager with MemHandle Send data is publish to own subscriber.
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
bool(* sensor_power_callback_t)(bool)
A function pointer for power control callback.
Definition: sensor_api.h:174
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_SendSensorResult(FAR sensor_command_result_t *packet)
Sender function to Sensor Manager without MemHandle. Send result data is publish to own subscriber.
bool SS_DeactivateSensorSubSystem()
Deativation function for sensor manager.
@ SensorCommandMum
Definition: sensor_api.h:338
@ SetPower
Definition: sensor_api.h:317
@ ResisterClient
Definition: sensor_api.h:310
@ SendData
Definition: sensor_api.h:326
@ ClearPower
Definition: sensor_api.h:321
@ ReleaseClient
Definition: sensor_api.h:311
@ ChangeSubscription
Definition: sensor_api.h:312
@ SendResult
Definition: sensor_api.h:334
@ SendDataMH
Definition: sensor_api.h:330
The command of change subscription of client.
Definition: sensor_api.h:237
bool add
Definition: sensor_api.h:241
sensor_command_header_t header
Definition: sensor_api.h:238
unsigned int subscriptions
Definition: sensor_api.h:240
unsigned int self
Definition: sensor_api.h:239
The command of send some sensor data with MemHandle to the sensor manager. This function only can cal...
Definition: sensor_api.h:134
sensor_command_header_t header
Definition: sensor_api.h:135
unsigned int time
Definition: sensor_api.h:137
unsigned int fs
Definition: sensor_api.h:138
unsigned int size
Definition: sensor_api.h:139
MemMgrLite::MemHandle mh
Definition: sensor_api.h:143
unsigned int self
Definition: sensor_api.h:136
The command of send some sensor data without MemHandle to the sensor manager.
Definition: sensor_api.h:99
uint32_t data
Definition: sensor_api.h:111
unsigned int get_self(void)
Definition: sensor_api.h:117
sensor_command_header_t header
Definition: sensor_api.h:100
unsigned int time
Definition: sensor_api.h:103
unsigned int fs
Definition: sensor_api.h:104
void * adr
Definition: sensor_api.h:112
bool is_ptr
Definition: sensor_api.h:107
unsigned int size
Definition: sensor_api.h:105
unsigned int self
Definition: sensor_api.h:102
Sensor Commnad Header. All sensor command has this header.
Definition: sensor_api.h:77
unsigned int reserve
Definition: sensor_api.h:80
unsigned int get_code(void)
Definition: sensor_api.h:84
unsigned int size
Definition: sensor_api.h:78
unsigned int code
Definition: sensor_api.h:79
The command of setting sleep mode to sensor.
Definition: sensor_api.h:280
sensor_command_header_t header
Definition: sensor_api.h:281
unsigned int subscriptions
Definition: sensor_api.h:284
unsigned int self
Definition: sensor_api.h:283
The command of resister a sensor.
Definition: sensor_api.h:192
sensor_power_callback_t callback_pw
Definition: sensor_api.h:201
sensor_command_header_t header
Definition: sensor_api.h:193
sensor_data_mh_callback_t callback_mh
Definition: sensor_api.h:198
unsigned int subscriptions
Definition: sensor_api.h:196
sensor_data_callback_t callback
Definition: sensor_api.h:197
unsigned int self
Definition: sensor_api.h:195
The command of release the sensor.
Definition: sensor_api.h:221
sensor_command_header_t header
Definition: sensor_api.h:222
unsigned int self
Definition: sensor_api.h:223
The command of release the sensor.
Definition: sensor_api.h:260
sensor_command_header_t header
Definition: sensor_api.h:261
unsigned int data
Definition: sensor_api.h:265
unsigned int time
Definition: sensor_api.h:264
unsigned int self
Definition: sensor_api.h:263