heartrate9  2.0.0.0
heartrate9.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 HEARTRATE9_H
29 #define HEARTRATE9_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 
60 #define DRV_BUFFER_SIZE 200
61  // heartrate9_set
63 
78 #define HEARTRATE9_MAP_MIKROBUS( cfg, mikrobus ) \
79  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
80  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
81  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
82 
83  // heartrate9_map // heartrate9
85 
90 typedef struct
91 {
92  // Output pins
93  digital_out_t rst;
95  // Modules
96  uart_t uart;
98  // Buffers
99  char uart_rx_buffer[ DRV_BUFFER_SIZE ];
100  char uart_tx_buffer[ DRV_BUFFER_SIZE ];
102 } heartrate9_t;
103 
108 typedef struct
109 {
110  // Communication gpio pins
111  pin_name_t rx_pin;
112  pin_name_t tx_pin;
114  // Additional gpio pins
115  pin_name_t rst;
117  // Static variable
118  uint32_t baud_rate;
120  uart_data_bits_t data_bit;
121  uart_parity_t parity_bit;
122  uart_stop_bits_t stop_bit;
125 
126 
143 
159 
173 err_t heartrate9_generic_write ( heartrate9_t *ctx, char *data_buf, uint16_t len );
174 
188 err_t heartrate9_generic_read ( heartrate9_t *ctx, char *data_buf, uint16_t max_len );
189 
200 void heartrate9_set_rst ( heartrate9_t *ctx, uint8_t state );
201 
202 #ifdef __cplusplus
203 }
204 #endif
205 #endif // HEARTRATE9_H
206  // heartrate9
208 
209 // ------------------------------------------------------------------------ END
heartrate9_cfg_t::tx_pin
pin_name_t tx_pin
Definition: heartrate9.h:112
DRV_BUFFER_SIZE
#define DRV_BUFFER_SIZE
Heart Rate 9 driver buffer size.
Definition: heartrate9.h:60
heartrate9_generic_write
err_t heartrate9_generic_write(heartrate9_t *ctx, char *data_buf, uint16_t len)
Heart Rate 9 data writing function.
heartrate9_set_rst
void heartrate9_set_rst(heartrate9_t *ctx, uint8_t state)
Sets state of the rst pin setting.
heartrate9_t
Heart Rate 9 Click context object.
Definition: heartrate9.h:91
heartrate9_cfg_t::baud_rate
uint32_t baud_rate
Definition: heartrate9.h:118
heartrate9_cfg_t::parity_bit
uart_parity_t parity_bit
Definition: heartrate9.h:121
heartrate9_generic_read
err_t heartrate9_generic_read(heartrate9_t *ctx, char *data_buf, uint16_t max_len)
Heart Rate 9 data reading function.
heartrate9_cfg_t::uart_blocking
bool uart_blocking
Definition: heartrate9.h:119
heartrate9_cfg_t
Heart Rate 9 Click configuration object.
Definition: heartrate9.h:109
heartrate9_cfg_t::stop_bit
uart_stop_bits_t stop_bit
Definition: heartrate9.h:122
heartrate9_cfg_t::rst
pin_name_t rst
Definition: heartrate9.h:115
heartrate9_cfg_t::rx_pin
pin_name_t rx_pin
Definition: heartrate9.h:111
heartrate9_t::rst
digital_out_t rst
Definition: heartrate9.h:93
heartrate9_cfg_t::data_bit
uart_data_bits_t data_bit
Definition: heartrate9.h:120
heartrate9_init
err_t heartrate9_init(heartrate9_t *ctx, heartrate9_cfg_t *cfg)
Heart Rate 9 initialization function.
heartrate9_t::uart
uart_t uart
Definition: heartrate9.h:96
heartrate9_cfg_setup
void heartrate9_cfg_setup(heartrate9_cfg_t *cfg)
Heart Rate 9 configuration object setup function.