Analog comparator (AC) functions.
Copyright (c) 2010-2018 Microchip Technology Inc. and its subsidiaries.
#include <stdint.h>
#include "compiler.h"
#include "parts.h"
#include "status_codes.h"
#include "pmic.h"
Data Structures | |
struct | ac_config |
Analog comparator channel configuration struct. More... | |
Typedefs | |
typedef void(* | ac_callback_t )(AC_t *ac, uint8_t channel, enum ac_status_t status) |
Interrupt event callback function type. More... | |
Enumerations | |
enum | ac_int_level_t { AC_INT_LVL_OFF = 0x00, AC_INT_LVL_LO = 0x01, AC_INT_LVL_MED = 0x02, AC_INT_LVL_HI = 0x03 } |
Analog comparator interrupt levels. More... | |
enum | ac_interrupt_mode_t { AC_INT_MODE_BOTH_EDGES = AC_INTMODE_BOTHEDGES_gc, AC_INT_MODE_FALLING_EDGE = AC_INTMODE_FALLING_gc, AC_INT_MODE_RISING_EDGE = AC_INTMODE_RISING_gc, AC_INT_MODE_ABOVE_WINDOW = AC_WINTMODE_ABOVE_gc, AC_INT_MODE_INSIDE_WINDOW = AC_WINTMODE_INSIDE_gc, AC_INT_MODE_BELOW_WINDOW = AC_WINTMODE_BELOW_gc, AC_INT_MODE_OUTSIDE_WINDOW = AC_WINTMODE_OUTSIDE_gc } |
Analog comparator interrupt modes. More... | |
enum | ac_mode_t { AC_MODE_SINGLE, AC_MODE_WINDOW } |
Analog comparator modes. More... | |
enum | ac_status_t { AC_STATUS_ABOVE = AC_WSTATE_ABOVE_gc, AC_STATUS_BELOW = AC_WSTATE_BELOW_gc, AC_STATUS_INSIDE = AC_WSTATE_INSIDE_gc } |
Analog comparator status values. More... | |
Functions | |
Management functions | |
void | ac_write_config (AC_t *ac, uint8_t channel, struct ac_config *config) |
Write analog comparator configuration to hardware. More... | |
void | ac_read_config (AC_t *ac, uint8_t channel, struct ac_config *config) |
Read analog comparator configuration from hardware. More... | |
enum ac_status_t | ac_get_status (AC_t *ac, uint8_t channel) |
Get analog compare channel status. More... | |
void | ac_enable (AC_t *ac, uint8_t channel) |
Enable an analog comparator channel. More... | |
void | ac_disable (AC_t *ac, uint8_t channel) |
Disable an analog comparator channel. More... | |
Interrupt management functions | |
void | ac_set_interrupt_callback (AC_t *ac, ac_callback_t callback) |
Set interrupt callback function. More... | |
static void | ac_set_interrupt_mode (struct ac_config *config, enum ac_interrupt_mode_t mode) |
Set analog comparator channel interrupt mode. More... | |
static void | ac_set_interrupt_level (struct ac_config *config, enum ac_int_level_t level) |
Set analog comparator channel interrupt level. More... | |
Configuration helper functions | |
static void | ac_set_mode (struct ac_config *config, enum ac_mode_t mode) |
Set analog comparator mode. More... | |
static void | ac_set_positive_reference (struct ac_config *config, AC_MUXPOS_t reference) |
Set analog comparator reference for positive line. More... | |
static void | ac_set_negative_reference (struct ac_config *config, AC_MUXNEG_t reference) |
Set analog comparator reference for negative line. More... | |
static void | ac_set_hysteresis (struct ac_config *config, AC_HYSMODE_t hysteresis) |
Set analog comparator hysteresis. More... | |
static void | ac_set_voltage_scaler (struct ac_config *config, uint8_t scale) |
Set analog comparator voltage scale. More... | |