Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
COMP Class Reference

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 COMPgetInstance ()
 

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ COMP() [1/2]

COMP::COMP ( )
private

◆ COMP() [2/2]

COMP::COMP ( COMP const &  )
private

Member Function Documentation

◆ applyWorkarounds()

void COMP::applyWorkarounds ( )
inlineprivate

Apply work arounds that are suggested by Nordic.

For the NRF52 PAN 12 refers to COMP.

  • PAN 12 COMP: Reference ladder is not correctly calibrated

◆ getInstance()

static COMP & COMP::getInstance ( )
inlinestatic

◆ handleEvent()

void COMP::handleEvent ( nrf_comp_event_t  event)

Internal usage.

Handle a comparator event, in interrupt.

◆ handleEventDecoupled()

void COMP::handleEventDecoupled ( nrf_comp_event_t  event)

Internal usage.

Handle a comparator event, on main thread.

◆ init()

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

Parameters
[in]ainPinAn analog input pin: so for pin AIN6 the value should be 6.
[in]thresholdDownThreshold to be triggered when input drops below a certain value.
[in]thresholdUpThreshold to be triggered when input goes beyond a certain value.
[in]callbackThe function to be called when the value goes over/under the threshold. Use null pointer for none.

◆ operator=()

void COMP::operator= ( COMP const &  )
private

◆ sample()

bool COMP::sample ( )

Sample the comparator.

Returns
True when the value is above the threshold, false when below.

◆ start()

void COMP::start ( CompEvent_t  event)

Start the comparator.

Parameters
[in]eventSelects which events to get.

Member Data Documentation

◆ _callback

comp_event_cb_t COMP::_callback = nullptr
private

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