force3  2.0.0.0
force3.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 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef FORCE3_H
36 #define FORCE3_H
37 
38 #include "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_i2c_master.h"
51 
52 // -------------------------------------------------------------- PUBLIC MACROS
62 #define FORCE3_MAP_MIKROBUS( cfg, mikrobus ) \
63  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
64  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
65 
71 #define FORCE3_RETVAL uint8_t
72 
73 #define FORCE3_OK 0x00
74 #define FORCE3_INIT_ERROR 0xFF
75 
81 #define FORCE3_DEVICE_SLAVE_ADDR 0x4D
82  // End group macro
85 // --------------------------------------------------------------- PUBLIC TYPES
94 typedef struct
95 {
96  // Modules
97 
98  i2c_master_t i2c;
99 
100  // ctx variable
101 
102  uint8_t slave_address;
103 
104 } force3_t;
105 
109 typedef struct
110 {
111  // Communication gpio pins
112 
113  pin_name_t scl;
114  pin_name_t sda;
115 
116  // static variable
117 
118  uint32_t i2c_speed;
119  uint8_t i2c_address;
120 
121 } force3_cfg_t;
122  // End types group
124 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
125 
131 #ifdef __cplusplus
132 extern "C"{
133 #endif
134 
144 
153 
164 void force3_generic_write ( force3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
165 
177 void force3_generic_read ( force3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
178 
186 uint16_t force3_read_raw_data ( force3_t *ctx );
187 
188 #ifdef __cplusplus
189 }
190 #endif
191 #endif // _FORCE3_H_
192  // End public_function group
195 
196 // ------------------------------------------------------------------------- END
FORCE3_RETVAL
#define FORCE3_RETVAL
Definition: force3.h:71
force3_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: force3.h:118
force3_cfg_setup
void force3_cfg_setup(force3_cfg_t *cfg)
Config Object Initialization function.
force3_cfg_t::sda
pin_name_t sda
Definition: force3.h:114
force3_cfg_t
Click configuration structure definition.
Definition: force3.h:110
force3_cfg_t::scl
pin_name_t scl
Definition: force3.h:113
force3_init
FORCE3_RETVAL force3_init(force3_t *ctx, force3_cfg_t *cfg)
Initialization function.
force3_generic_write
void force3_generic_write(force3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
force3_read_raw_data
uint16_t force3_read_raw_data(force3_t *ctx)
Read 12bit raw data.
force3_t
Click ctx object definition.
Definition: force3.h:95
force3_t::slave_address
uint8_t slave_address
Definition: force3.h:102
force3_generic_read
void force3_generic_read(force3_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
force3_t::i2c
i2c_master_t i2c
Definition: force3.h:98
force3_cfg_t::i2c_address
uint8_t i2c_address
Definition: force3.h:119