#include <hall-speed.hpp>
|
typedef void(* | CBackSpd_t) (double) |
| Callback function type for interrupt mode. More...
|
|
|
enum | SpeedUnit_t { HERTZ = 0,
RADS = 1,
RPM = 2
} |
|
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
} |
|
typedef void(* HallSpeed::CBackSpd_t) (double) |
Callback function type for interrupt mode.
- Parameters
-
[in] | speed | The new speed change. |
- Returns
- void
Enumerator |
---|
HERTZ |
cps - Hertz
|
RADS |
rads/s
|
RPM |
RPM
|
Hall Speed Default Constructor.
- Hardware interfaces pointers set to NULL
- All speed parameters set to zero
- Precondition
- None
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] | *output | Sensor output GPIO interface pointer |
[in] | polesMum | Number of magnetic poles pair of the rotating B field |
[in] | units | Speed units (RPM, Hertz, cps ...) |
[in] | cBack | Callback for interrupt mode. When passed, it enables interrupt mode |
[in] | *power | Sensor 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
Initializes the hardware interfaces.
- Precondition
- None
- Returns
- HallSwitch error code
- Return values
-
OK | if success |
INTF_ERROR | if hardware interface error |
Deinitializes the hardware interfaces.
- Precondition
- Instance has called init()
- Returns
- HallSwitch error code
- Return values
-
OK | if success |
INTF_ERROR | if hardware interface error |
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
-
OK | if success |
INTF_ERROR | if hardware interface error |
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
-
OK | if success |
INTF_ERROR | if hardware interface error |
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
-
OK | if success |
INTF_ERROR | if hardware interface error |
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.
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
uint8_t HallSpeed::polesPair |
|
protected |
double const HallSpeed::speedCoeff |
|
staticprotected |
Initial value:=
{
1000.0,
6283.2,
60000.0
}
The documentation for this class was generated from the following files: