Enumerations | Functions

Analog comparator (hal_ancmp)
[nRF24LE1 HAL]


The analog comparator allows a system wakeup to be triggered by the voltage level of a differential or single-ended analog input applied through the port pins.

This module also contains functions for configuring and enabling the comparator.

Enumerations

enum  hal_ancmp_input_channel_t {
  HAL_ANCMP_INP_AIN0 = 0x00, HAL_ANCMP_INP_AIN1 = 0x01, HAL_ANCMP_INP_AIN2 = 0x02, HAL_ANCMP_INP_AIN3 = 0x03,
  HAL_ANCMP_INP_AIN4 = 0x04, HAL_ANCMP_INP_AIN5 = 0x05, HAL_ANCMP_INP_AIN6 = 0x06, HAL_ANCMP_INP_AIN7 = 0x07,
  HAL_ANCMP_INP_AIN8 = 0x08, HAL_ANCMP_INP_AIN9 = 0x09, HAL_ANCMP_INP_AIN10 = 0x0A, HAL_ANCMP_INP_AIN11 = 0x0B,
  HAL_ANCMP_INP_AIN12 = 0x0C, HAL_ANCMP_INP_AIN13 = 0x0D
}
enum  hal_ancmp_pol_t { HAL_ANCMP_NON_INVERTING = 0x00, HAL_ANCMP_INVERTING = 0x01 }
enum  hal_ancmp_ref_scale_t { HAL_ANCMP_REF_SCALE_25 = 0x00, HAL_ANCMP_REF_SCALE_50 = 0x01, HAL_ANCMP_REF_SCALE_75 = 0x02, HAL_ANCMP_REF_SCALE_100 = 0x03 }
enum  hal_ancmp_ref_t { HAL_ANCMP_REF_VDD = 0x00, HAL_ANCMP_REF_EXT = 0x01 }

Functions

void hal_ancmp_set_polarity (hal_ancmp_pol_t polarity)
void hal_ancmp_set_ref_voltage_scale (hal_ancmp_ref_scale_t scale)
void hal_ancmp_set_reference (hal_ancmp_ref_t ref)
void hal_ancmp_set_input_channel (hal_ancmp_input_channel_t chsel)
void hal_ancmp_enable (_Bool en)

Enumeration Type Documentation

An enum describing the input channel of the analog comparator.

Enumerator:
HAL_ANCMP_INP_AIN0 
HAL_ANCMP_INP_AIN1 
HAL_ANCMP_INP_AIN2 
HAL_ANCMP_INP_AIN3 
HAL_ANCMP_INP_AIN4 
HAL_ANCMP_INP_AIN5 
HAL_ANCMP_INP_AIN6 
HAL_ANCMP_INP_AIN7 
HAL_ANCMP_INP_AIN8 
HAL_ANCMP_INP_AIN9 
HAL_ANCMP_INP_AIN10 
HAL_ANCMP_INP_AIN11 
HAL_ANCMP_INP_AIN12 
HAL_ANCMP_INP_AIN13 

Definition at line 36 of file hal_ancmp.h.

An enum describing the reference of the analog comparator.

Enumerator:
HAL_ANCMP_NON_INVERTING 

Non-inverting output polarity

HAL_ANCMP_INVERTING 

Inverting output polarity

Definition at line 56 of file hal_ancmp.h.

An enum describing the reference of the analog comparator.

Enumerator:
HAL_ANCMP_REF_SCALE_25 

Reference voltage scaling (25%)

HAL_ANCMP_REF_SCALE_50 

Reference voltage scaling (50%)

HAL_ANCMP_REF_SCALE_75 

Reference voltage scaling (75%)

HAL_ANCMP_REF_SCALE_100 

Reference voltage scaling (100%)

Definition at line 64 of file hal_ancmp.h.

An enum describing the reference of the analog comparator.

Enumerator:
HAL_ANCMP_REF_VDD 

VDD as reference

HAL_ANCMP_REF_EXT 

External reference

Definition at line 74 of file hal_ancmp.h.


Function Documentation

void hal_ancmp_set_polarity ( hal_ancmp_pol_t  polarity )

Function to set the output polarity. Use this function set the output polarity of the analog comparator.

Parameters:
polarityThe output polarity

Definition at line 25 of file hal_ancmp.c.

{ // Update "polarity" bit
  COMPCON = (COMPCON & 0xEF) | (((uint8_t)polarity << 4) & ~0xEF);   
}
void hal_ancmp_set_ref_voltage_scale ( hal_ancmp_ref_scale_t  scale )

Function to set the reference voltage scaling. Use this function to set reference voltage scaling of the analog comparator.

Parameters:
scaleThe reference voltage scaling

Definition at line 30 of file hal_ancmp.c.

{ // Update "refscale" bits
  COMPCON = (COMPCON & 0xF3) | (((uint8_t)scale << 2) & ~0xF3);   
}
void hal_ancmp_set_reference ( hal_ancmp_ref_t  ref )

Function to set the reference of the analog comparator. Use this function to set the reference of the analog comparator.

Parameters:
refThe reference of the analog comparator

Definition at line 35 of file hal_ancmp.c.

{ // Update "cmpref" bit
  COMPCON = (COMPCON & 0xFD) | (((uint8_t)ref << 1) & ~0xFD);   
}
void hal_ancmp_set_input_channel ( hal_ancmp_input_channel_t  chsel )

Function to set the input channel of the analog comparator. This function uses the ADC HAL to set the input channel of the analog comp.

Parameters:
chselThe input channel of the analog comparator

Definition at line 40 of file hal_ancmp.c.

void hal_ancmp_enable ( _Bool  en )

Function to enable the analog comparator. Use this function to enable the analog comparator.

Parameters:
enTrue to enable, false to disable the analog comparator

< The value of bit 0

< The value of bit 0

Definition at line 47 of file hal_ancmp.c.

{
  if(en)
  {
    COMPCON = COMPCON | BIT_0;                // Set "enable" bit
  }
  else
  {
    COMPCON = COMPCON & ~BIT_0;               // Clear "enable" bit
  }
}