Bluenet
5.7.0
Bluenet, firmware for nRF52 smart home devices
|
Class that enables you to get events when a the voltage on an AIN pin goes over or below a given threshold. More...
#include <cs_COMP.h>
Public Member Functions | |
void | init (uint8_t ainPin, float thresholdDown, float thresholdUp, comp_event_cb_t callback) |
The COMP unit gets initialized by indicating a pin. More... | |
void | start (CompEvent_t event) |
Start the comparator. More... | |
bool | sample () |
Sample the comparator. More... | |
void | handleEventDecoupled (nrf_comp_event_t event) |
Internal usage. More... | |
void | handleEvent (nrf_comp_event_t event) |
Internal usage. More... | |
Static Public Member Functions | |
static COMP & | getInstance () |
Private Member Functions | |
COMP () | |
COMP (COMP const &) | |
void | operator= (COMP const &) |
void | applyWorkarounds () |
Apply work arounds that are suggested by Nordic. More... | |
Private Attributes | |
comp_event_cb_t | _callback = nullptr |
Class that enables you to get events when a the voltage on an AIN pin goes over or below a given threshold.
There are 2 thresholds, as this class supports hysteresis.
|
private |
|
private |
|
inlineprivate |
|
inlinestatic |
void COMP::handleEvent | ( | nrf_comp_event_t | event | ) |
Internal usage.
Handle a comparator event, in interrupt.
void COMP::handleEventDecoupled | ( | nrf_comp_event_t | event | ) |
Internal usage.
Handle a comparator event, on main thread.
void COMP::init | ( | uint8_t | ainPin, |
float | thresholdDown, | ||
float | thresholdUp, | ||
comp_event_cb_t | callback | ||
) |
The COMP unit gets initialized by indicating a pin.
TODO: use const where appropriate TODO: use nrf_drv_comp_ain_to_gpio in implementation
[in] | ainPin | An analog input pin: so for pin AIN6 the value should be 6. |
[in] | thresholdDown | Threshold to be triggered when input drops below a certain value. |
[in] | thresholdUp | Threshold to be triggered when input goes beyond a certain value. |
[in] | callback | The function to be called when the value goes over/under the threshold. Use null pointer for none. |
|
private |
bool COMP::sample | ( | ) |
Sample the comparator.
void COMP::start | ( | CompEvent_t | event | ) |
Start the comparator.
[in] | event | Selects which events to get. |
|
private |