Skip to content

File syn_comp.h

FileList > drivers > syn_comp.h

Go to the source code of this file

High-Speed Rail-to-Rail Analog Comparator Driver. More...

  • #include "../common/syn_defs.h"
  • #include "../port/syn_port_comp.h"
  • #include <stdbool.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_COMP
Analog Comparator handle. Caller allocates; zero heap.

Public Functions

Type Name
SYN_Status syn_comp_enable (SYN_COMP * comp, bool enable)
Enable or disable the analog comparator.
SYN_Status syn_comp_init (SYN_COMP * comp, uint8_t comp_id, SYN_COMP_InvertingInput inv_in)
Initialize an Analog Comparator instance.
bool syn_comp_read (const SYN_COMP * comp)
Read real-time logical output state of the comparator.

Detailed Description

Provides a vendor-agnostic, zero-allocation OS interface for internal analog comparators with configurable voltage reference thresholds (VREFINT 1.23V, DAC, or external).

Usage:

SYN_COMP comp;
syn_comp_init(&comp, 0, SYN_COMP_INV_VREFINT); // COMP1 vs 1.23V VREFINT
syn_comp_enable(&comp, true);
bool state = syn_comp_read(&comp);             // True if PA1 > 1.23V

Public Functions Documentation

function syn_comp_enable

Enable or disable the analog comparator.

SYN_Status syn_comp_enable (
    SYN_COMP * comp,
    bool enable
) 

Parameters:

  • comp Initialized comparator handle.
  • enable true to enable, false to disable.

Returns:

SYN_OK on success.


function syn_comp_init

Initialize an Analog Comparator instance.

SYN_Status syn_comp_init (
    SYN_COMP * comp,
    uint8_t comp_id,
    SYN_COMP_InvertingInput inv_in
) 

Parameters:

  • comp Handle to initialize. Must not be NULL.
  • comp_id Comparator hardware index (0 = COMP1, 1 = COMP2).
  • inv_in Reference threshold input source.

Returns:

SYN_OK on success, SYN_INVALID_PARAM on invalid argument.


function syn_comp_read

Read real-time logical output state of the comparator.

bool syn_comp_read (
    const SYN_COMP * comp
) 

Parameters:

  • comp Initialized comparator handle.

Returns:

true if non-inverting input voltage > inverting reference voltage.



The documentation for this class was generated from the following file src/syntropic/drivers/syn_comp.h