You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
134 lines
4.2 KiB
134 lines
4.2 KiB
/*
|
|
* Copyright (c) 2021, Erich Styger
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#ifndef __QuadCounter_H
|
|
#define __QuadCounter_H
|
|
|
|
#include "McuLib.h" /* SDK and API used */
|
|
//#include "QuadCounterconfig.h" /* configuration */
|
|
#include "McuShell.h"
|
|
|
|
|
|
#define QuadCounter_SWAP_PINS 0 /* 1: C1 and C2 are swapped */
|
|
#define QuadCounter_SWAP_PINS_AT_RUNTIME 1 /* 1: C1 and C2 are swapped at runtime, if SwapPins() method is available */
|
|
|
|
typedef uint32_t QuadCounter_QuadCntrType;
|
|
|
|
#define QuadCounter_PARSE_COMMAND_ENABLED 1 /* set to 1 if method ParseCommand() is present, 0 otherwise */
|
|
|
|
void QuadCounter_SetPosLeft(QuadCounter_QuadCntrType pos);
|
|
void QuadCounter_SetPosRight(QuadCounter_QuadCntrType pos);
|
|
|
|
void QuadCounter_SwapPinsLeft(bool swap);
|
|
void QuadCounter_SwapPinsRight(bool swap);
|
|
|
|
uint32_t QuadCounter_GetErrorsLeft(void);
|
|
uint32_t QuadCounter_GetErrorsRight(void);
|
|
|
|
void QuadCounter_EnablePullups(void);
|
|
|
|
/*
|
|
** ===================================================================
|
|
** Method : SetPos (component QuadCounter)
|
|
**
|
|
** Description :
|
|
** Sets the position information. Can be used as well to reset
|
|
** the position information.
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** pos - Position value to be set.
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
QuadCounter_QuadCntrType QuadCounter_GetPosLeft(void);
|
|
QuadCounter_QuadCntrType QuadCounter_GetPosRight(void);
|
|
/*
|
|
** ===================================================================
|
|
** Method : GetPos (component QuadCounter)
|
|
**
|
|
** Description :
|
|
** Returns the current position based on the encoder tracking.
|
|
** Parameters : None
|
|
** Returns :
|
|
** --- - position
|
|
** ===================================================================
|
|
*/
|
|
|
|
void QuadCounter_Sample(void);
|
|
/*
|
|
** ===================================================================
|
|
** Method : Sample (component QuadCounter)
|
|
**
|
|
** Description :
|
|
** Call this method to periodically sample the signals.
|
|
** Parameters : None
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void QuadCounter_Deinit(void);
|
|
/*
|
|
** ===================================================================
|
|
** Method : Deinit (component QuadCounter)
|
|
**
|
|
** Description :
|
|
** Module de-initialization method
|
|
** Parameters : None
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
void QuadCounter_Init(void);
|
|
/*
|
|
** ===================================================================
|
|
** Method : Init (component QuadCounter)
|
|
**
|
|
** Description :
|
|
** Module initialization method
|
|
** Parameters : None
|
|
** Returns : Nothing
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t QuadCounter_ParseCommand(const unsigned char *cmd, bool *handled, const McuShell_StdIOType *io);
|
|
/*
|
|
** ===================================================================
|
|
** Method : ParseCommand (component QuadCounter)
|
|
**
|
|
** Description :
|
|
** Handler to process shell commands
|
|
** Parameters :
|
|
** NAME - DESCRIPTION
|
|
** cmd - Command string to be parsed
|
|
** * handled - Pointer to boolean. The handler
|
|
** sets this variable to TRUE if command was
|
|
** handled, otherwise let it untouched.
|
|
** io - Pointer to I/O structure
|
|
** Returns :
|
|
** --- - Error code
|
|
** ===================================================================
|
|
*/
|
|
|
|
uint8_t QuadCounter_GetValLeft(void);
|
|
uint8_t QuadCounter_GetValRight(void);
|
|
/*
|
|
** ===================================================================
|
|
** Method : GetVal (component QuadCounter)
|
|
**
|
|
** Description :
|
|
** Returns the quadrature value (0, 1, 2 or 3)
|
|
** Parameters : None
|
|
** Returns :
|
|
** --- - Quadrature value (0-3)
|
|
** ===================================================================
|
|
*/
|
|
|
|
#endif
|
|
/* ifndef __QuadCounter_H */
|
|
/*!
|
|
** @}
|
|
*/
|
|
|