#include <hall-switch.hpp>
typedef void(* HallSwitch::CBack_t) (Result_t) |
Callback function type for interrupt mode.
- Parameters
-
[in] | Result_t | B field value. The interrupt read the B field value and will pass it to the callback |
- Returns
- void
Enumerator |
---|
OK |
No error
|
INTF_ERROR |
Interface error
|
CONF_ERROR |
Configuration error
|
Enumerator |
---|
MAIN |
Same as MCU VDD supply signal
|
SWITCH |
Switched controlled power from MCU
|
Enumerator |
---|
UNINITED |
Not initialized
|
INITED |
Initialized (external interfaces initialized)
|
POWER_ON |
Power on
|
POWER_OFF |
Power off
|
Enumerator |
---|
POLLING |
Polling mode
|
INTERRUPT |
Interrupt mode
|
Enumerator |
---|
B_FIELD_UNDEF |
Output default high. Undefined at initialization
|
B_FIELD_OFF |
No magnetic field present. Off. Q output high
|
B_FIELD_ON |
Magnetic field present. On. Q output low
|
HallSwitch::HallSwitch |
( |
| ) |
|
Hall Switch Default Constructor.
- Hardware interfaces pointers set to NULL
- Default modes polling (for measure mode) and main (for switch power mode)
- Precondition
- None
HallSwitch::HallSwitch |
( |
GPIO * |
output, |
|
|
CBack_t |
cBack = NULL , |
|
|
GPIO * |
power = NULL |
|
) |
| |
Hall Switch Constructor.
Mandatory arguments:
- Sensor output GPIO pointer
Optional arguments:
- 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] | cBack | Callback for interrupt mode. When passed, it enables interrupt mode |
[in] | *power | Sensor switch power controller GPIO interface pointer. Default NULL will set power mode to MAIN |
- Precondition
- None
HallSwitch::~HallSwitch |
( |
| ) |
|
Hall Switch Destructor Disables the sensor:
- 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()
-
Instance has called disable() if enable() was called
- 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 instance magnetic field value.
- Magnetic field present if the GPIO voltage level is low
- Mangnetic field not present if the GPIO voltage level is high
The "bfieldVal" object member is updated with the read GPIO value.
- Precondition
- Instance has called enable()
- Returns
- HallSwitch error code
- Return values
-
OK | if success |
INTF_ERROR | if hardware interface error |
Gets magnetic field.
This functions returns the last read value updated in the object member bfieldVal variable, either from a explicit updateBField() call or due to an interrupt event.
- Precondition
- If polling mode is used, updateBField() has to be called preivously in order to get the actual value.
- Returns
- HallSwitch Result_t magnetic field value
- Return values
-
B_FIELD_ON | if magnetic field present |
B_FIELD_OFF | if magnetic field NOT present |
void HallSwitch::callback |
( |
| ) |
|
|
protectedvirtual |
Interrupt mode callback function.
The instance updates on its own bfieldVal member when the interrupt occurs.
Additionally, the user callback function is executed.
- Returns
- void
Reimplemented in HallSpeed.
Output GPIO hardware interface pointer
Power switch controller mode GPIO hardware interface pointer
The documentation for this class was generated from the following files: