CMSIS-Driver_PIC32CM-PL  
Peripheral Library (PLIB) Documentation
 
Loading...
Searching...
No Matches
AC Interface

Driver API for AC (plib_ac.h) More...

Typedefs

typedef void(* AC_CALLBACK) (AC_EVENT event)
 AC callback function signature.
 

Enumerations

enum  AC_EVENT { AC_EVENT_COMP0 = 0 , AC_EVENT_COMP1 , AC_EVENT_WIN0 , AC_EVENT_NONE }
 AC Comparator events. More...
 

Functions

void AC_Initialize (void)
 Initializes the AC peripheral.
 
void AC_Enable (void)
 Enables the AC peripheral.
 
void AC_Disable (void)
 Disables the AC peripheral.
 
void AC_SoftwareReset (void)
 Performs a software reset of the AC peripheral.
 
bool AC_EnableChannel (uint8_t channel_number)
 Enables the specified AC channel.
 
bool AC_DisableChannel (uint8_t channel_number)
 Disables the specified AC channel.
 
bool AC_SetRunInStandby (uint8_t channel_number, bool enable)
 Sets the run-in-standby mode for the specified channel.
 
bool AC_SelectChannelInputs (uint8_t channel_number, uint32_t pos_input, uint32_t neg_input)
 Selects the positive and negative inputs for the specified channel.
 
bool AC_SetVddScaler (uint8_t channel_number, uint8_t vdd_scaler_value)
 Sets the VDD scaler value for the specified channel.
 
bool AC_SetReference (uint8_t channel_number, uint32_t reference)
 Sets the reference selection for the specified channel.
 
bool AC_SetHysteresis (uint8_t channel_number, bool enable)
 Enables or disables hysteresis for the specified channel.
 
bool AC_EnableOutput (uint8_t channel_number, bool enable)
 Enables or disables the output for the specified channel.
 
bool AC_GetStatus (uint8_t channel_number)
 Gets the status of the specified channel.
 
bool AC_EnableInterrupt (uint8_t channel_number, uint32_t interrupt_mode)
 Enables interrupt for the specified channel.
 
bool AC_DisableInterrupt (uint8_t channel_number)
 Disables interrupt for the specified channel.
 
bool AC_ClearInterruptFlag (uint8_t channel_number)
 Clears the interrupt flag for the specified channel.
 
bool AC_EnableWindowInterrupt (uint32_t window_interrupt_mode)
 Enables window interrupt with the specified mode.
 
void AC_DisableWindowInterrupt (void)
 Disables window interrupt.
 
void AC_ClearWindowInterruptFlag (void)
 Clears the window interrupt flag.
 
void AC_EnableWindowMode (void)
 Enables window mode.
 
void AC_DisableWindowMode (void)
 Disables window mode.
 
void AC_CallbackRegister (AC_CALLBACK callback)
 Register a callback handler for AC interrupts.
 

Description

Driver API for AC (plib_ac.h)

Usage Example

The following example demonstrates typical usage of the AC peripheral:

#include "plib_ac.h"
#include <stdint.h>
#include <stdbool.h>
int32_t configure_ac(void)
{
const uint8_t AC_CHANNEL_0 = 0U;
const uint8_t AC_VDDSCALER_32 = 32U;
// 1. Initialize the AC peripheral
// 2. Enable interrupts for comparator 0 (e.g., on rising edge)
AC_EnableInterrupt(AC_CHANNEL_0, AC_COMPCTRLA_INTSEL_RISING);
// 3. Configure comparator 0
AC_SelectChannelInputs(AC_CHANNEL_0, AC_COMPCTRLA_MUXPOS_AINP0, AC_COMPCTRLA_MUXNEG_VREFSCALE);
AC_SetReference(AC_CHANNEL_0, AC_COMPCTRLB_REFSEL_VDD_Val);
AC_SetHysteresis(AC_CHANNEL_0, true);
AC_SetVddScaler(AC_CHANNEL_0, AC_VDDSCALER_32);
// 4. Enable comparator 0 and the AC module
AC_EnableChannel(AC_CHANNEL_0);
return 0;
}
void AC_Initialize(void)
Initializes the AC peripheral.
bool AC_EnableInterrupt(uint8_t channel_number, uint32_t interrupt_mode)
Enables interrupt for the specified channel.
bool AC_SetReference(uint8_t channel_number, uint32_t reference)
Sets the reference selection for the specified channel.
bool AC_SelectChannelInputs(uint8_t channel_number, uint32_t pos_input, uint32_t neg_input)
Selects the positive and negative inputs for the specified channel.
bool AC_SetHysteresis(uint8_t channel_number, bool enable)
Enables or disables hysteresis for the specified channel.
bool AC_SetVddScaler(uint8_t channel_number, uint8_t vdd_scaler_value)
Sets the VDD scaler value for the specified channel.
bool AC_EnableChannel(uint8_t channel_number)
Enables the specified AC channel.
void AC_Enable(void)
Enables the AC peripheral.

