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
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_uart.h"
38 
59 #define XSENSMTI3_WAIT_FOR_START 0x00
60 #define XSENSMTI3_START_PROCESS 0x01
61 #define XSENSMTI3_DATA_PROCESSING 0x02
62 #define XSENSMTI3_PARSER_DATA 0x03
63 
69 #define DRV_BUFFER_SIZE 200
70  // xsensmti3_cmd
72 
87 #define XSENSMTI3_MAP_MIKROBUS( cfg, mikrobus ) \
88  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
89  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
90  cfg.syn = MIKROBUS( mikrobus, MIKROBUS_AN ); \
91  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
92  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
93  cfg.rts = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
94  cfg.cts = MIKROBUS( mikrobus, MIKROBUS_INT )
95  // xsensmti3_map // xsensmti3
98 
103 typedef struct
104 {
105  // Output pins
106  digital_out_t syn;
107  digital_out_t rst;
108  digital_out_t cs;
109  digital_out_t rts;
111  // Input pins
112  digital_in_t cts;
114  // Modules
115  uart_t uart;
117  // Buffers
118  char uart_rx_buffer[ DRV_BUFFER_SIZE ];
119  char uart_tx_buffer[ DRV_BUFFER_SIZE ];
121 } xsensmti3_t;
122 
127 typedef struct
128 {
129  // Communication gpio pins
130  pin_name_t rx_pin;
131  pin_name_t tx_pin;
133  // Additional gpio pins
134  pin_name_t syn;
135  pin_name_t rst;
136  pin_name_t cs;
137  pin_name_t rts;
138  pin_name_t cts;
140  // Static variable
141  uint32_t baud_rate;
142  bool uart_blocking;
143  uart_data_bits_t data_bit;
144  uart_parity_t parity_bit;
145  uart_stop_bits_t stop_bit;
148 
152 typedef struct
153 {
154  uint16_t data_id;
155  uint32_t raw_data[ 4 ];
156  float quat_data[ 4 ];
157 
159 
163 typedef struct
164 {
165  uint16_t data_id;
166  uint32_t out_data;
167 
169 
173 typedef struct
174 {
175  uint16_t data_id;
176  uint16_t out_data;
177 
179 
183 typedef struct
184 {
185  uint32_t package_header;
189  xsensmti3_u16_data_t package_obj;
190  uint8_t crc_data;
191 
193 
197 typedef struct
198 {
199  float roll;
200  float pitch;
201  float yaw;
202 
204 
209 typedef enum
210 {
212  XSENSMTI3_ERROR = -1
213 
215 
232 
247 err_t xsensmti3_init ( xsensmti3_t *ctx, xsensmti3_cfg_t *cfg );
248 
262 err_t xsensmti3_generic_write ( xsensmti3_t *ctx, char *data_buf, uint16_t len );
263 
277 err_t xsensmti3_generic_read ( xsensmti3_t *ctx, char *data_buf, uint16_t max_len );
278 
287 void xsensmti3_parser ( uint8_t *rsp_buf, uint8_t start_cnt, xsensmti3_parse_t *obj );
288 
296 void xsensmti3_get_data( xsensmti3_quat_t *quat_obj, xsensmti3_data_t *data_obj );
297 
308 err_t xsensmti3_check_package( uint8_t *package_buf, uint8_t *start_package );
309 
310 #ifdef __cplusplus
311 }
312 #endif
313 #endif // XSENSMTI3_H
314  // xsensmti3
316 
317 // ------------------------------------------------------------------------ END
xsensmti3_generic_write
err_t xsensmti3_generic_write(xsensmti3_t *ctx, char *data_buf, uint16_t len)
XSENS MTi-3 data writing function.
xsensmti3_parse_t
Click parse structure definition.
Definition: xsensmti3.h:182
xsensmti3_return_value_t
xsensmti3_return_value_t
XSENS MTi-3 Click return value data.
Definition: xsensmti3.h:208
DRV_BUFFER_SIZE
#define DRV_BUFFER_SIZE
XSENS MTi-3 driver buffer size.
Definition: xsensmti3.h:68
xsensmti3_parser
void xsensmti3_parser(uint8_t *rsp_buf, uint8_t start_cnt, xsensmti3_parse_t *obj)
XSENS MTi-3 general parser.
xsensmti3_quat_t
Click quat structure definition.
Definition: xsensmti3.h:151
xsensmti3_check_package
err_t xsensmti3_check_package(uint8_t *package_buf, uint8_t *start_package)
XSENS MTi-3 checks package.
xsensmti3_generic_read
err_t xsensmti3_generic_read(xsensmti3_t *ctx, char *data_buf, uint16_t max_len)
XSENS MTi-3 data reading function.
xsensmti3_data_t
Click roll/pitch/yaw structure definition.
Definition: xsensmti3.h:196
xsensmti3_get_data
void xsensmti3_get_data(xsensmti3_quat_t *quat_obj, xsensmti3_data_t *data_obj)
XSENS MTi-3 get Roll, Pitch and Yaw.
XSENSMTI3_ERROR
Definition: xsensmti3.h:211
xsensmti3_cfg_setup
void xsensmti3_cfg_setup(xsensmti3_cfg_t *cfg)
XSENS MTi-3 configuration object setup function.
xsensmti3_u16_data_t
Click 16-bit data structure definition.
Definition: xsensmti3.h:172
XSENSMTI3_OK
Definition: xsensmti3.h:210
xsensmti3_u32_data_t
Click 32-bit data structure definition.
Definition: xsensmti3.h:162
xsensmti3_init
err_t xsensmti3_init(xsensmti3_t *ctx, xsensmti3_cfg_t *cfg)
XSENS MTi-3 initialization function.
xsensmti3_t
XSENS MTi-3 Click context object.
Definition: xsensmti3.h:102
xsensmti3_cfg_t
XSENS MTi-3 Click configuration object.
Definition: xsensmti3.h:126