Driver API for AC (plib_ac.h) More...
Macros | |
| #define | AC_COMP_NUMBER 4U |
| Number of comparators available in the AC peripheral. | |
| #define | AC_WIN_NUMBER 2U |
| Number of window comparators available in the AC peripheral. | |
Typedefs | |
| typedef void(* | AC_CALLBACK_HANDLER) (uint8_t status) |
| AC interrupt callback function type. | |
Enumerations | |
| enum | AC_EVENT { AC_EVENT_COMP0 = 0 , AC_EVENT_COMP1 = 1 , AC_EVENT_COMP2 = 2 , AC_EVENT_COMP3 = 3 , AC_EVENT_WIN0 = 4 , AC_EVENT_WIN1 = 5 , AC_EVENT_NONE = 6 } |
| AC Comparator events. More... | |
| enum | AC_OUTPUT { AC_OUTPUT_OFF = 0 , AC_OUTPUT_ASYNC = 1 , AC_OUTPUT_SYNC = 2 } |
| AC output options. More... | |
Functions | |
| void | AC_Enable (void) |
| Enables the AC peripheral. | |
| void | AC_Disable (void) |
| Disables the AC peripheral. | |
| void | AC_ResetSoftware (void) |
| Performs a software reset of the AC peripheral. | |
| bool | AC_EnableChannel (uint8_t channel) |
| Enables the specified AC channel. | |
| bool | AC_DisableChannel (uint8_t channel) |
| Disables the specified AC channel. | |
| bool | AC_SetRunInStandby (uint8_t channel, bool enable) |
| Sets the run-in-standby mode for the specified channel. | |
| bool | AC_SelectChannelInputs (uint8_t channel, uint32_t pos, uint32_t neg) |
| Selects the positive and negative inputs for the specified channel. | |
| bool | AC_SetComparisonMode (uint8_t channel, uint8_t single) |
| Set comparison mode for the comparator channel. | |
| bool | AC_SetSpeed (uint8_t channel, uint32_t speed) |
| Set speed for comparator channel. | |
| bool | AC_SetVddScaler (uint8_t channel, uint8_t value) |
| Sets the VDD scaler value for the specified channel. | |
| bool | AC_SetHysteresis (uint8_t channel, bool enable) |
| Enables or disables hysteresis for the specified channel. | |
| bool | AC_SetFilterLength (uint8_t channel, uint32_t flen) |
| Set Filter length for comparator channel. | |
| bool | AC_SwapInputs (uint8_t channel, bool enable) |
| Swaps the inputs. | |
| bool | AC_EnableOutput (uint8_t channel, AC_OUTPUT value) |
| Enables or disables the output for the specified channel. | |
| bool | AC_StartComparison (uint8_t channel) |
| Starts comparison. | |
| bool | AC_CheckOutputReady (uint8_t channel) |
| Check if output is ready. | |
| bool | AC_GetStatus (uint8_t channel) |
| Gets the status of the specified channel. | |
| bool | AC_SetInvertedInput (uint8_t channel) |
| Invert the input event. | |
| bool | AC_ClearInvertedInput (uint8_t channel) |
| Clear the inverted input event setting. | |
| bool | AC_StartComparisonOnEvent (uint8_t channel) |
| Start comparison on input event. | |
| bool | AC_DisableComparisonOnEvent (uint8_t channel) |
| Disable start comparison on input event. | |
| bool | AC_EnableCompEventOutput (uint8_t channel) |
| Enables Comparator event output. | |
| bool | AC_DisableCompEventOutput (uint8_t channel) |
| Disables Comparator event output. | |
| bool | AC_EnableWindowEventOutput (uint8_t instance) |
| Enables window event output. | |
| bool | AC_DisableWindowEventOutput (uint8_t instance) |
| Disables window event output. | |
| bool | AC_EnableInterrupt (uint8_t channel, uint32_t mode) |
| Enables interrupt for the specified channel. | |
| bool | AC_DisableInterrupt (uint8_t channel) |
| Disables interrupt for the specified channel. | |
| bool | AC_ClearInterruptFlag (uint8_t channel) |
| Clears the interrupt flag for the specified channel. | |
| bool | AC_EnableWindowInterrupt (uint8_t instance, uint32_t mode) |
| Enables window interrupt with the specified mode. | |
| bool | AC_DisableWindowInterrupt (uint8_t instance) |
| Disables window interrupt. | |
| bool | AC_ClearWindowInterruptFlag (uint8_t instance) |
| Clears the window interrupt flag. | |
| bool | AC_EnableWindowMode (uint8_t instance) |
| Enables window mode. | |
| bool | AC_DisableWindowMode (uint8_t instance) |
| Disables window mode. | |
| uint8_t | AC_GetWindowModeStatus (uint8_t instance) |
| Gets the status of the Window mode output. | |
| void | AC_SetCallbackHandler (AC_CALLBACK_HANDLER callback) |
| Register a callback for AC interrupts. | |
Driver API for AC (plib_ac.h)
The following example demonstrates typical usage of the AC peripheral:
| #define AC_COMP_NUMBER 4U |
Number of comparators available in the AC peripheral.
| #define AC_WIN_NUMBER 2U |
Number of window comparators available in the AC peripheral.
| typedef void(* AC_CALLBACK_HANDLER) (uint8_t status) |
AC interrupt callback function type.
This function pointer type is used to register a user callback for the Analog Comparator (AC) interrupt. The callback is invoked when an AC interrupt occurs, providing the interrupt flags and user context.
| int_flags | Interrupt flags indicating the source of the AC interrupt. |
| context | User-defined context value passed during callback registration. |
| enum AC_EVENT |
| enum AC_OUTPUT |
| bool AC_CheckOutputReady | ( | uint8_t | channel | ) |
Check if output is ready.
| channel | Comparator channel number 0 to 3. |
| bool AC_ClearInterruptFlag | ( | uint8_t | channel | ) |
Clears the interrupt flag for the specified channel.
| channel | Channel number. |
| bool AC_ClearInvertedInput | ( | uint8_t | channel | ) |
Clear the inverted input event setting.
| channel | Comparator channel number 0 to 3. |
| bool AC_ClearWindowInterruptFlag | ( | uint8_t | instance | ) |
Clears the window interrupt flag.
| instance | Select window instance 0 or 1. |
| void AC_Disable | ( | void | ) |
Disables the AC peripheral.
| bool AC_DisableChannel | ( | uint8_t | channel | ) |
Disables the specified AC channel.
| channel | Channel number to disable. |
| bool AC_DisableComparisonOnEvent | ( | uint8_t | channel | ) |
Disable start comparison on input event.
| channel | Comparator channel number 0 to 3. |
| bool AC_DisableCompEventOutput | ( | uint8_t | channel | ) |
Disables Comparator event output.
| channel | Comparator channel number 0 to 3. |
| bool AC_DisableInterrupt | ( | uint8_t | channel | ) |
Disables interrupt for the specified channel.
| channel | Channel number. |
| bool AC_DisableWindowEventOutput | ( | uint8_t | instance | ) |
Disables window event output.
| instance | Select window instance 0 or 1. |
| bool AC_DisableWindowInterrupt | ( | uint8_t | instance | ) |
Disables window interrupt.
| instance | Select window instance 0 or 1. |
| bool AC_DisableWindowMode | ( | uint8_t | instance | ) |
Disables window mode.
| instance | Select window instance 0 or 1. |
| void AC_Enable | ( | void | ) |
Enables the AC peripheral.
| bool AC_EnableChannel | ( | uint8_t | channel | ) |
Enables the specified AC channel.
| channel | Channel number to enable. |
| bool AC_EnableCompEventOutput | ( | uint8_t | channel | ) |
Enables Comparator event output.
| channel | Comparator channel number 0 to 3. |
| bool AC_EnableInterrupt | ( | uint8_t | channel, |
| uint32_t | mode ) |
Enables interrupt for the specified channel.
| channel | Channel number. |
| mode | Interrupt mode selection. |
| bool AC_EnableOutput | ( | uint8_t | channel, |
| AC_OUTPUT | value ) |
Enables or disables the output for the specified channel.
| channel | Channel number. |
| value | AC_OUTPUT OFF, ASYNC, SYNC. |
| bool AC_EnableWindowEventOutput | ( | uint8_t | instance | ) |
Enables window event output.
| instance | Select window instance 0 or 1. |
| bool AC_EnableWindowInterrupt | ( | uint8_t | instance, |
| uint32_t | mode ) |
Enables window interrupt with the specified mode.
| instance | Select window instance 0 or 1. |
| mode | Window interrupt mode selection. |
| bool AC_EnableWindowMode | ( | uint8_t | instance | ) |
Enables window mode.
| instance | Select window instance 0 or 1. |
| bool AC_GetStatus | ( | uint8_t | channel | ) |
Gets the status of the specified channel.
| channel | Channel number. |
| uint8_t AC_GetWindowModeStatus | ( | uint8_t | instance | ) |
Gets the status of the Window mode output.
| instance | Select window instance 0 or 1. |
| void AC_ResetSoftware | ( | void | ) |
Performs a software reset of the AC peripheral.
| bool AC_SelectChannelInputs | ( | uint8_t | channel, |
| uint32_t | pos, | ||
| uint32_t | neg ) |
Selects the positive and negative inputs for the specified channel.
| channel | Channel number. |
| pos | Positive input selection. |
| neg | Negative input selection. |
| void AC_SetCallbackHandler | ( | AC_CALLBACK_HANDLER | callback | ) |
Register a callback for AC interrupts.
Registers a user callback to be called from the AC interrupt handler when any enabled AC interrupt occurs. The callback receives the interrupt flags and user context.
| [in] | callback | Pointer to the callback function (AC_CALLBACK). |
| bool AC_SetComparisonMode | ( | uint8_t | channel, |
| uint8_t | single ) |
Set comparison mode for the comparator channel.
| channel | Comparator channel number 0 to 3. |
| single | Single mode selection. |
| bool AC_SetFilterLength | ( | uint8_t | channel, |
| uint32_t | flen ) |
Set Filter length for comparator channel.
| channel | Comparator channel number 0 to 3. |
| flen | Filter length. |
| bool AC_SetHysteresis | ( | uint8_t | channel, |
| bool | enable ) |
Enables or disables hysteresis for the specified channel.
| channel | Channel number. |
| enable | true to enable, false to disable. |
| bool AC_SetInvertedInput | ( | uint8_t | channel | ) |
Invert the input event.
| channel | Comparator channel number 0 to 3. |
| bool AC_SetRunInStandby | ( | uint8_t | channel, |
| bool | enable ) |
Sets the run-in-standby mode for the specified channel.
| channel | Channel number. |
| enable | true to enable, false to disable. |
| bool AC_SetSpeed | ( | uint8_t | channel, |
| uint32_t | speed ) |
Set speed for comparator channel.
| channel | Comparator channel number 0 to 3. |
| speed | Speed selection. |
| bool AC_SetVddScaler | ( | uint8_t | channel, |
| uint8_t | value ) |
Sets the VDD scaler value for the specified channel.
| channel | Channel number. |
| value | Scaler value. |
| bool AC_StartComparison | ( | uint8_t | channel | ) |
Starts comparison.
| channel | Comparator channel number 0 to 3. |
| bool AC_StartComparisonOnEvent | ( | uint8_t | channel | ) |
Start comparison on input event.
| channel | Comparator channel number 0 to 3. |
| bool AC_SwapInputs | ( | uint8_t | channel, |
| bool | enable ) |
Swaps the inputs.
| channel | Comparator channel number 0 to 3. |
| enable | true to enable, false to disable. |