dcmotor15  2.0.0.0
dcmotor15.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 DCMOTOR15_H
29 #define DCMOTOR15_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 
59 #define DCMOTOR15_RIPROP_OHM 1500
60 #define DCMOTOR15_AIPROP_AMP 0.000455
61 
76 #define DCMOTOR15_MAP_MIKROBUS( cfg, mikrobus ) \
77  cfg.ipr = MIKROBUS( mikrobus, MIKROBUS_AN ); \
78  cfg.slp = MIKROBUS( mikrobus, MIKROBUS_RST ); \
79  cfg.in2 = MIKROBUS( mikrobus, MIKROBUS_CS ); \
80  cfg.in1 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
81  cfg.flt = MIKROBUS( mikrobus, MIKROBUS_INT )
82  // dcmotor15_map // dcmotor15
85 
90 typedef struct
91 {
92  digital_out_t slp;
93  digital_out_t in2;
94  digital_out_t in1;
96  digital_in_t flt;
98  analog_in_t adc;
100 } dcmotor15_t;
101 
106 typedef struct
107 {
108  pin_name_t ipr;
109  pin_name_t slp;
110  pin_name_t in2;
111  pin_name_t in1;
112  pin_name_t flt;
114  analog_in_resolution_t resolution;
115  float vref;
118 
123 typedef enum
124 {
126  DCMOTOR15_ERROR = -1
127 
129 
134 typedef enum
135 {
137  DCMOTOR15_HIGH = 1
138 
140 
157 
173 
185 
198 err_t dcmotor15_read_an_pin_value ( dcmotor15_t *ctx, uint16_t *data_out );
199 
214 err_t dcmotor15_read_an_pin_voltage ( dcmotor15_t *ctx, float *data_out );
215 
225 void dcmotor15_set_slp_pin_state ( dcmotor15_t *ctx, uint8_t state );
226 
236 void dcmotor15_set_in1_pin_state ( dcmotor15_t *ctx, uint8_t state );
237 
247 void dcmotor15_set_in2_pin_state ( dcmotor15_t *ctx, uint8_t state );
248 
258 
268 
278 
288 
298 
308 float dcmotor15_get_current ( dcmotor15_t *ctx, uint16_t num_of_conv );
309 
310 #ifdef __cplusplus
311 }
312 #endif
313 #endif // DCMOTOR15_H
314  // dcmotor15
316 
317 // ------------------------------------------------------------------------ END
dcmotor15_cfg_t
DC Motor 15 Click configuration object.
Definition: dcmotor15.h:107
dcmotor15_cfg_t::flt
pin_name_t flt
Definition: dcmotor15.h:112
DCMOTOR15_HIGH
@ DCMOTOR15_HIGH
Definition: dcmotor15.h:137
DCMOTOR15_ERROR
@ DCMOTOR15_ERROR
Definition: dcmotor15.h:126
dcmotor15_t::adc
analog_in_t adc
Definition: dcmotor15.h:98
dcmotor15_t
DC Motor 15 Click context object.
Definition: dcmotor15.h:91
dcmotor15_cfg_t::in1
pin_name_t in1
Definition: dcmotor15.h:111
dcmotor15_cfg_setup
void dcmotor15_cfg_setup(dcmotor15_cfg_t *cfg)
DC Motor 15 configuration object setup function.
dcmotor15_set_slp_pin_state
void dcmotor15_set_slp_pin_state(dcmotor15_t *ctx, uint8_t state)
DC Motor 15 set SLP pin state function.
dcmotor15_get_current
float dcmotor15_get_current(dcmotor15_t *ctx, uint16_t num_of_conv)
DC Motor 15 get current function.
dcmotor15_cfg_t::in2
pin_name_t in2
Definition: dcmotor15.h:110
dcmotor15_t::flt
digital_in_t flt
Definition: dcmotor15.h:96
dcmotor15_cfg_t::ipr
pin_name_t ipr
Definition: dcmotor15.h:108
dcmotor15_t::in2
digital_out_t in2
Definition: dcmotor15.h:93
DCMOTOR15_OK
@ DCMOTOR15_OK
Definition: dcmotor15.h:125
dcmotor15_t::in1
digital_out_t in1
Definition: dcmotor15.h:94
dcmotor15_read_an_pin_voltage
err_t dcmotor15_read_an_pin_voltage(dcmotor15_t *ctx, float *data_out)
DC Motor 15 read IPR pin voltage level function.
dcmotor15_set_in1_pin_state
void dcmotor15_set_in1_pin_state(dcmotor15_t *ctx, uint8_t state)
DC Motor 15 set IN1 pin state function.
dcmotor15_init
err_t dcmotor15_init(dcmotor15_t *ctx, dcmotor15_cfg_t *cfg)
DC Motor 15 initialization function.
dcmotor15_stop
void dcmotor15_stop(dcmotor15_t *ctx)
DC Motor 15 stop function.
dcmotor15_brake
void dcmotor15_brake(dcmotor15_t *ctx)
DC Motor 15 brake function.
dcmotor15_return_value_t
dcmotor15_return_value_t
DC Motor 15 Click return value data.
Definition: dcmotor15.h:124
dcmotor15_t::slp
digital_out_t slp
Definition: dcmotor15.h:92
dcmotor15_pin_state_value_t
dcmotor15_pin_state_value_t
DC Motor 15 Click pin state value data.
Definition: dcmotor15.h:135
dcmotor15_cfg_t::slp
pin_name_t slp
Definition: dcmotor15.h:109
dcmotor15_forward
void dcmotor15_forward(dcmotor15_t *ctx)
DC Motor 15 drive forward function.
dcmotor15_reverse
void dcmotor15_reverse(dcmotor15_t *ctx)
DC Motor 15 drive reverse function.
dcmotor15_read_an_pin_value
err_t dcmotor15_read_an_pin_value(dcmotor15_t *ctx, uint16_t *data_out)
DC Motor 15 read IPR pin value function.
DCMOTOR15_LOW
@ DCMOTOR15_LOW
Definition: dcmotor15.h:136
dcmotor15_cfg_t::vref
float vref
Definition: dcmotor15.h:115
dcmotor15_cfg_t::resolution
analog_in_resolution_t resolution
Definition: dcmotor15.h:114
dcmotor15_set_in2_pin_state
void dcmotor15_set_in2_pin_state(dcmotor15_t *ctx, uint8_t state)
DC Motor 15 set IN2 pin state function.
dcmotor15_default_cfg
void dcmotor15_default_cfg(dcmotor15_t *ctx)
DC Motor 15 default configuration function.
dcmotor15_fault_check
uint8_t dcmotor15_fault_check(dcmotor15_t *ctx)
DC Motor 15 get FLT pin state function.