CMSIS-Driver_PIC32CZ-CA70  
Peripheral Library (PLIB) Documentation
 
Loading...
Searching...
No Matches
ACC Interface

Driver API for ACC (plib_acc.h) More...

Typedefs

typedef void(* ACC_CALLBACK_HANDLER) (uint32_t status)
 ACC interrupt callback function type.
 

Functions

void ACC_Enable (void)
 Enables the ACC peripheral.
 
void ACC_Disable (void)
 Disables the ACC peripheral.
 
void ACC_ResetSoftware (void)
 Performs a software reset of the ACC peripheral.
 
bool ACC_SelectPositiveInput (uint8_t positive)
 Selects the positive input source for the ACC comparator. Module should be disabled before using this API.
 
bool ACC_SelectNegativeInput (uint8_t negative)
 Selects the negative input source for the ACC comparator. Module should be disabled before using this API.
 
bool ACC_SetHysteresis (uint8_t hystersis)
 Sets the hysteresis level for the ACC comparator.
 
bool ACC_SetCurrentMode (uint8_t isel)
 Sets the operating current mode (speed/power) of the ACC.
 
void ACC_SetOutputInversion (bool invert)
 Enables or disables inversion of the ACC comparator output.
 
bool ACC_SetEdgeType (uint8_t edge_type)
 Configures the edge type that triggers an ACC comparison interrupt.
 
void ACC_EnableFaultOutput (void)
 Enables the ACC fault output to the PWM fault input.
 
void ACC_DisableFaultOutput (void)
 Disables the ACC fault output to the PWM fault input.
 
void ACC_SelectFaultSource (bool use_output)
 Selects the source for the ACC fault output.
 
bool ACC_GetSynchronizedComparatorOutput (void)
 Reads the SCO (Synchronized Comparator Output) bit from ACC_ISR.
 
bool ACC_ComparatorOutputIsValid (void)
 Reads the MASK bit from ACC_ISR to check if the comparator output is valid.
 
bool ACC_GetAndClearComparisonEdge (void)
 Reads and clears the comparison edge flag from the ACC status register.
 
void ACC_EnableWriteProtection (void)
 Enables write protection on ACC configuration registers.
 
void ACC_DisableWriteProtection (void)
 Disables write protection on ACC configuration registers.
 
bool ACC_WriteProtectionViolationHasOccurred (void)
 Reads the write protection status register.
 
void ACC_EnableComparisonEdgeInterrupt (void)
 Enables the ACC comparison edge interrupt in ACC_IER.
 
void ACC_DisableComparisonEdgeInterrupt (void)
 Disables the ACC comparison edge interrupt.
 
bool ACC_GetComparisonEdgeStatus (void)
 Reads the comparison edge interrupt mask status.
 
void ACC_SetCallbackHandler (ACC_CALLBACK_HANDLER callback)
 Register a callback for ACC interrupts.
 

Description

Driver API for ACC (plib_acc.h)

Usage Example

The following example demonstrates typical usage of the ACC peripheral:

#include "plib_acc.h"
void configure_acc(void);
void configure_acc(void) {
/* Disable the ACC peripheral before changing configuration */
/* Clear old configurations for inputs, inversion, and edge selection */
(void)ACC_SelectPositiveInput(0U); /* SELPLUS = 0 : AD0 as positive input */
(void)ACC_SelectNegativeInput(5U); /* SELMINUS = 5: AD1 as negative input */
ACC_SetOutputInversion(false); /* INV = 0 : No output inversion */
(void)ACC_SetEdgeType(2U); /* EDGETYP = 2 : Interrupt on any edge */
/* Configure Analog Control Register (ACC_ACR)
* - HYST(1) : Small hysteresis level
* - ISEL = 1 : High-speed current mode
*/
(void)ACC_SetHysteresis(1U);
(void)ACC_SetCurrentMode(1U);
/* Enable the comparison-edge interrupt */
/* Enable the ACC peripheral */
}
bool ACC_SetEdgeType(uint8_t edge_type)
Configures the edge type that triggers an ACC comparison interrupt.
void ACC_Enable(void)
Enables the ACC peripheral.
bool ACC_SelectNegativeInput(uint8_t negative)
Selects the negative input source for the ACC comparator. Module should be disabled before using this...
void ACC_EnableComparisonEdgeInterrupt(void)
Enables the ACC comparison edge interrupt in ACC_IER.
bool ACC_SetCurrentMode(uint8_t isel)
Sets the operating current mode (speed/power) of the ACC.
bool ACC_SelectPositiveInput(uint8_t positive)
Selects the positive input source for the ACC comparator. Module should be disabled before using this...
void ACC_SetOutputInversion(bool invert)
Enables or disables inversion of the ACC comparator output.
void ACC_Disable(void)
Disables the ACC peripheral.
bool ACC_SetHysteresis(uint8_t hystersis)
Sets the hysteresis level for the ACC comparator.
Analog comparator controller PLIB interface.

