Developer World
Spresense SDK Library v3.2.0-ebc0364
step_counter.h
1/****************************************************************************
2 * modules/include/sensing/logical_sensor/step_counter.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_STEP_COUNTER_H
37#define __INCLUDE_SENSING_STEP_COUNTER_H
38
44/****************************************************************************
45 * Included Files
46 ****************************************************************************/
47
48#include <asmp/mpmq.h>
49#include <asmp/mptask.h>
50
52#include "sensing/sensor_api.h"
53#include "sensing/sensor_id.h"
54#include "sensing/sensor_ecode.h"
56#include "memutils/s_stl/queue.h"
57
58/****************************************************************************
59 * Pre-processor Definitions
60 ****************************************************************************/
61
66#define STEP_COUNTER_INITIAL_WALK_STEP_LENGTH 60
67#define STEP_COUNTER_INITIAL_RUN_STEP_LENGTH 80
69/****************************************************************************
70 * Public Types
71 ****************************************************************************/
72
74{
75public:
76
77 /* public methods */
78 int open(void);
79 int close(void);
80 int write(FAR sensor_command_data_mh_t *cmd);
81 void set_callback(void);
82 int receive(void);
83 int set(FAR StepCounterSetting *set_param);
84
86 : m_cmd_pool_id(cmd_pool_id)
87 {
88 };
89
91
92private:
93
94 #define MAX_EXEC_COUNT 8
95 struct exe_mh_s
96 {
99 };
100 s_std::Queue<struct exe_mh_s, MAX_EXEC_COUNT> m_exe_que;
101
102 /* private members */
103
104 MemMgrLite::PoolId m_cmd_pool_id;
105
106 mptask_t m_mptask;
107 mpmq_t m_mq;
108
109 pthread_t m_thread_id;
110
111 /* private methods */
112
113 int sendInit(void);
114};
115
116/****************************************************************************
117 * Public Function Prototypes
118 ****************************************************************************/
119
127
128StepCounterClass* StepCounterCreate(uint8_t cmd_pool_id);
129
137
144
152 FAR sensor_command_data_mh_t *command);
153
161 FAR StepCounterSetting *set);
162
167#endif /* __INCLUDE_SENSING_STEP_COUNTER_H */
168
Memory Handler API.
Memory Handler Class for "Memory Manager Lite". This is only wrapper class for convert project-specif...
Definition: MemManager.h:107
Definition: step_counter.h:74
int StepCounterWrite(FAR StepCounterClass *ins, FAR sensor_command_data_mh_t *command)
Send data to StepCounter worker task.
StepCounterClass * StepCounterCreate(MemMgrLite::PoolId cmd_pool_id)
Create StepCounterClass instance.
int StepCounterSet(FAR StepCounterClass *ins, FAR StepCounterSetting *set)
User step set function.
int StepCounterOpen(FAR StepCounterClass *ins)
Load StepCounter library and boot up as worker task. After booted up, send initialize and wait comple...
int StepCounterClose(FAR StepCounterClass *ins)
Destory StepCounter worker task.
Definition: MemMgrTypes.h:88
the structure of Accelstep user setting.
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