dcmotor25  2.1.0.0
dcmotor25.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 DCMOTOR25_H
29 #define DCMOTOR25_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_i2c_master.h"
37 
58 #define DCMOTOR25_WRITE_TO_RDAC 0x00
59 #define DCMOTOR25_ONE_TIME_PROG 0x80
60  // dcmotor25_inst
62 
77 #define DCMOTOR25_OTP_V_READY 0x00
78 #define DCMOTOR25_OTP_V_TEST_OK 0x40
79 #define DCMOTOR25_OTP_V_ERROR 0x80
80 #define DCMOTOR25_OTP_V_PROG_SUCCESS 0xC0
81 
87 #define DCMOTOR25_DEVICE_ADDRESS 0x2C
88  // dcmotor25_set
90 
105 #define DCMOTOR25_MAP_MIKROBUS( cfg, mikrobus ) \
106  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
107  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
108  cfg.in1 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
109  cfg.in2 = MIKROBUS( mikrobus, MIKROBUS_PWM )
110  // dcmotor25_map // dcmotor25
113 
118 typedef struct
119 {
120  // Output pins
121  digital_out_t in1;
122  digital_out_t in2;
124  // Modules
125  i2c_master_t i2c;
127  // I2C slave address
128  uint8_t slave_address;
130 } dcmotor25_t;
131 
136 typedef struct
137 {
138  pin_name_t scl;
139  pin_name_t sda;
141  pin_name_t in1;
142  pin_name_t in2;
144  uint32_t i2c_speed;
145  uint8_t i2c_address;
148 
153 typedef enum
154 {
156  DCMOTOR25_ERROR = -1
157 
159 
176 
191 
205 
219 err_t dcmotor25_write_byte ( dcmotor25_t *ctx, uint8_t inst, uint8_t data_in );
220 
232 err_t dcmotor25_read_byte ( dcmotor25_t *ctx, uint8_t *data_out );
233 
247 err_t dcmotor25_write_rdac ( dcmotor25_t *ctx, uint8_t rdac_data );
248 
262 err_t dcmotor25_read_rdac ( dcmotor25_t *ctx, uint8_t *rdac_data );
263 
277 err_t dcmotor25_set_digi_pot ( dcmotor25_t *ctx, uint8_t wiper_pos );
278 
293 err_t dcmotor25_set_resistance ( dcmotor25_t *ctx, uint16_t res_ohm );
294 
306 
318 
330 
342 
343 #ifdef __cplusplus
344 }
345 #endif
346 #endif // DCMOTOR25_H
347  // dcmotor25
349 
350 // ------------------------------------------------------------------------ END
dcmotor25_cfg_t::sda
pin_name_t sda
Definition: dcmotor25.h:139
dcmotor25_cfg_t::scl
pin_name_t scl
Definition: dcmotor25.h:138
DCMOTOR25_ERROR
@ DCMOTOR25_ERROR
Definition: dcmotor25.h:156
dcmotor25_t::in2
digital_out_t in2
Definition: dcmotor25.h:122
dcmotor25_t::in1
digital_out_t in1
Definition: dcmotor25.h:121
dcmotor25_return_value_t
dcmotor25_return_value_t
DC Motor 25 Click return value data.
Definition: dcmotor25.h:154
dcmotor25_forward
void dcmotor25_forward(dcmotor25_t *ctx)
DC Motor 25 set brake mode function.
dcmotor25_default_cfg
err_t dcmotor25_default_cfg(dcmotor25_t *ctx)
DC Motor 25 default configuration function.
dcmotor25_init
err_t dcmotor25_init(dcmotor25_t *ctx, dcmotor25_cfg_t *cfg)
DC Motor 25 initialization function.
dcmotor25_write_rdac
err_t dcmotor25_write_rdac(dcmotor25_t *ctx, uint8_t rdac_data)
DC Motor 25 write RDAC function.
dcmotor25_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: dcmotor25.h:144
dcmotor25_t
DC Motor 25 Click context object.
Definition: dcmotor25.h:119
dcmotor25_cfg_t::in2
pin_name_t in2
Definition: dcmotor25.h:142
dcmotor25_t::slave_address
uint8_t slave_address
Definition: dcmotor25.h:128
dcmotor25_cfg_t::i2c_address
uint8_t i2c_address
Definition: dcmotor25.h:145
DCMOTOR25_OK
@ DCMOTOR25_OK
Definition: dcmotor25.h:155
dcmotor25_brake
void dcmotor25_brake(dcmotor25_t *ctx)
DC Motor 25 set brake mode function.
dcmotor25_cfg_t::in1
pin_name_t in1
Definition: dcmotor25.h:141
dcmotor25_standby
void dcmotor25_standby(dcmotor25_t *ctx)
DC Motor 25 set standby mode function.
dcmotor25_cfg_setup
void dcmotor25_cfg_setup(dcmotor25_cfg_t *cfg)
DC Motor 25 configuration object setup function.
dcmotor25_read_rdac
err_t dcmotor25_read_rdac(dcmotor25_t *ctx, uint8_t *rdac_data)
DC Motor 25 read RDAC function.
dcmotor25_reverse
void dcmotor25_reverse(dcmotor25_t *ctx)
DC Motor 25 set reverse mode function.
dcmotor25_read_byte
err_t dcmotor25_read_byte(dcmotor25_t *ctx, uint8_t *data_out)
DC Motor 25 I2C reading function.
dcmotor25_t::i2c
i2c_master_t i2c
Definition: dcmotor25.h:125
dcmotor25_cfg_t
DC Motor 25 Click configuration object.
Definition: dcmotor25.h:137
dcmotor25_write_byte
err_t dcmotor25_write_byte(dcmotor25_t *ctx, uint8_t inst, uint8_t data_in)
DC Motor 25 I2C writing function.
dcmotor25_set_resistance
err_t dcmotor25_set_resistance(dcmotor25_t *ctx, uint16_t res_ohm)
DC Motor 25 set the resistance function.
dcmotor25_set_digi_pot
err_t dcmotor25_set_digi_pot(dcmotor25_t *ctx, uint8_t wiper_pos)
DC Motor 25 set the digital potentiometer function.