TLx4966 Direction Speed Sensor  1.1.1
C/C++ library of Infineons double Hall-effect direction and speed sensor TLx4966(K)/(G)/(L)/(V) family for magnetic sensing applications.

Functions

void TLx4966_Config (TLx4966_Handle_t *handle, uint8_t polesPair, TLx4966_PowerMode_t powMode, TLx4966_MeasMode_t measMode, TLx4966_SpeedUnit_t speedUnit, TLx4966_HwIntf_t *hwIntf)
 Configures the sensor handle attributes Mandatory hw interfaces: dir, speed, timer. Optional hw interfaces: power (only for switch mode platform). More...
 
TLx4966_Error_t TLx4966_Init (TLx4966_Handle_t *handle)
 Initilializes the hardware interfaces. More...
 
STATIC void TLx4966_DirectionCallback (TLx4966_Handle_t *handle)
 Direction interrupt callback The sensor instance direction is updated upon interrupt event: rising or falling edge. More...
 
STATIC INLINE void TLx4966_CalculateSpeed (TLx4966_Handle_t *handle)
 Calculates the speed. More...
 
STATIC void TLx4966_SpeedCallback (TLx4966_Handle_t *handle)
 Speed interrupt callback The sensor instance instant speed is updated upon rising edge. More...
 
TLx4966_Error_t TLx4966_Enable (TLx4966_Handle_t *handle)
 Enables the sensor. More...
 
TLx4966_Error_t TLx4966_Disable (TLx4966_Handle_t *handle)
 Disables the sensor. More...
 
void TLx4966_UpdateSpeed (TLx4966_Handle_t *handle)
 Updates the sensor speed. A rising edge is detected when the gpio voltage level changes from low to high. More...
 
INLINE void TLx4966_UpdateDirection (TLx4966_Handle_t *handle)
 Updates the rotation direction A rising edge is detected when the gpio voltage level changes from low to high. More...
 
INLINE void TLx4966_UpdateValues (TLx4966_Handle_t *handle)
 Updates the rotation direction and speed. More...
 
INLINE void TLx4966_GetValues (TLx4966_Handle_t *handle, TLx4966_Params_t *params)
 Gets the rotation direction and speed parameters. More...
 
INLINE TLx4966_Status_t TLx4966_GetStatus (TLx4966_Handle_t *handle)
 Gets the sensor status. More...
 
INLINE double TLx4966_GetSpeed (TLx4966_Handle_t *handle)
 Gets the rotation speed. More...
 
INLINE TLx4966_Dir_t TLx4966_GetDirection (TLx4966_Handle_t *handle)
 Gets the rotation direction The direction definition (clock-wise/anticlock-wise, left/rigth, positive/negative...) is dependant of the mechanical configuration of the sensor with repect to the rotor. The library just provide voltage-low/voltage-high directions. More...
 

Variables

STATIC double TLx4966_SpeedCoeffient [3]
 Look-up array for Speed Unit Coeffients. More...
 

Detailed Description

Function Documentation

◆ TLx4966_CalculateSpeed()

STATIC INLINE void TLx4966_CalculateSpeed ( TLx4966_Handle_t handle)

Calculates the speed.

The rising edge of the speed GPIO signal determines the rotating period between a pair of poles. The speed is then obtained by applying the selected speed unit product coefficient, and dividing between the number of poles pairs.

Note
To be called upon speed GPIO rising edge.
Parameters
[in]handlePointer to the sensor entity handle
Returns
void

◆ TLx4966_Config()

void TLx4966_Config ( TLx4966_Handle_t handle,
uint8_t  polesPair,
TLx4966_PowerMode_t  powMode,
TLx4966_MeasMode_t  measMode,
TLx4966_SpeedUnit_t  speedUnit,
TLx4966_HwIntf_t hwIntf 
)

Configures the sensor handle attributes Mandatory hw interfaces: dir, speed, timer. Optional hw interfaces: power (only for switch mode platform).

Parameters
[in,out]*handlePointer to the sensor instance handle
[in]polesPairRotor poles pair number
[in]powModePower mode
[in]measModeMeasuring mode
[in]speedUnitSpeed unit
[in]*hwIntfPointer to hardware interface handle
Returns
void

◆ TLx4966_DirectionCallback()

STATIC void TLx4966_DirectionCallback ( TLx4966_Handle_t handle)

Direction interrupt callback The sensor instance direction is updated upon interrupt event: rising or falling edge.

Parameters
[in]handlePointer to the sensor entity handle
Returns
void

