Hall Switch  2.1.0
C++ library of Infineon single Hall-effect switch family for magnetic sensing applications
HallSpeed Class Reference

#include <hall-speed.hpp>

Inheritance diagram for HallSpeed:
Collaboration diagram for HallSpeed:

Classes

class  Timer
 

Public Types

typedef void(* CBackSpd_t) (double)
 Callback function type for interrupt mode. More...
 
Speed units
enum  SpeedUnit_t { HERTZ = 0, RADS = 1, RPM = 2 }
 
- Public Types inherited from HallSwitch
typedef void(* CBack_t) (Result_t)
 Callback function type for interrupt mode. More...
 
enum  Error_t { OK = 0, INTF_ERROR = -1, CONF_ERROR = -2 }
 
enum  PowerMode_t { MAIN = 1, SWITCH = 2 }
 
enum  Status_t { UNINITED = 0, INITED = 1, POWER_ON = 2, POWER_OFF = 3 }
 
enum  MeasMode_t { POLLING = 1, INTERRUPT = 2 }
 
enum  Result_t { B_FIELD_UNDEF = -1, B_FIELD_OFF = 0, B_FIELD_ON = 1 }
 

Public Member Functions

 HallSpeed ()
 Hall Speed Default Constructor. More...
 
 HallSpeed (GPIO *output, Timer *timer, uint8_t polesNum=1, SpeedUnit_t units=HERTZ, CBackSpd_t cBack=NULL, GPIO *power=NULL)
 Hall Speed Constructor. More...
 
 ~HallSpeed ()
 Hall Speed Destructor Disables the sensor: More...
 
Error_t init ()
 Initializes the hardware interfaces. More...
 
Error_t deinit ()
 Deinitializes the hardware interfaces. More...
 
Error_t enable ()
 Enables the sensor. More...
 
Error_t disable ()
 Disables the sensor. More...
 
Error_t updateSpeed ()
 Updates the instance speed value. More...
 
double getSpeed ()
 Gets speed value. More...
 
- Public Member Functions inherited from HallSwitch
 HallSwitch ()
 Hall Switch Default Constructor. More...
 
 HallSwitch (GPIO *output, CBack_t cBack=NULL, GPIO *power=NULL)
 Hall Switch Constructor. More...
 
 ~HallSwitch ()
 Hall Switch Destructor Disables the sensor: More...
 
Error_t init ()
 Initializes the hardware interfaces. More...
 
Error_t deinit ()
 Deinitializes the hardware interfaces. More...
 
Error_t enable ()
 Enables the sensor. More...
 
Error_t disable ()
 Disables the sensor. More...
 
Status_t getStatus ()
 Gets the sensor status. More...
 
Error_t updateBField ()
 Updates instance magnetic field value. More...
 
Result_t getBField ()
 Gets magnetic field. More...
 

Protected Member Functions

void callback ()
 Interrupt mode callback function. More...
 
void calculateSpeed ()
 Calculates the speed in the configured units. More...
 

Protected Attributes

Timertimer
 
uint8_t polesPair
 
SpeedUnit_t sUnits
 
double speed
 
- Protected Attributes inherited from HallSwitch
Status_t status
 
GPIOoutput
 
Result_t bfieldVal
 
CBack_t cBack
 
MeasMode_t measMode
 
GPIOpower
 
PowerMode_t powerMode
 

Static Protected Attributes

static double const speedCoeff [3]
 

Member Typedef Documentation

typedef void(* HallSpeed::CBackSpd_t) (double)

Callback function type for interrupt mode.

Parameters
[in]speedThe new speed change.
Returns
void

Member Enumeration Documentation

Enumerator
HERTZ 

cps - Hertz

RADS 

rads/s

RPM 

RPM

Constructor & Destructor Documentation

HallSpeed::HallSpeed ( )

Hall Speed Default Constructor.

  • Hardware interfaces pointers set to NULL
  • All speed parameters set to zero
    Precondition
    None
HallSpeed::HallSpeed ( GPIO output,
Timer timer,
uint8_t  polesNum = 1,
SpeedUnit_t  units = HERTZ,
CBackSpd_t  cBack = NULL,
GPIO power = NULL 
)