Typedef Documentation

◆ ACC_CALLBACK_HANDLER

typedef void(* ACC_CALLBACK_HANDLER) (uint32_t status)

ACC interrupt callback function type.

This function pointer type is used to register a user callback for the Analog Comparator controller (ACC) interrupt. The callback is invoked when an ACC interrupt occurs, providing the interrupt flags and user context.

Parameters
contextUser-defined context value passed during callback registration.

Function Documentation

◆ ACC_ComparatorOutputIsValid()

bool ACC_ComparatorOutputIsValid ( void )

Reads the MASK bit from ACC_ISR to check if the comparator output is valid.

Returns
0 if CE flag and SCO is valid or 1 otherwise

◆ ACC_Disable()

void ACC_Disable ( void )

Disables the ACC peripheral.

◆ ACC_DisableComparisonEdgeInterrupt()

void ACC_DisableComparisonEdgeInterrupt ( void )

Disables the ACC comparison edge interrupt.

◆ ACC_DisableFaultOutput()

void ACC_DisableFaultOutput ( void )

Disables the ACC fault output to the PWM fault input.

◆ ACC_DisableWriteProtection()

void ACC_DisableWriteProtection ( void )

Disables write protection on ACC configuration registers.

◆ ACC_Enable()

void ACC_Enable ( void )

Enables the ACC peripheral.

◆ ACC_EnableComparisonEdgeInterrupt()

void ACC_EnableComparisonEdgeInterrupt ( void )

Enables the ACC comparison edge interrupt in ACC_IER.

◆ ACC_EnableFaultOutput()

void ACC_EnableFaultOutput ( void )

Enables the ACC fault output to the PWM fault input.

◆ ACC_EnableWriteProtection()

void ACC_EnableWriteProtection ( void )

Enables write protection on ACC configuration registers.

◆ ACC_GetAndClearComparisonEdge()

bool ACC_GetAndClearComparisonEdge ( void )

Reads and clears the comparison edge flag from the ACC status register.

Returns
0 if no edge occured and 1 if a selected edge on Analog comparator occured

◆ ACC_GetComparisonEdgeStatus()

bool ACC_GetComparisonEdgeStatus ( void )

Reads the comparison edge interrupt mask status.

Returns
0 if interrupt is disabled and 1 otherwise

◆ ACC_GetSynchronizedComparatorOutput()

bool ACC_GetSynchronizedComparatorOutput ( void )

Reads the SCO (Synchronized Comparator Output) bit from ACC_ISR.

Returns
Analog comparator output after preprocessed, return -1 if the MSK value is invalid

◆ ACC_ResetSoftware()

void ACC_ResetSoftware ( void )

Performs a software reset of the ACC peripheral.

◆ ACC_SelectFaultSource()

void ACC_SelectFaultSource ( bool use_output)

Selects the source for the ACC fault output.

Parameters
useOutput0 or 1 for fault source selection

◆ ACC_SelectNegativeInput()

bool ACC_SelectNegativeInput ( uint8_t negative)

Selects the negative input source for the ACC comparator. Module should be disabled before using this API.

Parameters
negativenegative input channel selection
Returns
true if successful, false otherwise.

◆ ACC_SelectPositiveInput()

bool ACC_SelectPositiveInput ( uint8_t positive)

Selects the positive input source for the ACC comparator. Module should be disabled before using this API.

Parameters
positivepostive input channel selection
Returns
true if successful, false otherwise.

◆ ACC_SetCallbackHandler()

void ACC_SetCallbackHandler ( ACC_CALLBACK_HANDLER callback)

Register a callback for ACC interrupts.

Registers a user callback to be called from the AC interrupt handler when any enabled ACC interrupt occurs. The callback receives the interrupt flags and user context.

Parameters
[in]callbackPointer to the callback function (ACC_CALLBACK).

◆ ACC_SetCurrentMode()

bool ACC_SetCurrentMode ( uint8_t isel)

Sets the operating current mode (speed/power) of the ACC.

Parameters
iselCurrent mode selection
Returns
true if successful, false otherwise

◆ ACC_SetEdgeType()

bool ACC_SetEdgeType ( uint8_t edge_type)

Configures the edge type that triggers an ACC comparison interrupt.

Parameters
edgetypedge type selection 0 to 2
Returns
true if successful, false otherwise

◆ ACC_SetHysteresis()

bool ACC_SetHysteresis ( uint8_t hystersis)

Sets the hysteresis level for the ACC comparator.

Parameters
hystersisHyseteresis selection 0 to 3
Returns
true if successful, false otherwise

◆ ACC_SetOutputInversion()

void ACC_SetOutputInversion ( bool invert)

Enables or disables inversion of the ACC comparator output.

Parameters
invert1 to enable and 0 to disable.

◆ ACC_WriteProtectionViolationHasOccurred()

bool ACC_WriteProtectionViolationHasOccurred ( void )

Reads the write protection status register.

Returns
1 if write protection violation has occured and 0 otherwise