pedometer3 2.0.0.0
pedometer3.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
34#ifndef PEDOMETER3_H
35#define PEDOMETER3_H
36
41#ifdef PREINIT_SUPPORTED
42#include "preinit.h"
43#endif
44
45#ifdef MikroCCoreVersion
46 #if MikroCCoreVersion >= 1
47 #include "delays.h"
48 #endif
49#endif
50
51#include "drv_digital_in.h"
52#include "drv_i2c_master.h"
53#include "drv_spi_master.h"
54
55
56// -------------------------------------------------------------- PUBLIC MACROS
66#define PEDOMETER3_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
70 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
71 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
72 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
73 cfg.trg = MIKROBUS( mikrobus, MIKROBUS_AN ); \
74 cfg.it2 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
75 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
82#define PEDOMETER3_MASTER_I2C 0
83#define PEDOMETER3_MASTER_SPI 1
90#define PEDOMETER3_OK 0
91#define PEDOMETER3_ERROR -1
98#define PEDOMETER3_REG_MANUFACTURING_ID 0x00
99#define PEDOMETER3_REG_PART_ID 0x01
100#define PEDOMETER3_REG_X_AXIS_HIGH_PASS_LOW 0x02
101#define PEDOMETER3_REG_X_AXIS_HIGH_PASS_HIGH 0x03
102#define PEDOMETER3_REG_Y_AXIS_HIGH_PASS_LOW 0x04
103#define PEDOMETER3_REG_Y_AXIS_HIGH_PASS_HIGH 0x05
104#define PEDOMETER3_REG_Z_AXIS_HIGH_PASS_LOW 0x06
105#define PEDOMETER3_REG_Z_AXIS_HIGH_PASS_HIGH 0x07
106#define PEDOMETER3_REG_X_AXIS_OUTPUT_LOW 0x08
107#define PEDOMETER3_REG_X_AXIS_OUTPUT_HIGH 0x09
108#define PEDOMETER3_REG_Y_AXIS_OUTPUT_LOW 0x0A
109#define PEDOMETER3_REG_Y_AXIS_OUTPUT_HIGH 0x0B
110#define PEDOMETER3_REG_Z_AXIS_OUTPUT_LOW 0x0C
111#define PEDOMETER3_REG_Z_AXIS_OUTPUT_HIGH 0x0D
112#define PEDOMETER3_REG_PAD_STEP_LOW 0x0E
113#define PEDOMETER3_REG_PAD_STEP_HIGH 0x0F
114#define PEDOMETER3_REG_COMMAND_TEST_RESPONSE 0x10
115#define PEDOMETER3_REG_WHO_AM_I 0x11
116#define PEDOMETER3_REG_CURRENT_TILT_POSITION 0x12
117#define PEDOMETER3_REG_PREVIOUS_TILT_POSITION 0x13
118#define PEDOMETER3_REG_INS1 0x14
119#define PEDOMETER3_REG_INS2 0x15
120#define PEDOMETER3_REG_INS3 0x16
121#define PEDOMETER3_REG_STATUS 0x17
122#define PEDOMETER3_REG_INT_REL 0x19
123#define PEDOMETER3_REG_CONTROL_1 0x1A
124#define PEDOMETER3_REG_CONTROL_2 0x1B
125#define PEDOMETER3_REG_CONTROL_3 0x1C
126#define PEDOMETER3_REG_CONTROL_4 0x1D
127#define PEDOMETER3_REG_CONTROL_5 0x1E
128#define PEDOMETER3_REG_OUTPUT_DATA_CONTROL 0x1F
129#define PEDOMETER3_REG_INTERRUPT_CONTROL_1 0x20
130#define PEDOMETER3_REG_INTERRUPT_CONTROL_2 0x21
131#define PEDOMETER3_REG_INTERRUPT_CONTROL_3 0x22
132#define PEDOMETER3_REG_INTERRUPT_CONTROL_4 0x23
133#define PEDOMETER3_REG_INTERRUPT_CONTROL_5 0x24
134#define PEDOMETER3_REG_INTERRUPT_CONTROL_6 0x25
135#define PEDOMETER3_REG_INTERRUPT_CONTROL_7 0x26
136#define PEDOMETER3_REG_TILT_TIMER 0x27
137#define PEDOMETER3_REG_TAP_REPORT_CONTROL 0x28
138#define PEDOMETER3_REG_DOUBLE_TAP_EVENT 0x29
139#define PEDOMETER3_REG_TAP_THRESHOLD_HIGH 0x2A
140#define PEDOMETER3_REG_TAP_THRESHOLD_LOW 0x2B
141#define PEDOMETER3_REG_FTD 0x2C
142#define PEDOMETER3_REG_STD 0x2D
143#define PEDOMETER3_REG_TLT 0x2E
144#define PEDOMETER3_REG_TWS 0x2F
145#define PEDOMETER3_REG_FREE_FALL_THRESHOLD 0x30
146#define PEDOMETER3_REG_FREE_FALL_COUNTER 0x31
147#define PEDOMETER3_REG_FREE_FALL_CONTROL 0x32
148#define PEDOMETER3_REG_TILT_ANGLE_LL 0x34
149#define PEDOMETER3_REG_TILT_ANGLE_HL 0x35
150#define PEDOMETER3_REG_HYSTERESIS_SET 0x36
151#define PEDOMETER3_REG_LOW_POWER_CONTROL 0x37
152#define PEDOMETER3_REG_WUFTH 0x3C
153#define PEDOMETER3_REG_BTSWUFTH 0x3D
154#define PEDOMETER3_REG_BTSTH 0x3E
155#define PEDOMETER3_REG_BTS_MOTION_DETECTION 0x3F
156#define PEDOMETER3_REG_WUF_MOTION_DETECTION 0x40
157#define PEDOMETER3_REG_PED_STPWM_LOW 0x41
158#define PEDOMETER3_REG_PED_STPWM_HIGH 0x42
159#define PEDOMETER3_REG_PEDOMETER_CONTROL_1 0x43
160#define PEDOMETER3_REG_PEDOMETER_CONTROL_2 0x44
161#define PEDOMETER3_REG_PEDOMETER_CONTROL_3 0x45
162#define PEDOMETER3_REG_PEDOMETER_CONTROL_4 0x46
163#define PEDOMETER3_REG_PEDOMETER_CONTROL_5 0x47
164#define PEDOMETER3_REG_PEDOMETER_CONTROL_6 0x48
165#define PEDOMETER3_REG_PEDOMETER_CONTROL_7 0x49
166#define PEDOMETER3_REG_PEDOMETER_CONTROL_8 0x4A
167#define PEDOMETER3_REG_PEDOMETER_CONTROL_9 0x4B
168#define PEDOMETER3_REG_PEDOMETER_CONTROL_10 0x4C
169#define PEDOMETER3_REG_SELF_TEST 0x4D
170#define PEDOMETER3_REG_BUFFER_CONTROL_1 0x5A
171#define PEDOMETER3_REG_BUFFER_CONTROL_2 0x5B
172#define PEDOMETER3_REG_BUFFER_STATUS_1 0x5C
173#define PEDOMETER3_REG_BUFFER_STATUS_2 0x5D
174#define PEDOMETER3_REG_BUFFER_CLEAR 0x5E
175#define PEDOMETER3_REG_BUFFER_READ 0x5F
182#define PEDOMETER3_POSITON_BIT_LEFT_X_NEGATIVE 0x20
183#define PEDOMETER3_POSITON_BIT_RIGHT_X_POSITIVE 0x10
184#define PEDOMETER3_POSITON_BIT_DOWN_Y_NEGATIVE 0x08
185#define PEDOMETER3_POSITON_BIT_UP_Y_POSITIVE 0x04
186#define PEDOMETER3_POSITON_BIT_FACE_DOWN_Y_NEGATIVE 0x02
187#define PEDOMETER3_POSITON_BIT_FACE_UP_Y_POSITIVE 0x01
194#define PEDOMETER3_INS1_STPOVI 0x80
195#define PEDOMETER3_INS1_STPWMI 0x40
196#define PEDOMETER3_INS1_TLE 0x20
197#define PEDOMETER3_INS1_TRI 0x10
198#define PEDOMETER3_INS1_TDO 0x08
199#define PEDOMETER3_INS1_TUO 0x04
200#define PEDOMETER3_INS1_TFD 0x02
201#define PEDOMETER3_INS1_TFU 0x01
208#define PEDOMETER3_INS2_FFS 0x80
209#define PEDOMETER3_INS2_BFI 0x40
210#define PEDOMETER3_INS2_WMI 0x20
211#define PEDOMETER3_INS2_DRDY 0x10
212#define PEDOMETER3_INS2_TDTS_NO_TAP 0x00
213#define PEDOMETER3_INS2_TDTS_SINGLE_TAP 0x04
214#define PEDOMETER3_INS2_TDTS_DOUBLE_TAP 0x08
215#define PEDOMETER3_INS2_STPINCI 0x02
216#define PEDOMETER3_INS2_TPS 0x01
223#define PEDOMETER3_INS3_WUFS 0x80
224#define PEDOMETER3_INS3_BTS 0x40
225#define PEDOMETER3_INS3_XNWU 0x20
226#define PEDOMETER3_INS3_XPWU 0x10
227#define PEDOMETER3_INS3_YNWU 0x08
228#define PEDOMETER3_INS3_YPWU 0x04
229#define PEDOMETER3_INS3_ZNWU 0x02
230#define PEDOMETER3_INS3_ZPWU 0x01
237#define PEDOMETER3_STATUS_NO_INT 0x00
238#define PEDOMETER3_STATUS_INT_ACTIVE 0x10
239#define PEDOMETER3_STATUS_BACK_TO_SLEEP 0x00
240#define PEDOMETER3_STATUS_WAKE_UP 0x01
247#define PEDOMETER3_CNTL1_MODE_STAND_BY 0x00
248#define PEDOMETER3_CNTL1_MODE_LOW_POWER 0x80
249#define PEDOMETER3_CNTL1_RES_MODE_HIGHER_NOISE 0x00
250#define PEDOMETER3_CNTL1_RES_MODE_LOWER_NOISE 0x40
251#define PEDOMETER3_CNTL1_DATA_READY_DISABLE 0x00
252#define PEDOMETER3_CNTL1_DATA_READY_ENABLE 0x20
253#define PEDOMETER3_CNTL1_G_RANGE_2g 0x00
254#define PEDOMETER3_CNTL1_G_RANGE_4g 0x08
255#define PEDOMETER3_CNTL1_G_RANGE_8g 0x10
256#define PEDOMETER3_CNTL1_TAP_DISABLE 0x00
257#define PEDOMETER3_CNTL1_TAP_ENABLE 0x04
258#define PEDOMETER3_CNTL1_PEDOMETER_DISABLE 0x00
259#define PEDOMETER3_CNTL1_PEDOMETER_ENABLE 0x02
260#define PEDOMETER3_CNTL1_TILT_DISABLE 0x00
261#define PEDOMETER3_CNTL1_TILT_ENABLE 0x01
268#define PEDOMETER3_CNTL2_SOFTWARE_RESET_ACTIVE 0x80
269#define PEDOMETER3_CNTL2_SOFTWARE_RESET_NO_ACTIVE 0x00
270#define PEDOMETER3_CNTL2_COMMAND_TEST_ACTIVE 0x40
271#define PEDOMETER3_CNTL2_COMMAND_TEST_NO_ACTIVE 0x00
272#define PEDOMETER3_CNTL2_LEFT_STATE_ENABLE 0x20
273#define PEDOMETER3_CNTL2_RIGHT_STATE_ENABLE 0x10
274#define PEDOMETER3_CNTL2_DOWN_STATE_ENABLE 0x08
275#define PEDOMETER3_CNTL2_UP_STATE_ENABLE 0x04
276#define PEDOMETER3_CNTL2_FACE_DOWN_STATE_ENABLE 0x02
277#define PEDOMETER3_CNTL2_FACE_UP_STATE_ENABLE 0x01
284#define PEDOMETER3_CNTL3_OTP_OUTPUT_DATA_RATE_1_563Hz 0x00
285#define PEDOMETER3_CNTL3_OTP_OUTPUT_DATA_RATE_6_25Hz 0x40
286#define PEDOMETER3_CNTL3_OTP_OUTPUT_DATA_RATE_12_5Hz 0x80
287#define PEDOMETER3_CNTL3_OTP_OUTPUT_DATA_RATE_50Hz 0xC0
288#define PEDOMETER3_CNTL3_TAP_OUTPUT_DATA_RATE_50Hz 0x00
289#define PEDOMETER3_CNTL3_TAP_OUTPUT_DATA_RATE_100Hz 0x08
290#define PEDOMETER3_CNTL3_TAP_OUTPUT_DATA_RATE_200Hz 0x10
291#define PEDOMETER3_CNTL3_TAP_OUTPUT_DATA_RATE_400Hz 0x18
292#define PEDOMETER3_CNTL3_TAP_OUTPUT_DATA_RATE_12_5Hz 0x20
293#define PEDOMETER3_CNTL3_TAP_OUTPUT_DATA_RATE_25Hz 0x28
294#define PEDOMETER3_CNTL3_TAP_OUTPUT_DATA_RATE_800Hz 0x30
295#define PEDOMETER3_CNTL3_TAP_OUTPUT_DATA_RATE_1600Hz 0x38
296#define PEDOMETER3_CNTL3_OWUF_OUTPUT_DATA_RATE_0_781Hz 0x00
297#define PEDOMETER3_CNTL3_OWUF_OUTPUT_DATA_RATE_1_563Hz 0x01
298#define PEDOMETER3_CNTL3_OWUF_OUTPUT_DATA_RATE_3_125Hz 0x02
299#define PEDOMETER3_CNTL3_OWUF_OUTPUT_DATA_RATE_6_250Hz 0x03
300#define PEDOMETER3_CNTL3_OWUF_OUTPUT_DATA_RATE_12_5Hz 0x04
301#define PEDOMETER3_CNTL3_OWUF_OUTPUT_DATA_RATE_25Hz 0x05
302#define PEDOMETER3_CNTL3_OWUF_OUTPUT_DATA_RATE_50Hz 0x06
303#define PEDOMETER3_CNTL3_OWUF_OUTPUT_DATA_RATE_100Hz 0x07
310#define PEDOMETER3_CNTL4_COUNTER_CLEAR_MODE 0x00
311#define PEDOMETER3_CNTL4_COUNTER_DECREMENT_MODE 0x80
312#define PEDOMETER3_CNTL4_THRESHOLD_MODE_ABSOLUTE 0x00
313#define PEDOMETER3_CNTL4_THRESHOLD_MODE_RELATIVE 0x40
314#define PEDOMETER3_CNTL4_WAKE_UP_DISABLE 0x00
315#define PEDOMETER3_CNTL4_WAKE_UP_ENABLE 0x20
316#define PEDOMETER3_CNTL4_BACK_TO_SLEEP_DISABLE 0x00
317#define PEDOMETER3_CNTL4_BACK_TO_SLEEP_ENABLE 0x10
318#define PEDOMETER3_CNTL4_HIGH_PASS_DISABLE 0x00
319#define PEDOMETER3_CNTL4_HIGH_PASS_ENABLE 0x08
320#define PEDOMETER3_CNTL4_OBTS_OUTPUT_DATA_RATE_0_781Hz 0x00
321#define PEDOMETER3_CNTL4_OBTS_OUTPUT_DATA_RATE_1_563Hz 0x01
322#define PEDOMETER3_CNTL4_OBTS_OUTPUT_DATA_RATE_3_125Hz 0x02
323#define PEDOMETER3_CNTL4_OBTS_OUTPUT_DATA_RATE_6_250Hz 0x03
324#define PEDOMETER3_CNTL4_OBTS_OUTPUT_DATA_RATE_12_5Hz 0x04
325#define PEDOMETER3_CNTL4_OBTS_OUTPUT_DATA_RATE_25Hz 0x05
326#define PEDOMETER3_CNTL4_OBTS_OUTPUT_DATA_RATE_50Hz 0x06
327#define PEDOMETER3_CNTL4_OBTS_OUTPUT_DATA_RATE_100Hz 0x07
334#define PEDOMETER3_CNTL5_MANUAL_WAKE_UP_0 0x00
335#define PEDOMETER3_CNTL5_MANUAL_WAKE_UP_1 0x02
336#define PEDOMETER3_CNTL5_MANUAL_SLEEP_UP_0 0x00
337#define PEDOMETER3_CNTL5_MANUAL_SLEEP_UP_1 0x01
344#define PEDOMETER3_ODCNTL_IR_BYPASS_FILTERING_APPLIED 0x00
345#define PEDOMETER3_ODCNTL_IR_BYPASS_FILTER_BYPASSED 0x80
346#define PEDOMETER3_ODCNTL_LPRO_ODR_9 0x00
347#define PEDOMETER3_ODCNTL_LPRO_ODR_2 0x40
348#define PEDOMETER3_ODCNTL_OSA_OUTPUT_DATA_RATE_12_5Hz 0x00
349#define PEDOMETER3_ODCNTL_OSA_OUTPUT_DATA_RATE_25Hz 0x01
350#define PEDOMETER3_ODCNTL_OSA_OUTPUT_DATA_RATE_50Hz 0x02
351#define PEDOMETER3_ODCNTL_OSA_OUTPUT_DATA_RATE_100Hz 0x03
352#define PEDOMETER3_ODCNTL_OSA_OUTPUT_DATA_RATE_200Hz 0x04
353#define PEDOMETER3_ODCNTL_OSA_OUTPUT_DATA_RATE_400Hz 0x05
354#define PEDOMETER3_ODCNTL_OSA_OUTPUT_DATA_RATE_800Hz 0x06
355#define PEDOMETER3_ODCNTL_OSA_OUTPUT_DATA_RATE_1600Hz 0x07
356#define PEDOMETER3_ODCNTL_OSA_OUTPUT_DATA_RATE_0_781Hz 0x08
357#define PEDOMETER3_ODCNTL_OSA_OUTPUT_DATA_RATE_1_563Hz 0x09
358#define PEDOMETER3_ODCNTL_OSA_OUTPUT_DATA_RATE_3_125Hz 0x0A
359#define PEDOMETER3_ODCNTL_OSA_OUTPUT_DATA_RATE_6_25Hz 0x0B
360#define PEDOMETER3_ODCNTL_OSA_OUTPUT_DATA_RATE_3200Hz 0x0C
361#define PEDOMETER3_ODCNTL_OSA_OUTPUT_DATA_RATE_6400Hz 0x0D
362#define PEDOMETER3_ODCNTL_OSA_OUTPUT_DATA_RATE_12800Hz 0x0E
363#define PEDOMETER3_ODCNTL_OSA_OUTPUT_DATA_RATE_25600Hz 0x0F
370#define PEDOMETER3_INC1_PULSE_INTERRUPT_1_50uSec 0x00
371#define PEDOMETER3_INC1_PULSE_INTERRUPT_1_OSA_PERIOD 0x40
372#define PEDOMETER3_INC1_PULSE_INTERRUPT_1_OSA2_PERIOD 0x80
373#define PEDOMETER3_INC1_PULSE_INTERRUPT_1_OSA4_PERIOD 0xC0
374#define PEDOMETER3_INC1_PHYSICAL_INTERRUPT_DISABLE 0x00
375#define PEDOMETER3_INC1_PHYSICAL_INTERRUPT_ENABLE 0x20
376#define PEDOMETER3_INC1_INTERRUPT_ACTIVE_LEVEL_LOW 0x00
377#define PEDOMETER3_INC1_INTERRUPT_ACTIVE_LEVEL_HIGH 0x10
378#define PEDOMETER3_INC1_INTERRUPT_LATCHED 0x00
379#define PEDOMETER3_INC1_INTERRUPT_PULSED 0x08
380#define PEDOMETER3_INC1_SELF_TEST_POLARITY_NEGATIVE 0x00
381#define PEDOMETER3_INC1_SELF_TEST_POLARITY_POSITIVE 0x02
382#define PEDOMETER3_INC1_3_WIRE_SPI_INTERFACE_DISABLE 0x00
383#define PEDOMETER3_INC1_3_WIRE_SPI_INTERFACE_ENABLED 0x01
390#define PEDOMETER3_INC2_AOI_ACTIVE_STATE_IN_OR 0x00
391#define PEDOMETER3_INC2_AOI_ACTIVE_STATE_IN_AND 0x40
392#define PEDOMETER3_INC2_X_NEGATIVE_DISABLE 0x00
393#define PEDOMETER3_INC2_X_NEGATIVE_ENABEL 0x20
394#define PEDOMETER3_INC2_Y_NEGATIVE_DISABLE 0x00
395#define PEDOMETER3_INC2_Y_NEGATIVE_ENABEL 0x08
396#define PEDOMETER3_INC2_Z_NEGATIVE_DISABLE 0x00
397#define PEDOMETER3_INC2_Z_NEGATIVE_ENABEL 0x02
398#define PEDOMETER3_INC2_X_POSITIVE_DISABLE 0x00
399#define PEDOMETER3_INC2_X_POSITIVE_ENABEL 0x10
400#define PEDOMETER3_INC2_Y_POSITIVE_DISABLE 0x00
401#define PEDOMETER3_INC2_Y_POSITIVE_ENABEL 0x04
402#define PEDOMETER3_INC2_Z_POSITIVE_DISABLE 0x00
403#define PEDOMETER3_INC2_Z_POSITIVE_ENABEL 0x01
410#define PEDOMETER3_INC3_ALTERNATE_TAP_DISABLE 0x00
411#define PEDOMETER3_INC3_ALTERNATE_TAP_ENABLE 0x40
412#define PEDOMETER3_INC3_LEFT_STATE_DISABLE 0x00
413#define PEDOMETER3_INC3_LEFT_STATE_ENABLE 0x20
414#define PEDOMETER3_INC3_RIGHT_STATE_DISABLE 0x00
415#define PEDOMETER3_INC3_RIGHT_STATE_ENABLE 0x10
416#define PEDOMETER3_INC3_DOWN_STATE_DISABLE 0x00
417#define PEDOMETER3_INC3_DOWN_STATE_ENABLE 0x08
418#define PEDOMETER3_INC3_UP_STATE_DISABLE 0x00
419#define PEDOMETER3_INC3_UP_STATE_ENABLE 0x04
420#define PEDOMETER3_INC3_FACE_DOWN_STATE_DISABLE 0x00
421#define PEDOMETER3_INC3_FACE_DOWN_STATE_ENABLE 0x02
422#define PEDOMETER3_INC3_FACE_UP_STATE_DISABLE 0x00
423#define PEDOMETER3_INC3_FACE_UP_STATE_ENABLE 0x01
430#define PEDOMETER3_INC4_FREE_FALL_INTERRUPT_1_DISABLE 0x00
431#define PEDOMETER3_INC4_FREE_FALL_INTERRUPT_1_ENABLE 0x80
432#define PEDOMETER3_INC4_BUFFER_FULL_INTERRUPT_1_DISABLE 0x00
433#define PEDOMETER3_INC4_BUFFER_FULL_INTERRUPT_1_ENABLE 0x40
434#define PEDOMETER3_INC4_WATERMARK_INTERRUPT_1_DISABLE 0x00
435#define PEDOMETER3_INC4_WATERMARK_INTERRUPT_1_ENABLE 0x20
436#define PEDOMETER3_INC4_DATA_READY_INTERRUPT_1_DISABLE 0x00
437#define PEDOMETER3_INC4_DATA_READY_INTERRUPT_1_ENABLE 0x10
438#define PEDOMETER3_INC4_BACK_TO_SLEEP_INTERRUPT_1_DISABLE 0x00
439#define PEDOMETER3_INC4_BACK_TO_SLEEP_INTERRUPT_1_ENABLE 0x08
440#define PEDOMETER3_INC4_TAP_INTERRUPT_1_DISABLE 0x00
441#define PEDOMETER3_INC4_TAP_INTERRUPT_1_ENABLE 0x04
442#define PEDOMETER3_INC4_WAKE_UP_INTERRUPT_1_DISABLE 0x00
443#define PEDOMETER3_INC4_WAKE_UP_INTERRUPT_1_ENABLE 0x02
444#define PEDOMETER3_INC4_TILT_POSITION_INTERRUPT_1_DISABLE 0x00
445#define PEDOMETER3_INC4_TILT_POSITION_INTERRUPT_1_ENABLE 0x01
452#define PEDOMETER3_INC5_PULSE_INTERRUPT_2_50uSec 0x00
453#define PEDOMETER3_INC5_PULSE_INTERRUPT_2_OSA_PERIOD 0x40
454#define PEDOMETER3_INC5_PULSE_INTERRUPT_2_OSA2_PERIOD 0x80
455#define PEDOMETER3_INC5_PULSE_INTERRUPT_2_OSA4_PERIOD 0xC0
456#define PEDOMETER3_INC5_PHYSICAL_INTERRUPT_DISABLE 0x00
457#define PEDOMETER3_INC5_PHYSICAL_INTERRUPT_ENABLE 0x20
458#define PEDOMETER3_INC5_INTERRUPT_ACTIVE_LEVEL_LOW 0x00
459#define PEDOMETER3_INC5_INTERRUPT_ACTIVE_LEVEL_HIGH 0x10
460#define PEDOMETER3_INC5_INTERRUPT_LATCHED 0x00
461#define PEDOMETER3_INC5_INTERRUPT_PULSED 0x08
462#define PEDOMETER3_INC5_LATCHED_INTERRUPT_2_DISABLE 0x00
463#define PEDOMETER3_INC5_LATCHED_INTERRUPT_2_ENABLE 0x02
464#define PEDOMETER3_INC5_LATCHED_INTERRUPT_1_DISABLE 0x00
465#define PEDOMETER3_INC5_LATCHED_INTERRUPT_1_ENABLE 0x01
472#define PEDOMETER3_INC6_FREE_FALL_INTERRUPT_2_DISABLE 0x00
473#define PEDOMETER3_INC6_FREE_FALL_INTERRUPT_2_ENABLE 0x80
474#define PEDOMETER3_INC6_BUFFER_FULL_INTERRUPT_2_DISABLE 0x00
475#define PEDOMETER3_INC6_BUFFER_FULL_INTERRUPT_2_ENABLE 0x40
476#define PEDOMETER3_INC6_WATERMARK_INTERRUPT_2_DISABLE 0x00
477#define PEDOMETER3_INC6_WATERMARK_INTERRUPT_2_ENABLE 0x20
478#define PEDOMETER3_INC6_DATA_READY_INTERRUPT_2_DISABLE 0x00
479#define PEDOMETER3_INC6_DATA_READY_INTERRUPT_2_ENABLE 0x10
480#define PEDOMETER3_INC6_BACK_TO_SLEEP_INTERRUPT_2_DISABLE 0x00
481#define PEDOMETER3_INC6_BACK_TO_SLEEP_INTERRUPT_2_ENABLE 0x08
482#define PEDOMETER3_INC6_TAP_INTERRUPT_2_DISABLE 0x00
483#define PEDOMETER3_INC6_TAP_INTERRUPT_2_ENABLE 0x04
484#define PEDOMETER3_INC6_WAKE_UP_INTERRUPT_2_DISABLE 0x00
485#define PEDOMETER3_INC6_WAKE_UP_INTERRUPT_2_ENABLE 0x02
486#define PEDOMETER3_INC6_TILT_POSITION_INTERRUPT_2_DISABLE 0x00
487#define PEDOMETER3_INC6_TILT_POSITION_INTERRUPT_2_ENABLE 0x01
494#define PEDOMETER3_INC7_STEP_OVERFLOW_INTERRUPT_2_DISABLE 0x00
495#define PEDOMETER3_INC7_STEP_OVERFLOW_INTERRUPT_2_ENABLE 0x40
496#define PEDOMETER3_INC7_STEP_WATERMARK_INTERRUPT_2_DISABLE 0x00
497#define PEDOMETER3_INC7_STEP_WATERMARK_INTERRUPT_2_ENABLE 0x20
498#define PEDOMETER3_INC7_STEP_INCREMENT_INTERRUPT_2_DISABLE 0x00
499#define PEDOMETER3_INC7_STEP_INCREMENT_INTERRUPT_2_ENABLE 0x10
500#define PEDOMETER3_INC7_STEP_OVERFLOW_INTERRUPT_1_DISABLE 0x00
501#define PEDOMETER3_INC7_STEP_OVERFLOW_INTERRUPT_1_ENABLE 0x04
502#define PEDOMETER3_INC7_STEP_WATERMARK_INTERRUPT_1_DISABLE 0x00
503#define PEDOMETER3_INC7_STEP_WATERMARK_INTERRUPT_1_ENABLE 0x02
504#define PEDOMETER3_INC7_STEP_INCREMENT_INTERRUPT_1_DISABLE 0x00
505#define PEDOMETER3_INC7_STEP_INCREMENT_INTERRUPT_1_ENABLE 0x01
512#define PEDOMETER3_TDTRC_DOUBLE_TAP_INTERRUPT_DISABLE 0x00
513#define PEDOMETER3_TDTRC_DOUBLE_TAP_INTERRUPT_ENABLE 0x02
514#define PEDOMETER3_TDTRC_SINGLE_TAP_INTERRUPT_DISABLE 0x00
515#define PEDOMETER3_TDTRC_SINGLE_TAP_INTERRUPT_ENABLE 0x01
522#define PEDOMETER3_FFCNTL_FREE_FALL_DISABLE 0x00
523#define PEDOMETER3_FFCNTL_FREE_FALL_ENABLE 0x80
524#define PEDOMETER3_FFCNTL_FREE_FALL_INTERRUPT_LATCH_DISABLE 0x00
525#define PEDOMETER3_FFCNTL_FREE_FALL_INTERRUPT_UNLATCH_ENABLE 0x40
526#define PEDOMETER3_FFCNTL_DEBOUNCE_METHODOLOGY_DISABLE 0x00
527#define PEDOMETER3_FFCNTL_DEBOUNCE_METHODOLOGY_ENABLE 0x08
528#define PEDOMETER3_FFCNTL_OFFI_OUTPUT_DATA_RATE_12_5Hz 0x00
529#define PEDOMETER3_FFCNTL_OFFI_OUTPUT_DATA_RATE_25Hz 0x01
530#define PEDOMETER3_FFCNTL_OFFI_OUTPUT_DATA_RATE_50Hz 0x02
531#define PEDOMETER3_FFCNTL_OFFI_OUTPUT_DATA_RATE_100Hz 0x03
532#define PEDOMETER3_FFCNTL_OFFI_OUTPUT_DATA_RATE_200Hz 0x04
533#define PEDOMETER3_FFCNTL_OFFI_OUTPUT_DATA_RATE_400Hz 0x05
534#define PEDOMETER3_FFCNTL_OFFI_OUTPUT_DATA_RATE_800Hz 0x06
535#define PEDOMETER3_FFCNTL_OFFI_OUTPUT_DATA_RATE_1600Hz 0x07
542#define PEDOMETER3_LP_CNTL_NO_AVERAGING 0x00
543#define PEDOMETER3_LP_CNTL_2_SAMPLES_AVERAGED 0x10
544#define PEDOMETER3_LP_CNTL_4_SAMPLES_AVERAGED 0x20
545#define PEDOMETER3_LP_CNTL_8_SAMPLES_AVERAGED 0x30
546#define PEDOMETER3_LP_CNTL_16_SAMPLES_AVERAGED 0x40
547#define PEDOMETER3_LP_CNTL_32_SAMPLES_AVERAGED 0x50
548#define PEDOMETER3_LP_CNTL_64_SAMPLES_AVERAGED 0x60
549#define PEDOMETER3_LP_CNTL_128_SAMPLES_AVERAGED 0x70
556#define PEDOMETER3_PED_CNTL1_STEP_TH_NO_STEPS 0x00
557#define PEDOMETER3_PED_CNTL1_STEP_TH_2_STEPS 0x01
558#define PEDOMETER3_PED_CNTL1_STEP_TH_4_STEPS 0x02
559#define PEDOMETER3_PED_CNTL1_STEP_TH_6_STEPS 0x03
560#define PEDOMETER3_PED_CNTL1_STEP_TH_8_STEPS 0x04
561#define PEDOMETER3_PED_CNTL1_STEP_TH_10_STEPS 0x05
562#define PEDOMETER3_PED_CNTL1_STEP_TH_12_STEPS 0x06
563#define PEDOMETER3_PED_CNTL1_STEP_TH_14_STEPS 0x07
570#define PEDOMETER3_PED_CNTL2_HIGH_PASS_FILTER_1 0x00
571#define PEDOMETER3_PED_CNTL2_HIGH_PASS_FILTER_2 0x10
572#define PEDOMETER3_PED_CNTL2_HIGH_PASS_FILTER_4 0x20
573#define PEDOMETER3_PED_CNTL2_HIGH_PASS_FILTER_8 0x30
574#define PEDOMETER3_PED_CNTL2_HIGH_PASS_FILTER_16 0x40
575#define PEDOMETER3_PED_CNTL2_HIGH_PASS_FILTER_32 0x50
576#define PEDOMETER3_PED_CNTL2_HIGH_PASS_FILTER_64 0x60
577#define PEDOMETER3_PED_CNTL2_HIGH_PASS_FILTER_128 0x70
578#define PEDOMETER3_PED_CNTL2_ODR_SELECT_100Hz 0x0C
579#define PEDOMETER3_PED_CNTL2_ODR_SELECT_50Hz 0x06
586#define PEDOMETER3_SLAVE_ADDRESS_0 0x1E
587#define PEDOMETER3_SLAVE_ADDRESS_1 0x1F
594#define PEDOMETER3_TILT_POSITION_LEFT 1
595#define PEDOMETER3_TILT_POSITION_RIGHT 2
596#define PEDOMETER3_TILT_POSITION_DOWN 3
597#define PEDOMETER3_TILT_POSITION_UP 4
598#define PEDOMETER3_TILT_POSITION_FACE_DOWN 5
599#define PEDOMETER3_TILT_POSITION_FACE_UP 6
606#define PEDOMETER3_TAP_X_NEGATIVE 0x10
607#define PEDOMETER3_TAP_X_POSITIVE 0x11
608#define PEDOMETER3_TAP_Y_NEGATIVE 0x20
609#define PEDOMETER3_TAP_Y_POSITIVE 0x21
610#define PEDOMETER3_TAP_Z_NEGATIVE 0x30
611#define PEDOMETER3_TAP_Z_POSITIVE 0x31
614 // End group macro
615// --------------------------------------------------------------- PUBLIC TYPES
624typedef uint8_t pedometer3_select_t;
625
629typedef void ( *pedometer3_master_io_t )( struct pedometer3_s*, uint8_t, uint8_t*, uint8_t );
630
634typedef struct pedometer3_s
635{
636 // Output pins
637 digital_out_t cs;
638
639 // Input pins
640 digital_in_t trg;
641 digital_in_t it2;
642 digital_in_t int_pin;
643
644 // Modules
645 i2c_master_t i2c;
646 spi_master_t spi;
647
648 // ctx variable
650 pin_name_t chip_select;
654
656
660typedef struct
661{
662 // Communication gpio pins
663 pin_name_t scl;
664 pin_name_t sda;
665 pin_name_t miso;
666 pin_name_t mosi;
667 pin_name_t sck;
668 pin_name_t cs;
669
670 // Additional gpio pins
671 pin_name_t trg;
672 pin_name_t it2;
673 pin_name_t int_pin;
674
675 // static variable
676 uint32_t i2c_speed;
677 uint8_t i2c_address;
678
679 uint32_t spi_speed;
680 spi_master_mode_t spi_mode;
681 spi_master_chip_select_polarity_t cs_polarity;
682
684
686
690typedef struct
691{
692 int16_t x;
693 int16_t y;
694 int16_t z;
695
697
701typedef struct
702{
703 uint8_t current_pos;
705
707
708 // End types group
709// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
715#ifdef __cplusplus
716extern "C"{
717#endif
718
728
738
839
850void pedometer3_generic_write ( pedometer3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
851
862void pedometer3_generic_read ( pedometer3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
863
871
879
888void pedometer3_set_step_watermark ( pedometer3_t *ctx, uint16_t value );
889
899void pedometer3_pedometer_cfg ( pedometer3_t *ctx, uint8_t odr );
900
908
928
948
959
967
975
983
984#ifdef __cplusplus
985}
986#endif
987#endif // _PEDOMETER3_H_
988
989 // End varialbles group
991
992// ------------------------------------------------------------------------- END
void pedometer3_cfg_setup(pedometer3_cfg_t *cfg)
Config Object Initialization function.
void pedometer3_pedometer_cfg(pedometer3_t *ctx, uint8_t odr)
Functions for pedometer configuration.
void pedometer3_generic_write(pedometer3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
err_t pedometer3_init(pedometer3_t *ctx, pedometer3_cfg_t *cfg)
Initialization function.
uint8_t pedometer3_get_trigger_int(pedometer3_t *ctx)
Functions for read AN pin state.
uint16_t pedometer3_get_step_counter(pedometer3_t *ctx)
Functions for get pedometer step counter.
void pedometer3_get_accel_axis(pedometer3_t *ctx, pedometer3_axis_t *axis)
Functions for read Accel axis data.
void pedometer3_set_step_watermark(pedometer3_t *ctx, uint16_t value)
Functions for sets pedometer step counter Watermark.
void pedometer3_get_tilt_position(pedometer3_t *ctx, pedometer3_tilt_position_t *tilt)
Functions for get Tilt current and previous position.
void pedometer3_generic_read(pedometer3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
uint8_t pedometer3_get_interrupt_2(pedometer3_t *ctx)
Functions for read RST pin state.
void pedometer3_get_hp_accel_axis(pedometer3_t *ctx, pedometer3_axis_t *axis)
Functions for read High Pass Accel axis data.
uint8_t pedometer3_get_interrupt_1(pedometer3_t *ctx)
Functions for read INT pin state.
void pedometer3_default_cfg(pedometer3_t *ctx)
Click Default Configuration function.
uint8_t pedometer3_get_tap_detection(pedometer3_t *ctx)
Functions for get Tap detection.
err_t pedometer3_test_communication(pedometer3_t *ctx)
Functions for test first comunication width chip.
struct pedometer3_s pedometer3_t
Click ctx object definition.
void(* pedometer3_master_io_t)(struct pedometer3_s *, uint8_t, uint8_t *, uint8_t)
Function pointer for master input/output type.
Definition pedometer3.h:629
uint8_t pedometer3_select_t
Comunication select type.
Definition pedometer3.h:624
Axis structure.
Definition pedometer3.h:691
int16_t z
Definition pedometer3.h:694
int16_t x
Definition pedometer3.h:692
int16_t y
Definition pedometer3.h:693
Click configuration structure definition.
Definition pedometer3.h:661
pin_name_t it2
Definition pedometer3.h:672
uint32_t i2c_speed
Definition pedometer3.h:676
spi_master_chip_select_polarity_t cs_polarity
Definition pedometer3.h:681
pin_name_t sck
Definition pedometer3.h:667
spi_master_mode_t spi_mode
Definition pedometer3.h:680
pin_name_t mosi
Definition pedometer3.h:666
uint32_t spi_speed
Definition pedometer3.h:679
pin_name_t scl
Definition pedometer3.h:663
pin_name_t int_pin
Definition pedometer3.h:673
pin_name_t trg
Definition pedometer3.h:671
pin_name_t miso
Definition pedometer3.h:665
pin_name_t sda
Definition pedometer3.h:664
pedometer3_select_t sel
Definition pedometer3.h:683
pin_name_t cs
Definition pedometer3.h:668
uint8_t i2c_address
Definition pedometer3.h:677
Click ctx object definition.
Definition pedometer3.h:635
digital_out_t cs
Definition pedometer3.h:637
pedometer3_select_t master_sel
Definition pedometer3.h:653
digital_in_t trg
Definition pedometer3.h:640
spi_master_t spi
Definition pedometer3.h:646
digital_in_t it2
Definition pedometer3.h:641
pedometer3_master_io_t read_f
Definition pedometer3.h:652
pedometer3_master_io_t write_f
Definition pedometer3.h:651
digital_in_t int_pin
Definition pedometer3.h:642
i2c_master_t i2c
Definition pedometer3.h:645
uint8_t slave_address
Definition pedometer3.h:649
pin_name_t chip_select
Definition pedometer3.h:650
Tilt position structure.
Definition pedometer3.h:702
uint8_t previous_pos
Definition pedometer3.h:704
uint8_t current_pos
Definition pedometer3.h:703