Developer World
Spresense SDK Library v3.3.0-375c679
compass.h
1/****************************************************************************
2 * modules/include/sensing/logical_sensor/compass.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_COMPASS_H
37#define __INCLUDE_SENSING_COMPASS_H
38
44/****************************************************************************
45 * Included Files
46 ****************************************************************************/
47
48#include <asmp/mpmq.h>
49#include <asmp/mptask.h>
50
51#include "sensing/sensor_api.h"
52#include "sensing/sensor_id.h"
53#include "sensing/sensor_ecode.h"
55#include "memutils/s_stl/queue.h"
57
58/****************************************************************************
59 * Public Types
60 ****************************************************************************/
61
67typedef struct
68{
74 int errcode;
78 float azimuth;
83 float pitch;
87 float roll;
91 float decl;
102
103/*--------------------------------------------------------------------
104 * Compass Class
105 * --------------------------------------------------------------------
106 */
107
109{
110public:
111
112 /* public methods */
113
114 int open(void);
115 int close(void);
116 int write(FAR sensor_command_data_mh_t*);
117 int result(void);
118 void set_callback(uint32_t);
119 int receive(void);
120
121
123 MemMgrLite::PoolId rst_pool_id)
124 : m_cmd_pool_id(cmd_pool_id)
125 , m_rst_pool_id(rst_pool_id)
126 {
127 };
128
129 ~CompassClass(){};
130
131private:
132
133 #define MAX_EXEC_COUNT 10
134 struct exe_mh_s
135 {
138 };
139 s_std::Queue<struct exe_mh_s, MAX_EXEC_COUNT> m_accel_exe_que;
140 s_std::Queue<struct exe_mh_s, MAX_EXEC_COUNT> m_mag_exe_que;
141
142 /* private members */
143
144 MemMgrLite::PoolId m_cmd_pool_id;
145 MemMgrLite::PoolId m_rst_pool_id;
146
147 mptask_t m_mptask;
148 mpmq_t m_mq;
149
150 pthread_t m_thread_id;
151
152 /* private methods */
153
154 int sendInit(void);
155 int sendFlush(void);
156};
157
158/*--------------------------------------------------------------------
159 * External Interface
160 *--------------------------------------------------------------------
161 */
162
170 MemMgrLite::PoolId rst_pool_id);
171
179
186
194 FAR sensor_command_data_mh_t *command);
195
200#endif /* __INCLUDE_SENSING_COMPASS_H */
201
Memory Handler API.
Definition: compass.h:109
Memory Handler Class for "Memory Manager Lite". This is only wrapper class for convert project-specif...
Definition: MemManager.h:107
int CompassClose(FAR CompassClass *ins)
Destory Compass worker task.
FAR CompassClass * CompassCreate(MemMgrLite::PoolId cmd_pool_id, MemMgrLite::PoolId rst_pool_id)
Create CompassClass instance.
int CompassOpen(FAR CompassClass *ins)
Load Compass library and boot up as worker task. After booted up, send initialize and wait complete.
int CompassWrite(FAR CompassClass *ins, FAR sensor_command_data_mh_t *command)
Send data to Compass worker task.
The structure of result on compass commands.
Definition: compass.h:68
int resultcmd
Definition: compass.h:69
float azimuth
Definition: compass.h:78
int errcode
Definition: compass.h:74
float roll
Definition: compass.h:87
float pitch
Definition: compass.h:83
int exec_result
Definition: compass.h:73
int acc_azimuth
Definition: compass.h:95
float decl
Definition: compass.h:91
int calib_lv
Definition: compass.h:98
Definition: MemMgrTypes.h:88
Definition: mpmq.h:77
Definition: mptask.h:248
The command of send some sensor data with MemHandle to the sensor manager. This function only can cal...
Definition: sensor_api.h:134