Hall Speed Constructor.

Mandatory arguments:

  • Sensor utput GPIO PAL interface pointer
  • Timer PAL interface pointer

Optional arguments:

  • Magnetic poles pair number. By default 1 pair.
  • Speed units. By default Hertzs.
  • Interrupt callback. By default NULL. Required to enable interrupt mode.
  • Sensor power GPIO pointer (only for switch powered mode platform). By default it is NULL.
Parameters
[in]*outputSensor output GPIO interface pointer
[in]polesMumNumber of magnetic poles pair of the rotating B field
[in]unitsSpeed units (RPM, Hertz, cps ...)
[in]cBackCallback for interrupt mode. When passed, it enables interrupt mode
[in]*powerSensor switch power controlled GPIO interface pointer. Default NULL will set power mode to MAIN
Precondition
None
HallSpeed::~HallSpeed ( )

Hall Speed Destructor Disables the sensor:

  • Stops and disables the timer interface.
  • Stops and disable the GPIO interface.
  • If "interrupt measuring mode" is enabled, the interrupt is disabled
  • If "switch power mode" is configured, the sensor power is disabled
    Precondition
    None

Here is the call graph for this function:

Member Function Documentation

HallSwitch::Error_t HallSpeed::init ( )

Initializes the hardware interfaces.

Precondition
None
Returns
HallSwitch error code
Return values
OKif success
INTF_ERRORif hardware interface error

Here is the call graph for this function:

HallSwitch::Error_t HallSpeed::deinit ( )

Deinitializes the hardware interfaces.

Precondition
Instance has called init()
Returns
HallSwitch error code
Return values
OKif success
INTF_ERRORif hardware interface error

Here is the call graph for this function:

HallSwitch::Error_t HallSpeed::enable ( )

Enables the sensor.

  • If "switch power mode " is configured, the sensor is powered up
  • If "interrupt measuring mode" is configured, the interrupt is enabled
Precondition
Instance has called init()
Returns
HallSwitch error code
Return values
OKif success
INTF_ERRORif hardware interface error

Here is the call graph for this function:

HallSwitch::Error_t HallSpeed::disable ( )

Disables the sensor.

  • If the "interrupt measuring mode" is configured, the interrupt is disabled
  • If the "switch power mode" is configured, the sensor is powered off
Precondition
Instance has called enable()
Returns
HallSwitch error code
Return values
OKif success
INTF_ERRORif hardware interface error

Here is the call graph for this function:

HallSwitch::Error_t HallSpeed::updateSpeed ( )

Updates the instance speed value.

The speed instance member is updated with the read value.

Precondition
Instance has called enable()
Returns
HallSwitch error code
Return values
OKif success
INTF_ERRORif hardware interface error

Here is the call graph for this function:

double HallSpeed::getSpeed ( )

Gets speed value.

This functions returns the last read value updated in the object member speed variable, either from a explicit updateSpeed() call or due to an interrupt event.

Precondition
If polling mode is used, updateSpeed() has to be called preivously in order to get the actual value.
Returns
Speed value
void HallSpeed::callback ( )
protectedvirtual

Interrupt mode callback function.

The class updates on its own speed member to the when the interrupt occurs Passed as interrupt callback handler.

Returns
void

Reimplemented from HallSwitch.

Here is the call graph for this function:

void HallSpeed::calculateSpeed ( )
protected

Calculates the speed in the configured units.

Called by updateSpeed() or in the callback() interrupt to update the object speed member variable.

Returns
void

Here is the call graph for this function:

Member Data Documentation

Timer* HallSpeed::timer
protected

Timer interface pointer

uint8_t HallSpeed::polesPair
protected

Rotor poles pair number

SpeedUnit_t HallSpeed::sUnits
protected

Speed units

double HallSpeed::speed
protected

Rotating speed

double const HallSpeed::speedCoeff
staticprotected
Initial value:
=
{
1000.0,
6283.2,
60000.0
}

The documentation for this class was generated from the following files: