dcmotor27 2.1.0.0
dcmotor27.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 DCMOTOR27_H
29#define DCMOTOR27_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_pwm.h"
38
59#define DCMOTOR27_DEF_FREQ 5000
60
65#define DCMOTOR27_SET_PIN_HIGH 0x01
66#define DCMOTOR27_SET_PIN_LOW 0x00
67
72#define DCMOTOR27_SET_COAST_ON 0x01
73#define DCMOTOR27_SET_COAST_OFF 0x00
74 // dcmotor27_cfg
76
91#define DCMOTOR27_MAP_MIKROBUS( cfg, mikrobus ) \
92 cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
93 cfg.ip = MIKROBUS( mikrobus, MIKROBUS_AN ); \
94 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
95 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
96 cfg.flt = MIKROBUS( mikrobus, MIKROBUS_INT );
97 // dcmotor27_map // dcmotor27
100
105typedef struct
106{
107 // Output pins
108 digital_out_t rst;
109 digital_out_t cs;
111 // Input pins
112 digital_in_t ip;
113 digital_in_t flt;
115 // Modules
116 pwm_t pwm;
118 // ctx variable
119 uint32_t pwm_freq;
122
127typedef struct
128{
129 // Communication gpio pins
130 pin_name_t pwm;
132 // Additional gpio pins
133 pin_name_t ip;
134 pin_name_t rst;
135 pin_name_t cs;
136 pin_name_t flt;
138 // Static variable
139 uint32_t dev_pwm_freq;
142
147typedef enum
148{
150 DCMOTOR27_ERROR = -1
151
153
170
185
199
211err_t dcmotor27_set_duty_cycle ( dcmotor27_t *ctx, float duty_cycle );
212
224
236
246
256
266void dcmotor27_set_rst_pin ( dcmotor27_t *ctx, uint8_t pin_state );
267
277void dcmotor27_set_cs_pin ( dcmotor27_t *ctx, uint8_t pin_state );
278
288void dcmotor27_set_coast ( dcmotor27_t *ctx, uint8_t coast_state );
289
290#ifdef __cplusplus
291}
292#endif
293#endif // DCMOTOR27_H
294 // dcmotor27
296
297// ------------------------------------------------------------------------ END
dcmotor27_return_value_t
DC Motor 27 Click return value data.
Definition: dcmotor27.h:148
@ DCMOTOR27_ERROR
Definition: dcmotor27.h:150
@ DCMOTOR27_OK
Definition: dcmotor27.h:149
uint8_t dcmotor27_get_ip_pin(dcmotor27_t *ctx)
DC Motor 27 get ip pin state.
uint8_t dcmotor27_get_flt_pin(dcmotor27_t *ctx)
DC Motor 27 get flt pin state.
void dcmotor27_cfg_setup(dcmotor27_cfg_t *cfg)
DC Motor 27 configuration object setup function.
err_t dcmotor27_set_duty_cycle(dcmotor27_t *ctx, float duty_cycle)
DC Motor 27 sets PWM duty cycle.
err_t dcmotor27_init(dcmotor27_t *ctx, dcmotor27_cfg_t *cfg)
DC Motor 27 initialization function.
err_t dcmotor27_pwm_start(dcmotor27_t *ctx)
DC Motor 27 start PWM module.
err_t dcmotor27_default_cfg(dcmotor27_t *ctx)
DC Motor 27 default configuration function.
void dcmotor27_set_cs_pin(dcmotor27_t *ctx, uint8_t pin_state)
DC Motor 27 set CS pin state.
void dcmotor27_set_rst_pin(dcmotor27_t *ctx, uint8_t pin_state)
DC Motor 27 set RST pin state.
void dcmotor27_set_coast(dcmotor27_t *ctx, uint8_t coast_state)
DC Motor 27 set coast mode funtion.
err_t dcmotor27_pwm_stop(dcmotor27_t *ctx)
DC Motor 27 stop PWM module.
DC Motor 27 Click configuration object.
Definition: dcmotor27.h:128
pin_name_t ip
Definition: dcmotor27.h:133
uint32_t dev_pwm_freq
Definition: dcmotor27.h:139
pin_name_t flt
Definition: dcmotor27.h:136
pin_name_t pwm
Definition: dcmotor27.h:130
pin_name_t rst
Definition: dcmotor27.h:134
pin_name_t cs
Definition: dcmotor27.h:135
DC Motor 27 Click context object.
Definition: dcmotor27.h:106
digital_out_t cs
Definition: dcmotor27.h:109
digital_in_t flt
Definition: dcmotor27.h:113
uint32_t pwm_freq
Definition: dcmotor27.h:119
digital_in_t ip
Definition: dcmotor27.h:112
digital_out_t rst
Definition: dcmotor27.h:108
pwm_t pwm
Definition: dcmotor27.h:116