lightranger7 2.1.0.0
lightranger7.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 LIGHTRANGER7_H
29#define LIGHTRANGER7_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 LIGHTRANGER7_CMD_START 's'
74#define LIGHTRANGER7_CMD_STOP 'p'
75
81#define LIGHTRANGER7_TX_DRV_BUFFER_SIZE 100
82#define LIGHTRANGER7_RX_DRV_BUFFER_SIZE 1000
83
84 // lightranger7_cmd
85
100#define LIGHTRANGER7_MAP_MIKROBUS( cfg, mikrobus ) \
101 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
102 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
103 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX );
104
105 // lightranger7_map
106 // lightranger7
107
112typedef struct
113{
114 // Output pins
115 digital_out_t rst;
117 // Modules
118 uart_t uart;
120 // Buffers
121 uint8_t uart_rx_buffer[ LIGHTRANGER7_RX_DRV_BUFFER_SIZE ];
122 uint8_t uart_tx_buffer[ LIGHTRANGER7_TX_DRV_BUFFER_SIZE ];
125
130typedef struct
131{
132 // Communication gpio pins
133 pin_name_t rx_pin;
134 pin_name_t tx_pin;
135 pin_name_t rst;
137 // Static variable
138 uint32_t baud_rate;
140 uart_data_bits_t data_bit;
141 uart_parity_t parity_bit;
142 uart_stop_bits_t stop_bit;
145
156
173
188
201err_t lightranger7_generic_write ( lightranger7_t *ctx, uint8_t *data_in, uint16_t len );
202
215err_t lightranger7_generic_read ( lightranger7_t *ctx, uint8_t *data_out, uint16_t len );
216
229
242
252
262
272
273#ifdef __cplusplus
274}
275#endif
276#endif // LIGHTRANGER7_H
277
278 // lightranger7
279
280// ------------------------------------------------------------------------ END
#define LIGHTRANGER7_TX_DRV_BUFFER_SIZE
LightRanger 7 driver buffer size.
Definition lightranger7.h:81
#define LIGHTRANGER7_RX_DRV_BUFFER_SIZE
Definition lightranger7.h:82
err_t lightranger7_init(lightranger7_t *ctx, lightranger7_cfg_t *cfg)
LightRanger 7 initialization function.
err_t lightranger7_start_measurement(lightranger7_t *ctx)
LightRanger 7 start measurement function.
void lightranger7_cfg_setup(lightranger7_cfg_t *cfg)
LightRanger 7 configuration object setup function.
err_t lightranger7_generic_write(lightranger7_t *ctx, uint8_t *data_in, uint16_t len)
LightRanger 7 data writing function.
void lightranger7_enable_device(lightranger7_t *ctx)
LightRanger 7 enable device function.
err_t lightranger7_stop_measurement(lightranger7_t *ctx)
LightRanger 7 stop measurement function.
err_t lightranger7_generic_read(lightranger7_t *ctx, uint8_t *data_out, uint16_t len)
LightRanger 7 data reading function.
void lightranger7_reset_device(lightranger7_t *ctx)
LightRanger 7 reset device function.
void lightranger7_disable_device(lightranger7_t *ctx)
LightRanger 7 disable device function.
lightranger7_return_value_t
LightRanger 7 Click return value data.
Definition lightranger7.h:151
@ LIGHTRANGER7_ERROR
Definition lightranger7.h:153
@ LIGHTRANGER7_OK
Definition lightranger7.h:152
LightRanger 7 Click configuration object.
Definition lightranger7.h:131
uint32_t baud_rate
Definition lightranger7.h:138
bool uart_blocking
Definition lightranger7.h:139
uart_data_bits_t data_bit
Definition lightranger7.h:140
pin_name_t tx_pin
Definition lightranger7.h:134
pin_name_t rx_pin
Definition lightranger7.h:133
uart_stop_bits_t stop_bit
Definition lightranger7.h:142
uart_parity_t parity_bit
Definition lightranger7.h:141
pin_name_t rst
Definition lightranger7.h:135
LightRanger 7 Click context object.
Definition lightranger7.h:113
uart_t uart
Definition lightranger7.h:118
digital_out_t rst
Definition lightranger7.h:115