profet23a  2.0.0.0
profet23a.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 PROFET23A_H
29 #define PROFET23A_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 PROFET23A_MODE_ON 1
70 #define PROFET23A_MODE_OFF 2
71 #define PROFET23A_DIAGNOSTIC_ON 3
72 #define PROFET23A_DIAGNOSTIC_OFF 4
73  // profet23a_set
75 
90 #define PROFET23A_MAP_MIKROBUS( cfg, mikrobus ) \
91  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
92  cfg.dsl = MIKROBUS( mikrobus, MIKROBUS_RST ); \
93  cfg.den = MIKROBUS( mikrobus, MIKROBUS_CS ); \
94  cfg.in1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
95  cfg.in0 = MIKROBUS( mikrobus, MIKROBUS_INT )
96  // profet23a_map // profet23a
99 
104 typedef struct
105 {
106  digital_out_t dsl;
107  digital_out_t den;
108  digital_out_t in1;
109  digital_out_t in0;
111  analog_in_t adc;
113  uint8_t mode;
114  uint8_t channel;
115  uint16_t rsens;
116  uint16_t kilis;
118 } profet23a_t;
119 
124 typedef struct
125 {
126  pin_name_t an;
127  pin_name_t dsl;
128  pin_name_t den;
129  pin_name_t in1;
130  pin_name_t in0;
132  analog_in_resolution_t resolution;
133  float vref;
136 
141 typedef enum
142 {
146 
148 
153 typedef enum
154 {
157 
159 
176 
191 
206 
218 err_t profet23a_read_an_pin_value ( profet23a_t *ctx, uint16_t *data_out );
219 
234 err_t profet23a_read_an_pin_voltage ( profet23a_t *ctx, float *data_out );
235 
244 void profet23a_set_dsl ( profet23a_t *ctx, uint8_t state );
245 
254 void profet23a_set_den ( profet23a_t *ctx, uint8_t state );
255 
264 void profet23a_set_in1 ( profet23a_t *ctx, uint8_t state );
265 
274 void profet23a_set_in0 ( profet23a_t *ctx, uint8_t state );
275 
290 err_t profet23a_set_mode ( profet23a_t *ctx, profet23a_channel_t channel, uint8_t mode );
291 
292 #ifdef __cplusplus
293 }
294 #endif
295 #endif // PROFET23A_H
296  // profet23a
298 
299 // ------------------------------------------------------------------------ END
PROFET23A_ERROR
@ PROFET23A_ERROR
Definition: profet23a.h:144
profet23a_t::mode
uint8_t mode
Definition: profet23a.h:113
profet23a_cfg_t::vref
float vref
Definition: profet23a.h:133
profet23a_t::den
digital_out_t den
Definition: profet23a.h:107
profet23a_t::adc
analog_in_t adc
Definition: profet23a.h:111
profet23a_cfg_t::dsl
pin_name_t dsl
Definition: profet23a.h:127
PROFET23A_CHANNEL_0
@ PROFET23A_CHANNEL_0
Definition: profet23a.h:155
PROFET23A_CHANNEL_1
@ PROFET23A_CHANNEL_1
Definition: profet23a.h:156
profet23a_t::in0
digital_out_t in0
Definition: profet23a.h:109
profet23a_t::dsl
digital_out_t dsl
Definition: profet23a.h:106
profet23a_t
PROFET 2 3A Click context object.
Definition: profet23a.h:105
profet23a_cfg_t::in0
pin_name_t in0
Definition: profet23a.h:130
profet23a_set_in1
void profet23a_set_in1(profet23a_t *ctx, uint8_t state)
Set channel 1 enable pin state.
profet23a_set_den
void profet23a_set_den(profet23a_t *ctx, uint8_t state)
Set diagnostic enable pin state.
profet23a_init
err_t profet23a_init(profet23a_t *ctx, profet23a_cfg_t *cfg)
PROFET 2 3A initialization function.
profet23a_t::kilis
uint16_t kilis
Definition: profet23a.h:116
profet23a_cfg_t::in1
pin_name_t in1
Definition: profet23a.h:129
profet23a_return_value_t
profet23a_return_value_t
PROFET 2 3A Click return value data.
Definition: profet23a.h:142
profet23a_read_an_pin_value
err_t profet23a_read_an_pin_value(profet23a_t *ctx, uint16_t *data_out)
Read AN pin value function.
profet23a_cfg_t
PROFET 2 3A Click configuration object.
Definition: profet23a.h:125
PROFET23A_OK
@ PROFET23A_OK
Definition: profet23a.h:143
profet23a_t::channel
uint8_t channel
Definition: profet23a.h:114
profet23a_set_dsl
void profet23a_set_dsl(profet23a_t *ctx, uint8_t state)
Set diagnostic select pin state.
profet23a_set_mode
err_t profet23a_set_mode(profet23a_t *ctx, profet23a_channel_t channel, uint8_t mode)
Set mode device mode for specific channel channel.
profet23a_t::rsens
uint16_t rsens
Definition: profet23a.h:115
profet23a_t::in1
digital_out_t in1
Definition: profet23a.h:108
profet23a_cfg_t::an
pin_name_t an
Definition: profet23a.h:126
profet23a_cfg_t::resolution
analog_in_resolution_t resolution
Definition: profet23a.h:132
profet23a_cfg_setup
void profet23a_cfg_setup(profet23a_cfg_t *cfg)
PROFET 2 3A configuration object setup function.
profet23a_cfg_t::den
pin_name_t den
Definition: profet23a.h:128
PROFET23A_ERROR_CHANNEL
@ PROFET23A_ERROR_CHANNEL
Definition: profet23a.h:145
profet23a_channel_t
profet23a_channel_t
PROFET 2 3A channel select.
Definition: profet23a.h:154
profet23a_set_in0
void profet23a_set_in0(profet23a_t *ctx, uint8_t state)
Set channel 0 enable pin state.
profet23a_read_an_pin_voltage
err_t profet23a_read_an_pin_voltage(profet23a_t *ctx, float *data_out)
Read AN pin voltage level function.
profet23a_default_cfg
err_t profet23a_default_cfg(profet23a_t *ctx)
PROFET 2 3A default configuration function.