◆ TLx4966_Disable()

TLx4966_Error_t TLx4966_Disable ( TLx4966_Handle_t handle)

Disables the sensor.

  • If the "Interrupt measuring mode" is configured, the interrupt are enabled.
  • If the "Switch power mode" is configured, the sensor is powered off.
  • The measuring speed timer is stopped.
Parameters
[in]handlePointer to the sensor entity handle
Returns
TLx4966 error code
Return values
TLx4966_OKif success
TLx4966_INTF_ERRORif hardware interface error

◆ TLx4966_Enable()

TLx4966_Error_t TLx4966_Enable ( TLx4966_Handle_t handle)

Enables the sensor.

  • If the "Switch power mode" is configured, the sensor is powered up.
  • If the "Interrupt measuring mode" is configured, the interrupt are enabled.
  • The measuring speed timer is started.
Parameters
[in]handlePointer to the sensor entity handle
Returns
TLx4966 error code
Return values
TLx4966_OKif success
TLx4966_INTF_ERRORif hardware interface error

◆ TLx4966_GetDirection()

INLINE TLx4966_Dir_t TLx4966_GetDirection ( TLx4966_Handle_t handle)

Gets the rotation direction The direction definition (clock-wise/anticlock-wise, left/rigth, positive/negative...) is dependant of the mechanical configuration of the sensor with repect to the rotor. The library just provide voltage-low/voltage-high directions.

Parameters
[in]handlePointer to the sensor entity handle
Returns
TLx4966 direction
Return values
TLx4966_DIR_UNDEFprior initial rotor movement (after initialization)

◆ TLx4966_GetSpeed()

INLINE double TLx4966_GetSpeed ( TLx4966_Handle_t handle)

Gets the rotation speed.

Parameters
[in]handlePointer to the sensor entity handle
Returns
Speed in the unit specified in the configuration

◆ TLx4966_GetStatus()

INLINE TLx4966_Status_t TLx4966_GetStatus ( TLx4966_Handle_t handle)

Gets the sensor status.

Parameters
[in]handlePointer to the sensor entity handle
Returns
TLx4966 status

◆ TLx4966_GetValues()

INLINE void TLx4966_GetValues ( TLx4966_Handle_t handle,
TLx4966_Params_t params 
)

Gets the rotation direction and speed parameters.

Parameters
[in]handlePointer to the sensor entity handle
[out]*paramsPointer to the struct to store the parameter values
Returns
void

◆ TLx4966_Init()

TLx4966_Error_t TLx4966_Init ( TLx4966_Handle_t handle)

Initilializes the hardware interfaces.

Parameters
[in]handlePointer to the sensor entity handle
Returns
TLx4966 error code
Return values
TLx4966_OKif success
TLx4966_INTF_ERRORif hardware interface error

◆ TLx4966_SpeedCallback()

STATIC void TLx4966_SpeedCallback ( TLx4966_Handle_t handle)

Speed interrupt callback The sensor instance instant speed is updated upon rising edge.

Parameters
[in]handlePointer to the sensor entity handle
Returns
void

◆ TLx4966_UpdateDirection()

INLINE void TLx4966_UpdateDirection ( TLx4966_Handle_t handle)

Updates the rotation direction A rising edge is detected when the gpio voltage level changes from low to high.

Note
To be used in super-loop.
Parameters
[in]handlePointer to the sensor entity handle
Returns
void

◆ TLx4966_UpdateSpeed()

void TLx4966_UpdateSpeed ( TLx4966_Handle_t handle)

Updates the sensor speed. A rising edge is detected when the gpio voltage level changes from low to high.

Note
To be used in super-loop.
Parameters
[in]handlePointer to the sensor entity handle
Returns
void

◆ TLx4966_UpdateValues()

INLINE void TLx4966_UpdateValues ( TLx4966_Handle_t handle)

Updates the rotation direction and speed.

Note
To be used in super-loop.
Parameters
[in]handlePointer to the sensor entity handle
Returns
void

Variable Documentation

◆ TLx4966_SpeedCoeffient

STATIC double TLx4966_SpeedCoeffient[3]
Initial value:
=
{
}
#define TLx4966_SPEED_COEF_RADS
Definition: TLx4966-types.h:104
#define TLx4966_SPEED_COEF_RPM
Definition: TLx4966-types.h:105
#define TLx4966_SPEED_COEF_HZ
Definition: TLx4966-types.h:103

Look-up array for Speed Unit Coeffients.