42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
67#define DRV_RX_BUFFER_SIZE 500
75#define STSPIN233_MAP_MIKROBUS( cfg, mikrobus ) \
76 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
77 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
78 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
79 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
86#define STSPIN233_RETVAL uint8_t
88#define STSPIN233_OK 0x00
89#define STSPIN233_INIT_ERROR 0xFF
96#define STSPIN233_CMD_START_MOTOR "STARTM"
97#define STSPIN233_CMD_STOP_MOTOR "STOPMT"
98#define STSPIN233_CMD_DIR_MOTOR "DIRECT"
99#define STSPIN233_CMD_SET_SPEED "SETSPD"
100#define STSPIN233_CMD_GET_SPEED "GETSPD"
101#define STSPIN233_CMD_STATUS "STATUS"
102#define STSPIN233_CMD_HELP "HELP"
103#define STSPIN233_CMD_SET_PWM "INIREF"
104#define STSPIN233_CMD_COM_DELAY "COMDEL"
105#define STSPIN233_CMD_MOTOR_POLE "POLESP"
106#define STSPIN233_CMD_KP_PRM "KP-PRM"
107#define STSPIN233_CMD_KI_PRM "KI-PRM"
114#define STSPIN233_CW_DIR "1"
115#define STSPIN233_CCW_DIR "0"
122#define STSPIN233_START_PWM_DUTY_10p "409"
123#define STSPIN233_START_PWM_DUTY_20p "819"
124#define STSPIN233_START_PWM_DUTY_DEF "819"
125#define STSPIN233_START_PWM_DUTY_30p "1229"
126#define STSPIN233_START_PWM_DUTY_40p "1638"
127#define STSPIN233_START_PWM_DUTY_50p "2048"
128#define STSPIN233_START_PWM_DUTY_60p "2458"
129#define STSPIN233_START_PWM_DUTY_70p "2867"
130#define STSPIN233_START_PWM_DUTY_80p "3277"
131#define STSPIN233_START_PWM_DUTY_90p "3687"
132#define STSPIN233_START_PWM_DUTY_100p "4095"
139#define STSPIN233_COMM_DELAY_7ms "7"
140#define STSPIN233_COMM_DELAY_DEF "7"
147#define STSPIN233_M_POLE_2 "2"
148#define STSPIN233_M_POLE_3 "3"
149#define STSPIN233_M_POLE_4 "4"
150#define STSPIN233_M_POLE_5 "5"
151#define STSPIN233_M_POLE_6 "6"
152#define STSPIN233_M_POLE_DEF "6"
153#define STSPIN233_M_POLE_7 "7"
154#define STSPIN233_M_POLE_8 "8"
161#define STSPIN233_KP_PRM_DEF "500"
162#define STSPIN233_KI_PRM_DEF "250"
169#define STSPIN233_SPEED_1000RPM "1000"
170#define STSPIN233_SPEED_DEF "1000"
171#define STSPIN233_SPEED_900RPM "900"
172#define STSPIN233_SPEED_1100RPM "1100"
173#define STSPIN233_SPEED_1200RPM "1200"
174#define STSPIN233_SPEED_1300RPM "1300"
175#define STSPIN233_SPEED_1400RPM "1400"
176#define STSPIN233_SPEED_1500RPM "1500"
177#define STSPIN233_SPEED_1600RPM "1600"
178#define STSPIN233_SPEED_1700RPM "1700"
179#define STSPIN233_SPEED_1800RPM "1800"
180#define STSPIN233_SPEED_1900RPM "1900"
181#define STSPIN233_SPEED_2000RPM "2000"
182#define STSPIN233_SPEED_2100RPM "2100"
#define DRV_RX_BUFFER_SIZE
Definition stspin233.h:67
#define STSPIN233_RETVAL
Definition stspin233.h:86
void stspin233_generic_write(stspin233_t *ctx, char *data_buf, uint16_t len)
Generic write function.
void stspin233_cfg_setup(stspin233_cfg_t *cfg)
Config Object Initialization function.
int32_t stspin233_generic_read(stspin233_t *ctx, char *data_buf, uint16_t max_len)
Generic read function.
void stspin233_default_cfg(stspin233_t *ctx)
Click Default Configuration function.
uint8_t stspin233_get_int_state(stspin233_t *ctx)
Get INT pin state.
void stspin233_set_reset_state(stspin233_t *ctx, uint8_t state)
Set RST pin state.
STSPIN233_RETVAL stspin233_init(stspin233_t *ctx, stspin233_cfg_t *cfg)
Initialization function.
void stspin233_wakeup(stspin233_t *ctx)
Module wake-up (procedure)
void stspin233_send_single_cmd(stspin233_t *ctx, uint8_t *tx_buf)
Send single command.
void stspin233_send_double_cmd(stspin233_t *ctx, uint8_t *cmd_buf, uint8_t *arg_buf)
Send double command.
Click configuration structure definition.
Definition stspin233.h:218
uint32_t baud_rate
Definition stspin233.h:231
bool uart_blocking
Definition stspin233.h:232
uart_data_bits_t data_bit
Definition stspin233.h:233
pin_name_t tx_pin
Definition stspin233.h:222
pin_name_t rx_pin
Definition stspin233.h:221
uart_stop_bits_t stop_bit
Definition stspin233.h:235
pin_name_t int_pin
Definition stspin233.h:227
uart_parity_t parity_bit
Definition stspin233.h:234
pin_name_t rst
Definition stspin233.h:226
Click ctx object definition.
Definition stspin233.h:196
uart_t uart
Definition stspin233.h:207
digital_in_t int_pin
Definition stspin233.h:203
digital_out_t rst
Definition stspin233.h:199