LibL6474-C-Library 1.0
Library Code documentation
Loading...
Searching...
No Matches
LibL6474.h
Go to the documentation of this file.
1/*
2 * LibL6474.h
3 *
4 * Created on: Dec 2, 2024
5 * Author: Thorsten
6 */
7
9
10#ifndef INC_LIBL6474_H_
11#define INC_LIBL6474_H_ INC_LIBL6474_H_
12
16// --------------------------------------------------------------------------------------------------------------------
17#include "LibL6474Config.h"
18
19
25// --------------------------------------------------------------------------------------------------------------------
26typedef enum L6474x_State
27// --------------------------------------------------------------------------------------------------------------------
28{
33 stRESET = 0x00,
34
39 stDISABLED = 0x01,
40
45 stENABLED = 0x02,
46
52 stINVALID = 0x04
53
55
56
62// --------------------------------------------------------------------------------------------------------------------
63typedef enum L6474x_StepMode
64// --------------------------------------------------------------------------------------------------------------------
65{
70 smFULL = 0x00,
71
75 smHALF = 0x01,
76
80 smMICRO4 = 0x02,
81
85 smMICRO8 = 0x03,
86
90 smMICRO16 = 0x04
92
96// --------------------------------------------------------------------------------------------------------------------
97typedef enum L6474x_Direction
98// --------------------------------------------------------------------------------------------------------------------
99{
104
110
115// --------------------------------------------------------------------------------------------------------------------
117// --------------------------------------------------------------------------------------------------------------------
118{
123
128
133
139
144
151
156
162
167
169
170
175// --------------------------------------------------------------------------------------------------------------------
176typedef struct L6474_Status
177// --------------------------------------------------------------------------------------------------------------------
178{
182 unsigned char HIGHZ ;
183
187 unsigned char DIR ;
188
192 unsigned char NOTPERF_CMD;
193
197 unsigned char WRONG_CMD ;
198
202 unsigned char UVLO ;
203
207 unsigned char TH_WARN ;
208
212 unsigned char TH_SD ;
213
217 unsigned char OCD ;
218
222 unsigned char ONGOING ;
224
225
230// --------------------------------------------------------------------------------------------------------------------
231typedef enum L6474x_OCD_TH
232// --------------------------------------------------------------------------------------------------------------------
233{
234 ocdth375mA = 0x00,
235 ocdth750mA = 0x01,
236 ocdth1125mA = 0x02,
237 ocdth1500mA = 0x03,
238 ocdth1875mA = 0x04,
239 ocdth2250mA = 0x05,
240 ocdth2625mA = 0x06,
241 ocdth3000mA = 0x07,
242 ocdth3375mA = 0x08,
243 ocdth3750mA = 0x09,
244 ocdth4125mA = 0x0A,
245 ocdth4500mA = 0x0B,
246 ocdth4875mA = 0x0C,
247 ocdth5250mA = 0x0D,
248 ocdth5625mA = 0x0E,
249 ocdth6000mA = 0x0F
251
257// --------------------------------------------------------------------------------------------------------------------
259
260
266// --------------------------------------------------------------------------------------------------------------------
267typedef struct L6474x_Platform
268// --------------------------------------------------------------------------------------------------------------------
269{
285 void* (*malloc) ( unsigned int size );
286
303 void (*free) ( const void* const pMem );
304
327 int (*transfer) ( void* pIO, char* pRX, const char* pTX, unsigned int length );
328
345 void (*reset) ( void* pGPO, const int ena );
346
360 void (*sleep) ( unsigned int ms );
361
362#if defined(LIBL6474_STEP_ASYNC) && ( LIBL6474_STEP_ASYNC == 0 )
387 int (*step) ( void* pPWM, int dir, unsigned int numPulses );
388#else
415 int (*stepAsync) ( void* pPWM, int dir, unsigned int numPulses, void (*doneClb)(L6474_Handle_t), L6474_Handle_t h );
416
423 int (*cancelStep)( void* pPWM );
424#endif
425
426#if defined(LIBL6474_HAS_LOCKING) && LIBL6474_HAS_LOCKING == 1
430 int (*lock) ( void );
431
436 void (*unlock) ( void );
437#endif
438
439#if defined(LIBL6474_HAS_FLAG) && LIBL6474_HAS_FLAG == 1
447 int (*getFlag) ( void* pIO );
448#endif
449
451
458// --------------------------------------------------------------------------------------------------------------------
459typedef enum
460// --------------------------------------------------------------------------------------------------------------------
461{
466
471
476
481
486
492
499// --------------------------------------------------------------------------------------------------------------------
500typedef struct
501// --------------------------------------------------------------------------------------------------------------------
502{
507
512
517
522
527
531 char TFast;
532
534
535
544L6474_Handle_t L6474_CreateInstance(L6474x_Platform_t* p, void* pIO, void* pGPO, void* pPWM);
545
553
554
569
578
585char L6474_EncodePhaseCurrent(float mA);
586
596
609
623
636
650
663
664
677
690int L6474_StepIncremental(L6474_Handle_t h, int steps );
691
703
715int L6474_IsMoving(L6474_Handle_t h, int* moving);
716
731
745int L6474_GetProperty(L6474_Handle_t h, L6474_Property_t prop, int* value);
746
758int L6474_GetAbsolutePosition(L6474_Handle_t h, int* position);
759
771int L6474_SetAbsolutePosition(L6474_Handle_t h, int position);
772
785int L6474_GetElectricalPosition(L6474_Handle_t h, int* position);
786
800
812int L6474_GetPositionMark(L6474_Handle_t h, int* position);
813
825int L6474_SetPositionMark(L6474_Handle_t h, int position);
826
838int L6474_GetAlarmEnables(L6474_Handle_t h, int* bits);
839
852
853
1013
1033
1034 #endif /* INC_LIBL6474_H_ */
int L6474_SetBaseParameter(L6474_BaseParameter_t *p)
Definition LibL6474x.c:563
int L6474_IsMoving(L6474_Handle_t h, int *moving)
Definition LibL6474x.c:727
int L6474_SetAbsolutePosition(L6474_Handle_t h, int position)
Definition LibL6474x.c:888
int L6474_SetPowerOutputs(L6474_Handle_t h, int ena)
Definition LibL6474x.c:819
int L6474_SetElectricalPosition(L6474_Handle_t h, int position)
Definition LibL6474x.c:953
int L6474_SetPositionMark(L6474_Handle_t h, int position)
Definition LibL6474x.c:1021
int L6474_GetAbsolutePosition(L6474_Handle_t h, int *position)
Definition LibL6474x.c:851
enum L6474x_ErrorCode L6474x_ErrorCode_t
struct L6474_Handle * L6474_Handle_t
Definition LibL6474.h:258
int L6474_GetStepMode(L6474_Handle_t h, L6474x_StepMode_t *mode)
Definition LibL6474x.c:782
int L6474_GetAlarmEnables(L6474_Handle_t h, int *bits)
Definition LibL6474x.c:1053
int L6474_DestroyInstance(L6474_Handle_t h)
Definition LibL6474x.c:496
int L6474_GetPositionMark(L6474_Handle_t h, int *position)
Definition LibL6474x.c:985
int L6474_GetStatus(L6474_Handle_t h, L6474_Status_t *status)
Definition LibL6474x.c:1183
enum L6474x_Direction L6474x_Direction_t
int L6474_GetElectricalPosition(L6474_Handle_t h, int *position)
Definition LibL6474x.c:920
int L6474_GetProperty(L6474_Handle_t h, L6474_Property_t prop, int *value)
Definition LibL6474x.c:1118
int L6474_Initialize(L6474_Handle_t h, L6474_BaseParameter_t *p)
Definition LibL6474x.c:601
L6474_Property_t
Definition LibL6474.h:461
@ L6474_PROP_ADC_OUT
Definition LibL6474.h:480
@ L6474_PROP_OCDTH
Definition LibL6474.h:485
@ L6474_PROP_TOFF
Definition LibL6474.h:475
@ L6474_PROP_TFAST
Definition LibL6474.h:490
@ L6474_PROP_TORQUE
Definition LibL6474.h:465
@ L6474_PROP_TON
Definition LibL6474.h:470
L6474_Handle_t L6474_CreateInstance(L6474x_Platform_t *p, void *pIO, void *pGPO, void *pPWM)
Definition LibL6474x.c:440
enum L6474x_StepMode L6474x_StepMode_t
int L6474_ResetStandBy(L6474_Handle_t h)
Definition LibL6474x.c:521
int L6474_SetStepMode(L6474_Handle_t h, L6474x_StepMode_t mode)
Definition LibL6474x.c:744
int L6474_EncodePhaseCurrentParameter(L6474_BaseParameter_t *p, float mA)
Definition LibL6474x.c:591
int L6474_SetAlarmEnables(L6474_Handle_t h, int bits)
Definition LibL6474x.c:1151
int L6474_StepIncremental(L6474_Handle_t h, int steps)
Definition LibL6474x.c:1283
L6474x_Direction
Definition LibL6474.h:99
@ dirBACKWARD
Definition LibL6474.h:108
@ dirFOREWARD
Definition LibL6474.h:103
L6474x_ErrorCode
Definition LibL6474.h:118
@ errcLOCKING
Definition LibL6474.h:150
@ errcNONE
Definition LibL6474.h:122
@ errcINV_ARG
Definition LibL6474.h:127
@ errcINTERNAL
Definition LibL6474.h:143
@ errcPENDING
Definition LibL6474.h:161
@ errcDEVICE_STATE
Definition LibL6474.h:155
@ errcINV_STATE
Definition LibL6474.h:138
@ errcNULL_ARG
Definition LibL6474.h:132
@ errcFORBIDDEN
Definition LibL6474.h:166
enum L6474x_OCD_TH L6474x_OCD_TH_t
char L6474_EncodePhaseCurrent(float mA)
Definition LibL6474x.c:581
int L6474_GetState(L6474_Handle_t h, L6474x_State_t *state)
Definition LibL6474x.c:1227
struct L6474x_Platform L6474x_Platform_t
int L6474_StopMovement(L6474_Handle_t h)
Definition LibL6474x.c:1242
L6474x_State
Definition LibL6474.h:28
@ stRESET
Definition LibL6474.h:33
@ stDISABLED
Definition LibL6474.h:39
@ stENABLED
Definition LibL6474.h:45
@ stINVALID
Definition LibL6474.h:52
int L6474_SetProperty(L6474_Handle_t h, L6474_Property_t prop, int value)
Definition LibL6474x.c:1086
enum L6474x_State L6474x_State_t
L6474x_OCD_TH
Definition LibL6474.h:233
L6474x_StepMode
Definition LibL6474.h:65
@ smMICRO8
Definition LibL6474.h:85
@ smHALF
Definition LibL6474.h:75
@ smMICRO4
Definition LibL6474.h:80
@ smMICRO16
Definition LibL6474.h:90
@ smFULL
Definition LibL6474.h:70
struct L6474_Status L6474_Status_t
Definition LibL6474.h:502
char TorqueVal
Definition LibL6474.h:526
L6474x_OCD_TH_t OcdTh
Definition LibL6474.h:511
char TFast
Definition LibL6474.h:531
char TimeOnMin
Definition LibL6474.h:516
L6474x_StepMode_t stepMode
Definition LibL6474.h:506
char TimeOffMin
Definition LibL6474.h:521
Definition LibL6474x.c:148
Definition LibL6474.h:178
unsigned char WRONG_CMD
Definition LibL6474.h:197
unsigned char UVLO
Definition LibL6474.h:202
unsigned char TH_SD
Definition LibL6474.h:212
unsigned char NOTPERF_CMD
Definition LibL6474.h:192
unsigned char ONGOING
Definition LibL6474.h:222
unsigned char OCD
Definition LibL6474.h:217
unsigned char DIR
Definition LibL6474.h:187
unsigned char TH_WARN
Definition LibL6474.h:207
unsigned char HIGHZ
Definition LibL6474.h:182
Definition LibL6474.h:269
int(* step)(void *pPWM, int dir, unsigned int numPulses)
Definition LibL6474.h:387
int(* transfer)(void *pIO, char *pRX, const char *pTX, unsigned int length)
Definition LibL6474.h:327
void(* sleep)(unsigned int ms)
Definition LibL6474.h:360
void(* free)(const void *const pMem)
Definition LibL6474.h:303
void(* reset)(void *pGPO, const int ena)
Definition LibL6474.h:345