profet10a  2.0.0.0
profet10a.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 PROFET10A_H
29 #define PROFET10A_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_analog_in.h"
48 
69 #define PROFET10A_MODE_ON 1
70 #define PROFET10A_MODE_OFF 2
71 #define PROFET10A_DIAGNOSTIC_ON 3
72 #define PROFET10A_DIAGNOSTIC_OFF 4
73 #define PROFET10A_FAULT 5
74  // profet10a_set
76 
91 #define PROFET10A_MAP_MIKROBUS( cfg, mikrobus ) \
92  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
93  cfg.den = MIKROBUS( mikrobus, MIKROBUS_CS ); \
94  cfg.in = MIKROBUS( mikrobus, MIKROBUS_PWM );
95  // profet10a_map // profet10a
98 
103 typedef struct
104 {
105  digital_out_t den;
106  digital_out_t in;
108  analog_in_t adc;
110  uint8_t mode;
111  uint16_t rsens;
112  uint16_t kilis;
113  float offset;
115 } profet10a_t;
116 
121 typedef struct
122 {
123  pin_name_t an;
124  pin_name_t den;
125  pin_name_t in;
127  analog_in_resolution_t resolution;
128  float vref;
131 
136 typedef enum
137 {
139  PROFET10A_ERROR = -1
140 
142 
159 
175 
188 err_t profet10a_read_an_pin_value ( profet10a_t *ctx, uint16_t *data_out );
189 
204 err_t profet10a_read_an_pin_voltage ( profet10a_t *ctx, float *data_out );
205 
217 err_t profet10a_set_mode ( profet10a_t *ctx, uint8_t mode );
218 
219 #ifdef __cplusplus
220 }
221 #endif
222 #endif // PROFET10A_H
223  // profet10a
225 
226 // ------------------------------------------------------------------------ END
profet10a_return_value_t
profet10a_return_value_t
PROFET 10A Click return value data.
Definition: profet10a.h:137
profet10a_t::mode
uint8_t mode
Definition: profet10a.h:110
profet10a_t::den
digital_out_t den
Definition: profet10a.h:105
profet10a_t::adc
analog_in_t adc
Definition: profet10a.h:108
profet10a_t::in
digital_out_t in
Definition: profet10a.h:106
profet10a_cfg_t::an
pin_name_t an
Definition: profet10a.h:123
profet10a_cfg_t::resolution
analog_in_resolution_t resolution
Definition: profet10a.h:127
profet10a_read_an_pin_value
err_t profet10a_read_an_pin_value(profet10a_t *ctx, uint16_t *data_out)
PROFET 10A read AN pin value function.
profet10a_t
PROFET 10A Click context object.
Definition: profet10a.h:104
PROFET10A_ERROR
@ PROFET10A_ERROR
Definition: profet10a.h:139
profet10a_cfg_t::den
pin_name_t den
Definition: profet10a.h:124
profet10a_read_an_pin_voltage
err_t profet10a_read_an_pin_voltage(profet10a_t *ctx, float *data_out)
PROFET 10A read AN pin voltage level function.
profet10a_t::kilis
uint16_t kilis
Definition: profet10a.h:112
profet10a_set_mode
err_t profet10a_set_mode(profet10a_t *ctx, uint8_t mode)
PROFET 10A set mode.
profet10a_cfg_setup
void profet10a_cfg_setup(profet10a_cfg_t *cfg)
PROFET 10A configuration object setup function.
profet10a_t::rsens
uint16_t rsens
Definition: profet10a.h:111
profet10a_t::offset
float offset
Definition: profet10a.h:113
profet10a_init
err_t profet10a_init(profet10a_t *ctx, profet10a_cfg_t *cfg)
PROFET 10A initialization function.
profet10a_cfg_t::vref
float vref
Definition: profet10a.h:128
profet10a_cfg_t
PROFET 10A Click configuration object.
Definition: profet10a.h:122
profet10a_cfg_t::in
pin_name_t in
Definition: profet10a.h:125
PROFET10A_OK
@ PROFET10A_OK
Definition: profet10a.h:138