Driver API for ADC (plib_adc.h) More...
Typedefs | |
| typedef void(* | ADC_Callback_t) (ADC_INTERRUPT_SOURCE intr_src) |
| ADC callback. | |
Functions | |
| void | ADC_SetPrescaler (uint8_t pre_scaler) |
| Sets the ADC clock prescaler value. | |
| void | ADC_SetSampleLength (uint8_t sample_len) |
| Sets the ADC sample length. | |
| void | ADC_SetVoltageReference (uint8_t ref_sel) |
| Sets the ADC voltage reference source. | |
| void | ADC_SetResolution (uint32_t resolution) |
| Sets the ADC resolution. | |
| void | ADC_SetTimebase (uint8_t timebase) |
| Sets the ADC Timebase field. | |
| void | ADC_SetFreeRunMode (bool free_run) |
| Enables or disables the ADC free run mode. | |
| void | ADC_SetSampleAccummulationCount (uint32_t samp_acc_count) |
| Sets the number of samples to accumulate for ADC conversion. | |
| void | ADC_SetDifferentialMode (bool diff_mode) |
| Enables or disables ADC differential mode. | |
| void | ADC_SetComputationMode (ADC_COMPUTATION_MODE computation_mode) |
| Sets the ADC computation mode. | |
| void | ADC_Enable (void) |
| Enables the ADC module. | |
| void | ADC_Disable (void) |
| Disables the ADC module. | |
| uint32_t | ADC_Get32bitConversionResult (void) |
| Retrieves the 32-bit ADC conversion result. | |
| uint16_t | ADC_Get16bitConversionResult (void) |
| Retrieves the 16-bit ADC conversion result. | |
| void | ADC_SelectDifferentialChannel (uint32_t positive_input, uint32_t negative_input) |
| Selects the ADC differential input channels. | |
| bool | ADC_ConversionIsComplete (void) |
| Checks if the ADC conversion is complete. | |
| void | ADC_StartConversion (ADC_START_MODE start_mode) |
| Starts an ADC conversion with the specified start mode. | |
| void | ADC_AbortConversion (void) |
| Aborts the ongoing ADC conversion. | |
| void | ADC_ResetSoftware (void) |
| Performs a software reset and resets the ADC module. | |
| bool | ADC_EnableInterrupt (ADC_INTERRUPT_SOURCE interrupt) |
| Enables the specified ADC interrupt(s). | |
| void | ADC_DisableInterrupt (ADC_INTERRUPT_SOURCE interrupt) |
| Disables the specified ADC interrupt(s). | |
| void | ADC_ClearInterruptFlag (ADC_INTERRUPT_SOURCE intr_flag) |
| Clears the specified ADC interrupt flag(s). | |
| bool | ADC_GetInterruptFlagStatus (ADC_INTERRUPT_SOURCE interrupt) |
| Gets the current ADC interrupt flag status. | |
| void | ADC_ConfigureWindowMode (ADC_WINSRC win_src, ADC_WINMODE win_mode, uint32_t win_lt, uint32_t win_ht) |
| Configures the ADC window comparator source, mode, and threshold values. | |
| void | ADC_SetEventControl (ADC_EVENT_OUTPUT event, bool enable) |
| Configures the ADC event control settings. | |
| void | ADC_EnableWriteProtection (void) |
| Enables write protection for ADC registers. | |
| void | ADC_DisableWriteProtection (void) |
| Disables write protection for ADC registers. | |
| void | ADC_WriteProtectionLock (void) |
| Locks write protection configuration until reset. | |
| bool | ADC_WriteProtectionIsEnabled (void) |
| Queries if write protection is enabled. | |
| bool | ADC_WriteProtectionIsLocked (void) |
| Queries if write protection is locked. | |
| void | ADC_SetResultScaling (ADC_RES_SCALING scale) |
| Sets the ADC result scaling mode. | |
| void | ADC_SetLowPassFilter (bool low_pass_filter) |
| Enables or disables the ADC low-pass filter. | |
| void | ADC_SetCallbackHandler (ADC_Callback_t callback) |
| Sets a callback function for ADC interrupts. | |
Driver API for ADC (plib_adc.h)
The following example demonstrates typical usage of the ADC peripheral:
| ADC_Callback_t |
ADC callback.
This type defines a callback function that is called upon ADC events.
| intr_src | The source of the ADC interrupt that triggered the callback. |
| enum ADC_COMPUTATION_MODE |
ADC computation mode selection.
Enumerates the available modes for ADC computation.
| enum ADC_EVENT_OUTPUT |
| enum ADC_INTERRUPT_SOURCE |
ADC interrupt sources.
Enumerates the available interrupt sources for the ADC.
| enum ADC_RES_SCALING |
| enum ADC_START_MODE |
ADC start-conversion mode selection.
Enumerates the available modes for starting an ADC conversion.
| enum ADC_WINMODE |
ADC window comparator mode.
Enumerates the available window comparator modes for the ADC.
| enum ADC_WINSRC |
| void ADC_AbortConversion | ( | void | ) |
Aborts the ongoing ADC conversion.
This function stops any ongoing ADC conversion.
| None. |
| void ADC_ClearInterruptFlag | ( | ADC_INTERRUPT_SOURCE | intr_flag | ) |
Clears the specified ADC interrupt flag(s).
This function clears the specified ADC interrupt flags.
| intr_flag | Interrupt flag mask to clear. |
| void ADC_ConfigureWindowMode | ( | ADC_WINSRC | win_src, |
| ADC_WINMODE | win_mode, | ||
| uint32_t | win_lt, | ||
| uint32_t | win_ht ) |
Configures the ADC window comparator source, mode, and threshold values.
Sets up the ADC window comparator with the specified source, mode, and threshold values.
| win_src | Window comparator source selection (RESULT or SAMPLE). |
| win_mode | Window comparison mode (NONE, BELOW, ABOVE, INSIDE, OUTSIDE). |
| win_lt | Low threshold value for window comparison. |
| win_ht | High threshold value for window comparison. |
| bool ADC_ConversionIsComplete | ( | void | ) |
Checks if the ADC conversion is complete.
This function checks whether the ADC has finished its current conversion.
| None. |
| void ADC_Disable | ( | void | ) |
Disables the ADC module.
This function disables the ADC peripheral, stopping all conversions and reducing power consumption.
| None. |
| void ADC_DisableInterrupt | ( | ADC_INTERRUPT_SOURCE | interrupt | ) |
Disables the specified ADC interrupt(s).
This function disables the given ADC interrupt source(s).
| interrupt | Interrupt mask to disable. |
| void ADC_DisableWriteProtection | ( | void | ) |
Disables write protection for ADC registers.
| None. |
| void ADC_Enable | ( | void | ) |
Enables the ADC module.
This function enables the ADC peripheral, allowing conversions to be started.
| None. |
| bool ADC_EnableInterrupt | ( | ADC_INTERRUPT_SOURCE | interrupt | ) |
Enables the specified ADC interrupt(s).
This function enables the given ADC interrupt source(s).
| interrupt | Interrupt mask to enable. |
| void ADC_EnableWriteProtection | ( | void | ) |
Enables write protection for ADC registers.
| None. |
| uint16_t ADC_Get16bitConversionResult | ( | void | ) |
Retrieves the 16-bit ADC conversion result.
This function returns the latest 16-bit result from the ADC conversion.
| uint32_t ADC_Get32bitConversionResult | ( | void | ) |
Retrieves the 32-bit ADC conversion result.
This function returns the latest 32-bit result from the ADC conversion.
| None. |
| bool ADC_GetInterruptFlagStatus | ( | ADC_INTERRUPT_SOURCE | interrupt | ) |
Gets the current ADC interrupt flag status.
Checks if the specified ADC interrupt flag is set.
| interrupt | Interrupt source to check. |
| void ADC_ResetSoftware | ( | void | ) |
Performs a software reset and resets the ADC module.
This function resets the ADC peripheral to its default state.
| None. |
| void ADC_SelectDifferentialChannel | ( | uint32_t | positive_input, |
| uint32_t | negative_input ) |
Selects the ADC differential input channels.
Configures the ADC to use the specified positive and negative input channels for differential conversion.
| positive_input | The channel to use as the positive input. |
| negative_input | The channel to use as the negative input. |
| void ADC_SetCallbackHandler | ( | ADC_Callback_t | callback | ) |
Sets a callback function for ADC interrupts.
Sets a user-defined callback function to be invoked when an ADC interrupt occurs.
| callback | The callback function to be set. |
| void ADC_SetComputationMode | ( | ADC_COMPUTATION_MODE | computation_mode | ) |
Sets the ADC computation mode.
This function selects the computation mode for the ADC, such as single, series, or burst conversion.
| computation_mode | Computation mode selection value. |
| void ADC_SetDifferentialMode | ( | bool | diff_mode | ) |
Enables or disables ADC differential mode.
Configures the ADC to operate in differential or single-ended mode.
| diff_mode | true to enable differential mode, false for single-ended. |
| void ADC_SetEventControl | ( | ADC_EVENT_OUTPUT | event, |
| bool | enable ) |
Configures the ADC event control settings.
Enables or disables specific ADC event outputs.
| event | ADC event output to configure. |
| enable | Set to true to enable the event, false to disable. |
| void ADC_SetFreeRunMode | ( | bool | free_run | ) |
Enables or disables the ADC free run mode.
Configures the ADC to operate in free run mode, where it continuously performs conversions without requiring a new start command.
| free_run | Set to true to enable free run mode, or false to disable it. |
| void ADC_SetLowPassFilter | ( | bool | low_pass_filter | ) |
Enables or disables the ADC low-pass filter.
Configures the ADC to use its built-in low-pass filter to reduce high-frequency noise.
| low_pass_filter | If true, enables the low-pass filter; if false, disables it. |
| void ADC_SetPrescaler | ( | uint8_t | pre_scaler | ) |
Sets the ADC clock prescaler value.
This function configures the ADC clock prescaler.
| pre_scaler | Prescaler value to set for the ADC clock. |
| void ADC_SetResolution | ( | uint32_t | resolution | ) |
Sets the ADC resolution.
This function configures the resolution of the ADC conversion result.
| resolution | Resolution setting (e.g., 8, 10, 12 bits). |
| void ADC_SetResultScaling | ( | ADC_RES_SCALING | scale | ) |
Sets the ADC result scaling mode.
Configures the ADC to use the specified result scaling mode (e.g., normal, left-adjusted, or averaged).
| scale | The result scaling mode to set. See adc_res_scaling_t_enum for available options. |
| void ADC_SetSampleAccummulationCount | ( | uint32_t | samp_acc_count | ) |
Sets the number of samples to accumulate for ADC conversion.
This function configures the ADC to accumulate a specified number of samples for each conversion.
| samp_acc_count | Number of samples to accumulate. |
| void ADC_SetSampleLength | ( | uint8_t | sample_len | ) |
Sets the ADC sample length.
This function configures the number of ADC clock cycles used for sampling.
| sample_len | Number of ADC clock cycles for sampling. |
| void ADC_SetTimebase | ( | uint8_t | timebase | ) |
Sets the ADC Timebase field.
This function configures the TIMEBASE value in the ADC control register.
| timebase | TIMEBASE value to set. |
| void ADC_SetVoltageReference | ( | uint8_t | ref_sel | ) |
Sets the ADC voltage reference source.
This function selects the voltage reference source for the ADC.
| ref_sel | Voltage reference selection value. |
| void ADC_StartConversion | ( | ADC_START_MODE | start_mode | ) |
Starts an ADC conversion with the specified start mode.
Initiates an ADC conversion using the provided start mode.
| start_mode | Start mode selection value. |
| bool ADC_WriteProtectionIsEnabled | ( | void | ) |
Queries if write protection is enabled.
| None. |
| bool ADC_WriteProtectionIsLocked | ( | void | ) |
Queries if write protection is locked.
| None. |
| void ADC_WriteProtectionLock | ( | void | ) |
Locks write protection configuration until reset.
| None. |