stspin820 2.1.0.0
stspin820.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 STSPIN820_H
29#define STSPIN820_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51
72#define STSPIN820_DIR_CW 0
73#define STSPIN820_DIR_CCW 1
74
79#define STSPIN820_PIN_LOW_LEVEL 0
80#define STSPIN820_PIN_HIGH_LEVEL 1
81
86#define STSPIN820_SPEED_VERY_SLOW 0
87#define STSPIN820_SPEED_SLOW 1
88#define STSPIN820_SPEED_MEDIUM 2
89#define STSPIN820_SPEED_FAST 3
90#define STSPIN820_SPEED_VERY_FAST 4
91
92 // stspin820_set
93
108#define STSPIN820_MAP_MIKROBUS( cfg, mikrobus ) \
109 cfg.dir = MIKROBUS( mikrobus, MIKROBUS_AN ); \
110 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
111 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
112 cfg.step = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
113 cfg.fault = MIKROBUS( mikrobus, MIKROBUS_INT )
114
115 // stspin820_map
116 // stspin820
117
122typedef struct
123{
124 digital_out_t dir;
125 digital_out_t rst;
126 digital_out_t en;
127 digital_out_t step;
129 digital_in_t fault;
132
137typedef struct
138{
139 pin_name_t dir;
140 pin_name_t rst;
141 pin_name_t en;
142 pin_name_t step;
143 pin_name_t fault;
146
157
174
189
201
217void stspin820_drive_motor ( stspin820_t *ctx, uint32_t steps, uint8_t speed );
218
228
238
249void stspin820_set_direction ( stspin820_t *ctx, uint8_t dir );
250
260
270
281void stspin820_set_rst_pin ( stspin820_t *ctx, uint8_t state );
282
292
303void stspin820_set_step_pin ( stspin820_t *ctx, uint8_t state );
304
305#ifdef __cplusplus
306}
307#endif
308#endif // STSPIN820_H
309
310 // stspin820
311
312// ------------------------------------------------------------------------ END
void stspin820_switch_direction(stspin820_t *ctx)
STSPIN820 switch direction function.
void stspin820_set_direction(stspin820_t *ctx, uint8_t dir)
STSPIN820 set direction function.
void stspin820_cfg_setup(stspin820_cfg_t *cfg)
STSPIN820 configuration object setup function.
err_t stspin820_init(stspin820_t *ctx, stspin820_cfg_t *cfg)
STSPIN820 initialization function.
void stspin820_drive_motor(stspin820_t *ctx, uint32_t steps, uint8_t speed)
STSPIN820 drive motor function.
void stspin820_set_rst_pin(stspin820_t *ctx, uint8_t state)
STSPIN820 set rst pin function.
uint8_t stspin820_get_fault_pin(stspin820_t *ctx)
STSPIN820 get fault pin function.
void stspin820_reset_device(stspin820_t *ctx)
STSPIN820 reset device function.
void stspin820_enable_device(stspin820_t *ctx)
STSPIN820 enable device function.
void stspin820_disable_device(stspin820_t *ctx)
STSPIN820 disable device function.
void stspin820_set_step_pin(stspin820_t *ctx, uint8_t state)
STSPIN820 set step pin function.
void stspin820_default_cfg(stspin820_t *ctx)
STSPIN820 default configuration function.
STSPIN820 Click configuration object.
Definition stspin820.h:138
pin_name_t step
Definition stspin820.h:142
pin_name_t dir
Definition stspin820.h:139
pin_name_t en
Definition stspin820.h:141
pin_name_t rst
Definition stspin820.h:140
pin_name_t fault
Definition stspin820.h:143
STSPIN820 Click context object.
Definition stspin820.h:123
digital_out_t step
Definition stspin820.h:127
digital_out_t en
Definition stspin820.h:126
digital_out_t rst
Definition stspin820.h:125
digital_in_t fault
Definition stspin820.h:129
digital_out_t dir
Definition stspin820.h:124
stspin820_return_value_t
STSPIN820 Click return value data.
Definition stspin820.h:152
@ STSPIN820_ERROR
Definition stspin820.h:154
@ STSPIN820_OK
Definition stspin820.h:153