Typedef Documentation

◆ AC_CALLBACK

typedef void(* AC_CALLBACK) (AC_EVENT event)

AC callback function signature.

Enumeration Type Documentation

◆ AC_EVENT

enum AC_EVENT

AC Comparator events.

Enumerator
AC_EVENT_COMP0 
AC_EVENT_COMP1 
AC_EVENT_WIN0 
AC_EVENT_NONE 

Function Documentation

◆ AC_CallbackRegister()

void AC_CallbackRegister ( AC_CALLBACK callback)

Register a callback handler for AC interrupts.

Parameters
callbackPointer to the callback function.

◆ AC_ClearInterruptFlag()

bool AC_ClearInterruptFlag ( uint8_t channel_number)

Clears the interrupt flag for the specified channel.

Parameters
channel_numberChannel number.
Returns
true if successful, false otherwise.

◆ AC_ClearWindowInterruptFlag()

void AC_ClearWindowInterruptFlag ( void )

Clears the window interrupt flag.

◆ AC_Disable()

void AC_Disable ( void )

Disables the AC peripheral.

◆ AC_DisableChannel()

bool AC_DisableChannel ( uint8_t channel_number)

Disables the specified AC channel.

Parameters
channel_numberChannel number to disable.
Returns
true if successful, false otherwise.

◆ AC_DisableInterrupt()

bool AC_DisableInterrupt ( uint8_t channel_number)

Disables interrupt for the specified channel.

Parameters
channel_numberChannel number.
Returns
true if successful, false otherwise.

◆ AC_DisableWindowInterrupt()

void AC_DisableWindowInterrupt ( void )

Disables window interrupt.

◆ AC_DisableWindowMode()

void AC_DisableWindowMode ( void )

Disables window mode.

◆ AC_Enable()

void AC_Enable ( void )

Enables the AC peripheral.

◆ AC_EnableChannel()

bool AC_EnableChannel ( uint8_t channel_number)

Enables the specified AC channel.

Parameters
channel_numberChannel number to enable.
Returns
true if successful, false otherwise.

◆ AC_EnableInterrupt()

bool AC_EnableInterrupt ( uint8_t channel_number,
uint32_t interrupt_mode )

Enables interrupt for the specified channel.

Parameters
channel_numberChannel number.
interrupt_modeInterrupt mode selection.
Returns
true if successful, false otherwise.

◆ AC_EnableOutput()

bool AC_EnableOutput ( uint8_t channel_number,
bool enable )

Enables or disables the output for the specified channel.

Parameters
channel_numberChannel number.
enabletrue to enable, false to disable.
Returns
true if successful, false otherwise.

◆ AC_EnableWindowInterrupt()

bool AC_EnableWindowInterrupt ( uint32_t window_interrupt_mode)

Enables window interrupt with the specified mode.

Parameters
window_interrupt_modeWindow interrupt mode selection.
Returns
true if successful, false otherwise.

◆ AC_EnableWindowMode()

void AC_EnableWindowMode ( void )

Enables window mode.

◆ AC_GetStatus()

bool AC_GetStatus ( uint8_t channel_number)

Gets the status of the specified channel.

Parameters
channel_numberChannel number.
Returns
true if the comparator output is high, false otherwise.

◆ AC_Initialize()

void AC_Initialize ( void )

Initializes the AC peripheral.

◆ AC_SelectChannelInputs()

bool AC_SelectChannelInputs ( uint8_t channel_number,
uint32_t pos_input,
uint32_t neg_input )

Selects the positive and negative inputs for the specified channel.

Parameters
channel_numberChannel number.
pos_inputPositive input selection.
neg_inputNegative input selection.
Returns
true if successful, false otherwise.

◆ AC_SetHysteresis()

bool AC_SetHysteresis ( uint8_t channel_number,
bool enable )

Enables or disables hysteresis for the specified channel.

Parameters
channel_numberChannel number.
enabletrue to enable, false to disable.
Returns
true if successful, false otherwise.

◆ AC_SetReference()

bool AC_SetReference ( uint8_t channel_number,
uint32_t reference )

Sets the reference selection for the specified channel.

Parameters
channel_numberChannel number.
referenceReference selection value.
Returns
true if successful, false otherwise.

◆ AC_SetRunInStandby()

bool AC_SetRunInStandby ( uint8_t channel_number,
bool enable )

Sets the run-in-standby mode for the specified channel.

Parameters
channel_numberChannel number.
enabletrue to enable, false to disable.
Returns
true if successful, false otherwise.

◆ AC_SetVddScaler()

bool AC_SetVddScaler ( uint8_t channel_number,
uint8_t vdd_scaler_value )

Sets the VDD scaler value for the specified channel.

Parameters
channel_numberChannel number.
vdd_scaler_valueScaler value.
Returns
true if successful, false otherwise.

◆ AC_SoftwareReset()

void AC_SoftwareReset ( void )

Performs a software reset of the AC peripheral.