xsensmti3 2.0.0.0
xsensmti3.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef XSENSMTI3_H
29#define XSENSMTI3_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_uart.h"
52
73#define XSENSMTI3_WAIT_FOR_START 0x00
74#define XSENSMTI3_START_PROCESS 0x01
75#define XSENSMTI3_DATA_PROCESSING 0x02
76#define XSENSMTI3_PARSER_DATA 0x03
77
83#define XSENSMTI3_TX_DRV_BUFFER_SIZE 100
84#define XSENSMTI3_RX_DRV_BUFFER_SIZE 1000
85
86 // xsensmti3_cmd
87
102#define XSENSMTI3_MAP_MIKROBUS( cfg, mikrobus ) \
103 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
104 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
105 cfg.syn = MIKROBUS( mikrobus, MIKROBUS_AN ); \
106 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
107 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
108 cfg.rts = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
109 cfg.cts = MIKROBUS( mikrobus, MIKROBUS_INT )
110
111 // xsensmti3_map
112 // xsensmti3
113
118typedef struct
119{
120 // Output pins
121 digital_out_t syn;
122 digital_out_t rst;
123 digital_out_t cs;
124 digital_out_t rts;
126 // Input pins
127 digital_in_t cts;
129 // Modules
130 uart_t uart;
132 // Buffers
133 uint8_t uart_rx_buffer[ XSENSMTI3_RX_DRV_BUFFER_SIZE ];
134 uint8_t uart_tx_buffer[ XSENSMTI3_TX_DRV_BUFFER_SIZE ];
137
142typedef struct
143{
144 // Communication gpio pins
145 pin_name_t rx_pin;
146 pin_name_t tx_pin;
148 // Additional gpio pins
149 pin_name_t syn;
150 pin_name_t rst;
151 pin_name_t cs;
152 pin_name_t rts;
153 pin_name_t cts;
155 // Static variable
156 uint32_t baud_rate;
158 uart_data_bits_t data_bit;
159 uart_parity_t parity_bit;
160 uart_stop_bits_t stop_bit;
163
167typedef struct
168{
169 uint16_t data_id;
170 uint32_t raw_data[ 4 ];
171 float quat_data[ 4 ];
172
174
178typedef struct
179{
180 uint16_t data_id;
181 uint32_t out_data;
182
184
188typedef struct
189{
190 uint16_t data_id;
191 uint16_t out_data;
192
194
208
212typedef struct
213{
214 float roll;
215 float pitch;
216 float yaw;
217
219
230
247
262
275err_t xsensmti3_generic_write ( xsensmti3_t *ctx, uint8_t *data_buf, uint16_t len );
276
289err_t xsensmti3_generic_read ( xsensmti3_t *ctx, uint8_t *data_buf, uint16_t max_len );
290
299void xsensmti3_parser ( uint8_t *rsp_buf, uint8_t start_cnt, xsensmti3_parse_t *obj );
300
309
319err_t xsensmti3_check_package( uint8_t *package_buf, uint8_t *start_package );
320
321#ifdef __cplusplus
322}
323#endif
324#endif // XSENSMTI3_H
325
326 // xsensmti3
327
328// ------------------------------------------------------------------------ END
#define XSENSMTI3_TX_DRV_BUFFER_SIZE
XSENS MTi-3 driver buffer size.
Definition xsensmti3.h:83
#define XSENSMTI3_RX_DRV_BUFFER_SIZE
Definition xsensmti3.h:84
void xsensmti3_get_data(xsensmti3_quat_t *quat_obj, xsensmti3_data_t *data_obj)
XSENS MTi-3 get Roll, Pitch and Yaw.
err_t xsensmti3_check_package(uint8_t *package_buf, uint8_t *start_package)
XSENS MTi-3 checks package.
err_t xsensmti3_generic_write(xsensmti3_t *ctx, uint8_t *data_buf, uint16_t len)
XSENS MTi-3 data writing function.
void xsensmti3_cfg_setup(xsensmti3_cfg_t *cfg)
XSENS MTi-3 configuration object setup function.
err_t xsensmti3_generic_read(xsensmti3_t *ctx, uint8_t *data_buf, uint16_t max_len)
XSENS MTi-3 data reading function.
void xsensmti3_parser(uint8_t *rsp_buf, uint8_t start_cnt, xsensmti3_parse_t *obj)
XSENS MTi-3 general parser.
err_t xsensmti3_init(xsensmti3_t *ctx, xsensmti3_cfg_t *cfg)
XSENS MTi-3 initialization function.
XSENS MTi-3 Click configuration object.
Definition xsensmti3.h:143
pin_name_t rts
Definition xsensmti3.h:152
uint32_t baud_rate
Definition xsensmti3.h:156
pin_name_t cts
Definition xsensmti3.h:153
bool uart_blocking
Definition xsensmti3.h:157
uart_data_bits_t data_bit
Definition xsensmti3.h:158
pin_name_t tx_pin
Definition xsensmti3.h:146
pin_name_t rx_pin
Definition xsensmti3.h:145
uart_stop_bits_t stop_bit
Definition xsensmti3.h:160
uart_parity_t parity_bit
Definition xsensmti3.h:159
pin_name_t rst
Definition xsensmti3.h:150
pin_name_t syn
Definition xsensmti3.h:149
pin_name_t cs
Definition xsensmti3.h:151
Click roll/pitch/yaw structure definition.
Definition xsensmti3.h:213
float roll
Definition xsensmti3.h:214
float pitch
Definition xsensmti3.h:215
float yaw
Definition xsensmti3.h:216
Click parse structure definition.
Definition xsensmti3.h:199
xsensmti3_u32_data_t status_obj
Definition xsensmti3.h:203
uint8_t crc_data
Definition xsensmti3.h:205
xsensmti3_quat_t quat_obj
Definition xsensmti3.h:201
uint32_t package_header
Definition xsensmti3.h:200
xsensmti3_u32_data_t time_obj
Definition xsensmti3.h:202
xsensmti3_u16_data_t package_obj
Definition xsensmti3.h:204
Click quat structure definition.
Definition xsensmti3.h:168
uint16_t data_id
Definition xsensmti3.h:169
XSENS MTi-3 Click context object.
Definition xsensmti3.h:119
digital_out_t cs
Definition xsensmti3.h:123
digital_out_t rts
Definition xsensmti3.h:124
digital_out_t syn
Definition xsensmti3.h:121
uart_t uart
Definition xsensmti3.h:130
digital_in_t cts
Definition xsensmti3.h:127
digital_out_t rst
Definition xsensmti3.h:122
Click 16-bit data structure definition.
Definition xsensmti3.h:189
uint16_t data_id
Definition xsensmti3.h:190
uint16_t out_data
Definition xsensmti3.h:191
Click 32-bit data structure definition.
Definition xsensmti3.h:179
uint32_t out_data
Definition xsensmti3.h:181
uint16_t data_id
Definition xsensmti3.h:180
xsensmti3_return_value_t
XSENS MTi-3 Click return value data.
Definition xsensmti3.h:225
@ XSENSMTI3_ERROR
Definition xsensmti3.h:227
@ XSENSMTI3_OK
Definition xsensmti3.h:226