driver2  2.0.0.0
driver2.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2021 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 DRIVER2_H
29 #define DRIVER2_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_pwm.h"
38 
59 #define DRIVER2_PIN_ENABLE 0x01
60 #define DRIVER2_PIN_DISABLE 0x00
61 
66 #define DRIVER2_DEF_FREQ 5000
67  // driver2_cfg
69 
84 #define DRIVER2_MAP_MIKROBUS( cfg, mikrobus ) \
85  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
86  cfg.sd = MIKROBUS( mikrobus, MIKROBUS_CS ); \
87  cfg.fb = MIKROBUS( mikrobus, MIKROBUS_INT )
88  // driver2_map // driver2
91 
101 typedef struct
102 {
103  // Output pins
104  digital_out_t sd;
106  // Input pins
107  digital_in_t fb;
109  // Modules
110  pwm_t pwm;
112  // ctx variable
113  uint32_t pwm_freq;
115 } driver2_t;
116 
121 typedef struct
122 {
123  // Communication gpio pins
124  pin_name_t pwm;
126  // Additional gpio pins
127  pin_name_t sd;
128  pin_name_t fb;
130  // Static variable
131  uint32_t dev_pwm_freq;
133 } driver2_cfg_t;
134 
139 typedef enum
140 {
142  DRIVER2_ERROR = -1
143 
145 
162 
176 err_t driver2_init ( driver2_t *ctx, driver2_cfg_t *cfg );
177 
192 
204 err_t driver2_set_duty_cycle ( driver2_t *ctx, float duty_cycle );
205 
217 
229 
238 void driver2_set_sd_pin ( driver2_t *ctx, uint8_t state );
239 
248 void driver2_set_pwm_pin ( driver2_t *ctx, uint8_t state );
249 
257 uint8_t driver2_get_fb_pin ( driver2_t *ctx );
258 
259 #ifdef __cplusplus
260 }
261 #endif
262 #endif // DRIVER2_H
263  // driver2
265 
266 // ------------------------------------------------------------------------ END
driver2_cfg_t
Driver 2 Click configuration object.
Definition: driver2.h:122
driver2_pwm_start
err_t driver2_pwm_start(driver2_t *ctx)
Driver 2 start PWM module.
driver2_set_duty_cycle
err_t driver2_set_duty_cycle(driver2_t *ctx, float duty_cycle)
Driver 2 sets PWM duty cycle.
driver2_set_pwm_pin
void driver2_set_pwm_pin(driver2_t *ctx, uint8_t state)
Set PWM pin.
driver2_t
Driver 2 Click driver selector.
Definition: driver2.h:102
driver2_pwm_stop
err_t driver2_pwm_stop(driver2_t *ctx)
Driver 2 stop PWM module.
driver2_init
err_t driver2_init(driver2_t *ctx, driver2_cfg_t *cfg)
Driver 2 initialization function.
driver2_cfg_t::fb
pin_name_t fb
Definition: driver2.h:128
driver2_cfg_t::pwm
pin_name_t pwm
Definition: driver2.h:124
driver2_t::pwm
pwm_t pwm
Definition: driver2.h:110
driver2_default_cfg
err_t driver2_default_cfg(driver2_t *ctx)
Driver 2 default configuration function.
driver2_cfg_t::dev_pwm_freq
uint32_t dev_pwm_freq
Definition: driver2.h:131
driver2_return_value_t
driver2_return_value_t
Driver 2 Click return value data.
Definition: driver2.h:140
DRIVER2_ERROR
@ DRIVER2_ERROR
Definition: driver2.h:142
driver2_cfg_setup
void driver2_cfg_setup(driver2_cfg_t *cfg)
Driver 2 configuration object setup function.
DRIVER2_OK
@ DRIVER2_OK
Definition: driver2.h:141
driver2_cfg_t::sd
pin_name_t sd
Definition: driver2.h:127
driver2_t::fb
digital_in_t fb
Definition: driver2.h:107
driver2_set_sd_pin
void driver2_set_sd_pin(driver2_t *ctx, uint8_t state)
Set SD pin.
driver2_get_fb_pin
uint8_t driver2_get_fb_pin(driver2_t *ctx)
Get FB pin.
driver2_t::pwm_freq
uint32_t pwm_freq
Definition: driver2.h:113
driver2_t::sd
digital_out_t sd
Definition: driver2.h:104