profet27a  2.0.0.0
profet27a.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 PROFET27A_H
29 #define PROFET27A_H
30 
31 #ifdef __cplusplus
32 extern "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_analog_in.h"
52 
73 #define PROFET27A_MODE_ON 1
74 #define PROFET27A_MODE_OFF 2
75 #define PROFET27A_DIAGNOSTIC_ON 3
76 #define PROFET27A_DIAGNOSTIC_OFF 4
77  // profet27a_set
79 
94 #define PROFET27A_MAP_MIKROBUS( cfg, mikrobus ) \
95  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
96  cfg.dsl = MIKROBUS( mikrobus, MIKROBUS_RST ); \
97  cfg.den = MIKROBUS( mikrobus, MIKROBUS_CS ); \
98  cfg.in1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
99  cfg.in0 = MIKROBUS( mikrobus, MIKROBUS_INT )
100  // profet27a_map // profet27a
103 
108 typedef struct
109 {
110  digital_out_t dsl;
111  digital_out_t den;
112  digital_out_t in1;
113  digital_out_t in0;
115  analog_in_t adc;
117  uint8_t mode;
118  uint8_t channel;
119  uint16_t rsens;
120  uint16_t kilis;
122 } profet27a_t;
123 
128 typedef struct
129 {
130  pin_name_t an;
131  pin_name_t dsl;
132  pin_name_t den;
133  pin_name_t in1;
134  pin_name_t in0;
136  analog_in_resolution_t resolution;
137  float vref;
140 
145 typedef enum
146 {
150 
152 
157 typedef enum
158 {
161 
163 
180 
195 
210 
222 err_t profet27a_read_an_pin_value ( profet27a_t *ctx, uint16_t *data_out );
223 
238 err_t profet27a_read_an_pin_voltage ( profet27a_t *ctx, float *data_out );
239 
248 void profet27a_set_dsl ( profet27a_t *ctx, uint8_t state );
249 
258 void profet27a_set_den ( profet27a_t *ctx, uint8_t state );
259 
268 void profet27a_set_in1 ( profet27a_t *ctx, uint8_t state );
269 
278 void profet27a_set_in0 ( profet27a_t *ctx, uint8_t state );
279 
294 err_t profet27a_set_mode ( profet27a_t *ctx, profet27a_channel_t channel, uint8_t mode );
295 
296 #ifdef __cplusplus
297 }
298 #endif
299 #endif // PROFET27A_H
300  // profet27a
302 
303 // ------------------------------------------------------------------------ END
profet27a_t::mode
uint8_t mode
Definition: profet27a.h:117
profet27a_set_den
void profet27a_set_den(profet27a_t *ctx, uint8_t state)
Set diagnostic enable pin state.
profet27a_read_an_pin_voltage
err_t profet27a_read_an_pin_voltage(profet27a_t *ctx, float *data_out)
Read AN pin voltage level function.
profet27a_t::den
digital_out_t den
Definition: profet27a.h:111
profet27a_t::adc
analog_in_t adc
Definition: profet27a.h:115
profet27a_default_cfg
err_t profet27a_default_cfg(profet27a_t *ctx)
PROFET 2 7A default configuration function.
profet27a_t::in0
digital_out_t in0
Definition: profet27a.h:113
profet27a_cfg_t::in1
pin_name_t in1
Definition: profet27a.h:133
profet27a_t::dsl
digital_out_t dsl
Definition: profet27a.h:110
profet27a_cfg_t::vref
float vref
Definition: profet27a.h:137
PROFET27A_ERROR
@ PROFET27A_ERROR
Definition: profet27a.h:148
profet27a_cfg_setup
void profet27a_cfg_setup(profet27a_cfg_t *cfg)
PROFET 2 7A configuration object setup function.
profet27a_t::kilis
uint16_t kilis
Definition: profet27a.h:120
profet27a_return_value_t
profet27a_return_value_t
PROFET 2 7A Click return value data.
Definition: profet27a.h:146
profet27a_cfg_t::an
pin_name_t an
Definition: profet27a.h:130
profet27a_cfg_t::resolution
analog_in_resolution_t resolution
Definition: profet27a.h:136
profet27a_set_in0
void profet27a_set_in0(profet27a_t *ctx, uint8_t state)
Set channel 0 enable pin state.
profet27a_cfg_t::in0
pin_name_t in0
Definition: profet27a.h:134
profet27a_t::channel
uint8_t channel
Definition: profet27a.h:118
profet27a_t::rsens
uint16_t rsens
Definition: profet27a.h:119
profet27a_cfg_t
PROFET 2 7A Click configuration object.
Definition: profet27a.h:129
profet27a_t::in1
digital_out_t in1
Definition: profet27a.h:112
PROFET27A_CHANNEL_0
@ PROFET27A_CHANNEL_0
Definition: profet27a.h:159
profet27a_read_an_pin_value
err_t profet27a_read_an_pin_value(profet27a_t *ctx, uint16_t *data_out)
Read AN pin value function.
PROFET27A_CHANNEL_1
@ PROFET27A_CHANNEL_1
Definition: profet27a.h:160
PROFET27A_ERROR_CHANNEL
@ PROFET27A_ERROR_CHANNEL
Definition: profet27a.h:149
profet27a_set_dsl
void profet27a_set_dsl(profet27a_t *ctx, uint8_t state)
Set diagnostic select pin state.
profet27a_channel_t
profet27a_channel_t
PROFET 2 7A channel select.
Definition: profet27a.h:158
profet27a_set_mode
err_t profet27a_set_mode(profet27a_t *ctx, profet27a_channel_t channel, uint8_t mode)
Set mode device mode for specific channel channel.
profet27a_init
err_t profet27a_init(profet27a_t *ctx, profet27a_cfg_t *cfg)
PROFET 2 7A initialization function.
profet27a_t
PROFET 2 7A Click context object.
Definition: profet27a.h:109
profet27a_cfg_t::dsl
pin_name_t dsl
Definition: profet27a.h:131
profet27a_cfg_t::den
pin_name_t den
Definition: profet27a.h:132
profet27a_set_in1
void profet27a_set_in1(profet27a_t *ctx, uint8_t state)
Set channel 1 enable pin state.
PROFET27A_OK
@ PROFET27A_OK
Definition: profet27a.h:147