#include <hall-switch.hpp>
◆ CBack_t
| 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
◆ Error_t
| Enumerator |
|---|
| OK | No error
|
| INTF_ERROR | Interface error
|
| CONF_ERROR | Configuration error
|
◆ PowerMode_t
| Enumerator |
|---|
| MAIN | Same as MCU VDD supply signal
|
| SWITCH | Switched controlled power from MCU
|
◆ Status_t
| Enumerator |
|---|
| UNINITED | Not initialized
|
| INITED | Initialized (external interfaces initialized)
|
| POWER_ON | Power on
|
| POWER_OFF | Power off
|
◆ MeasMode_t
| Enumerator |
|---|
| POLLING | Polling mode
|
| INTERRUPT | Interrupt mode
|
◆ Result_t
| 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() [1/2]
| 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() [2/2]
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::~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
◆ init()
Initializes the hardware interfaces.
- Precondition
- None
- Returns
- HallSwitch error code
- Return values
-
| OK | if success |
| INTF_ERROR | if hardware interface error |
◆ deinit()
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 |
◆ 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
-
| OK | if success |
| INTF_ERROR | if hardware interface error
|
◆ 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
-
| OK | if success |
| INTF_ERROR | if hardware interface error
|
◆ getStatus()
◆ updateBField()
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
|
◆ getBField()
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 |
◆ callback()
| 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.
◆ status
◆ output
Output GPIO hardware interface pointer
◆ bfieldVal
◆ cBack
◆ measMode
◆ power
Power switch controller mode GPIO hardware interface pointer
◆ powerMode
The documentation for this class was generated from the following files: