Bar Logo 3.8/7.6 kw Totem pole Demonstration Application (Part-No. (not specified))
 
Content
     
Loading...
Searching...
No Matches

High-Speed, 12-Bit Multiple SARs Analog-to-Digital Converter driver using dsPIC MCUs. More...

+ Collaboration diagram for ADC Multicore Driver:

Files

file  adc1.h
 This is the generated driver header file for the ADC1 driver.
 
file  adc_features.h
 This is the generated module feature header file for ADC driver This file provides module feature list available on the selected device. The macros defined in this file provides the flexibility to easily migrate the user application to other device which might have varied feature list. The content in this file is strictly "read only" and should not be altered.
 
file  adc_types.h
 This is the generated driver types header file for the ADC driver.
 
file  adc1.c
 This is the generated driver source file for ADC1 driver.
 

Data Structures

struct  ADC_INTERFACE
 Structure containing the function pointers of ADC driver. More...
 
struct  ADC_MULTICORE
 Structure containing the function pointers of ADC driver. More...
 

Macros

#define ADC1_SCAN_MODE_SELECTED   true
 Defines the scan option selection done for the shared channels.
 
#define ADC1_RESOLUTION   12
 Defines the ADC Resolution.
 
#define ADC_POWER_ENABLE_FEATURE_AVAILABLE   1
 This macro defines the ADC core power enable functionality.
 
#define ADC_CALIBRATION_FEATURE_AVAILABLE   1
 This macro defines the macro associated with ADC core calibration.
 
#define ADC_INDIVIDUAL_CHANNEL_INTERRUPT_FEATURE_AVAILABLE   1
 Defines the macro associated with ADC indvidual channel interrupts.
 
#define ADC_COMPARATOR_FEATURE_AVAILABLE   1
 Defines the macro associated with ADC comparator feature.
 

Enumerations

enum  ADC_CHANNEL { FB_Vout , FB_AC_N , IL1_F , IL2_F , MAX_CHANNELS = 4 , ADC_MAX_CHANNELS = 4 }
 Defines the ADC channles that are selected from the MCC Melody User Interface for the ADC conversions. More...
 
enum  ADC_DEDICATED_CORE { CORE_0 = 0 , ADC_CORE_0 = 0 , CORE_1 = 1 , ADC_CORE_1 = 1 , MAX_DEDICATED_CORES = 2 , ADC_MAX_DEDICATED_CORES = 2 }
 Defines the ADC cores that are available for the module to use. More...
 
enum  ADC_RESOLUTION_TYPE { ADC_6_BIT_RESOLUTION = 0x0 , ADC_8_BIT_RESOLUTION = 0x1 , ADC_10_BIT_RESOLUTION = 0x2 , ADC_12_BIT_RESOLUTION = 0x3 }
 Defines the supported ADC resolution types. More...
 
enum  ADC_CMP { MAX_CMPS = 0 , ADC_MAX_CMPS = 0 }
 Defines the ADC comparators that are available for the module to use. More...
 
enum  ADC_PWM_INSTANCE { ADC_PWM_HS_NOT_AVAILABLE }
 Defines the ADC PWM trigger sources that are available for the module to use. More...
 
enum  ADC_PWM_TRIGGERS { ADC_PWM_TRIGGERS_NOT_AVAILABLE }
 Defines the PWM triggers that are available in each individual PWM. More...
 

Functions

void ADC1_Initialize (void)
 Initializes ADC1 module, using the given initialization data This function must be called before any other ADC1 function is called.
 
void ADC1_Deinitialize (void)
 Deinitializes the ADC1 to POR values.
 
static void ADC1_Enable (void)
 This inline function enables the ADC1 module.
 
static void ADC1_Disable (void)
 This inline function disables the ADC1 module.
 
static void ADC1_SoftwareTriggerEnable (void)
 This inline function sets software common trigger.
 
static void ADC1_SoftwareTriggerDisable (void)
 This inline function resets software common trigger.
 
static void ADC1_ChannelSelect (enum ADC_CHANNEL channel)
 This inline function allows selection of a channel for conversion.
 
static uint16_t ADC1_ConversionResultGet (enum ADC_CHANNEL channel)
 Returns the conversion value for the channel selected.
 
static bool ADC1_IsConversionComplete (enum ADC_CHANNEL channel)
 This inline function returns the status of conversion.This function is used to determine if conversion is completed. When conversion is complete the function returns true otherwise false.
 
static void ADC1_ResolutionSet (enum ADC_RESOLUTION_TYPE resolution)
 This inline function helps to configure all cores with same resolution.
 
static void ADC1_InterruptEnable (void)
 This inline function enables the ADC1 interrupt.
 
static void ADC1_InterruptDisable (void)
 This inline function disables the ADC1 interrupt.
 
static void ADC1_InterruptFlagClear (void)
 Clears interrupt flag manually.
 
static void ADC1_InterruptPrioritySet (uint16_t priorityValue)
 This inline function allows selection of priority for interrupt.
 
void ADC1_CommonCallbackRegister (void(*callback)(void))
 This function can be used to override default callback and to define custom callback for ADC1 Common event.
 
void ADC1_CommonCallback (void)
 This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using ADC1_CommonCallbackRegister.
 
void ADC1_Tasks (void)
 This function is used to implement the tasks for polled implementations.
 
static void ADC1_IndividualChannelInterruptEnable (enum ADC_CHANNEL channel)
 This inline function enables individual channel interrupt.
 
static void ADC1_IndividualChannelInterruptDisable (enum ADC_CHANNEL channel)
 This inline function disables individual channel interrupt.
 
static void ADC1_IndividualChannelInterruptFlagClear (enum ADC_CHANNEL channel)
 This inline function clears individual channel interrupt flag.
 
static void ADC1_IndividualChannelInterruptPrioritySet (enum ADC_CHANNEL channel, enum INTERRUPT_PRIORITY priorityValue)
 This inline function allows selection of priority for individual channel interrupt.
 
void ADC1_ChannelCallbackRegister (void(*callback)(enum ADC_CHANNEL channel, uint16_t adcVal))
 This function can be used to override default callback ADC1_ChannelCallback and to define custom callback for ADC1 Channel event. Read the conversion result of the corresponding channel in the custom callback.
 
void ADC1_ChannelCallback (enum ADC_CHANNEL channel, uint16_t adcVal)
 This is the default callback function for all the analog channels. This callback is triggered once the channel conversion is done for a channel and to read the conversion result of the corresponding channel.
 
void ADC1_ComparatorCallbackRegister (void(*callback)(enum ADC_CMP comparator))
 This function can be used to override default callback and to define custom callback for ADC1_Comparator event.
 
void ADC1_ComparatorCallback (enum ADC_CMP comparator)
 Comparator callback function.
 
void ADC1_ChannelTasks (enum ADC_CHANNEL channel)
 This function call used only in polling mode, if channel conversion is done for requested channel, the calls the respective callback function.
 
void ADC1_CorePowerEnable (enum ADC_DEDICATED_CORE core)
 Enables analog and digital power for ADC1 dedicated core.
 
void ADC1_SharedCorePowerEnable (void)
 Enables power for ADC1 shared Core This function is used to set the analog and digital power for ADC1 shared Core.
 

Variables

const struct ADC_INTERFACE ADC1
 Structure object of type ADC_INTERFACE with the custom name given by the user in the Melody Driver User interface. The default name e.g. ADC1 can be changed by the user in the ADC user interface. This allows defining a structure with application specific name using the 'Custom Name' field. Application specific name allows the API Portability.
 

Detailed Description

Macro Definition Documentation

◆ ADC1_RESOLUTION

#define ADC1_RESOLUTION   12

Definition at line 67 of file adc1.h.

◆ ADC1_SCAN_MODE_SELECTED

#define ADC1_SCAN_MODE_SELECTED   true

Definition at line 61 of file adc1.h.

◆ ADC_CALIBRATION_FEATURE_AVAILABLE

#define ADC_CALIBRATION_FEATURE_AVAILABLE   1

APIs Supported:
void ADCx_CoreCalibration (enum ADC_CHANNEL channel);
void ADC_SharedCoreCalibration (void);

x denotes instance of ADC in ADCx, channel denotes dedicated Core. Refer to device specific datasheet to check number of cores and ADC module instance. Refer driver header file for detailed description of the APIs.

Definition at line 105 of file adc_features.h.

◆ ADC_COMPARATOR_FEATURE_AVAILABLE

#define ADC_COMPARATOR_FEATURE_AVAILABLE   1

APIs Supported:
void ADCx_ComparatorEnable(void);
void ADCx_ComparatorDisable(void);
void ADCx_ComparatorLowThresholdSet(uint16_t threshold );
void ADCx_ComparatorHighThresholdSet(uint16_t threshold );
uint16_t ADCx_ComparatorEventStatusGet(void);
uint16_t ADCx_ComparatorEventChannelGet(void);

x denotes instance of ADC in ADCx. Refer to device specific datasheet to check number of comparators and ADC module instance. Refer driver header file for detailed description of the APIs.

Definition at line 140 of file adc_features.h.

◆ ADC_INDIVIDUAL_CHANNEL_INTERRUPT_FEATURE_AVAILABLE

#define ADC_INDIVIDUAL_CHANNEL_INTERRUPT_FEATURE_AVAILABLE   1

APIs Supported:
void ADCx_IndividualChannelInterruptEnable (enum ADC_CHANNEL channel);
void ADCx_IndividualChannelInterruptDisable (enum ADC_CHANNEL channel);
void ADCx_IndividualChannelInterruptFlagClear (enum ADC_CHANNEL channel);

x denotes instance of ADC, channel denotes dedicated ADC channel. Refer to device specific datasheet to check number of cores and ADC module instance. Refer driver header file for detailed description of the APIs.

Definition at line 121 of file adc_features.h.

◆ ADC_POWER_ENABLE_FEATURE_AVAILABLE

#define ADC_POWER_ENABLE_FEATURE_AVAILABLE   1

IMPORTANT********

This file defines the ADC module feature C-macros available on the selected device. The macros defined in this file provides the flexibility to easily migrate the user application to other device which might have varied feature list.

The file has to be manually included in main.c, if the user intends to migrate the application to another device which might have varied feature list.

          The content in this file is strictly "read only" and should 

not be altered. Failing to do so, the migration is not guaranteed.************* Macros defined for features supported in the device

APIs Supported:
void ADCx_CorePowerEnable (enum ADC_CHANNEL channel);
void ADC_SharedCorePowerEnable (void);

x denotes instance of ADC in ADCx, channel denotes dedicated Core. Refer to device specific datasheet to check number of cores and ADC module instance. Refer driver header file for detailed description of the APIs.

Definition at line 90 of file adc_features.h.

Enumeration Type Documentation

◆ ADC_CHANNEL

Note
The enum list in the Help document might be just a reference to show the analog channel list. Generated enum list is based on the configuration done by user in the MCC Melody user interface.
Enumerator
FB_Vout 

Channel Name:S1AN10 Assigned to:Shared Channel

FB_AC_N 

Channel Name:S1AN15 Assigned to:Shared Channel

IL1_F 

Channel Name:S1AN0 Assigned to:Dedicated Core0

IL2_F 

Channel Name:S1AN1 Assigned to:Dedicated Core1

MAX_CHANNELS 

MAX_CHANNELS will be removed in future MCC releases. Use ADC_MAX_CHANNELS instead

ADC_MAX_CHANNELS 

Maximum number of channels configured by user in MCC Melody User Interface

Definition at line 55 of file adc_types.h.

◆ ADC_CMP

enum ADC_CMP
Enumerator
MAX_CMPS 

MAX_CMPS will be removed in future MCC releases. Use ADC_MAX_CMPS instead

ADC_MAX_CMPS 

Maximum Comparators configured by user in MCC Melody User Interface

Definition at line 104 of file adc_types.h.

◆ ADC_DEDICATED_CORE

Note
The enum list in the Help document might be just a reference to to show the dedicated core list. Generated enum list is based on the configuration done by user in the MCC Melody user interface.
Enumerator
CORE_0 

CORE_0 will be removed in future MCC releases. Use ADC_CORE_0 instead.

ADC_CORE_0 

Core name:ADC_CORE_0

CORE_1 

CORE_1 will be removed in future MCC releases. Use ADC_CORE_1 instead.

ADC_CORE_1 

Core name:ADC_CORE_1

MAX_DEDICATED_CORES 

MAX_DEDICATED_CORES will be removed in future MCC releases. Use ADC_MAX_DEDICATED_CORES instead

ADC_MAX_DEDICATED_CORES 

Maximum cores configured by user in MCC Melody User Interface

Definition at line 75 of file adc_types.h.

◆ ADC_PWM_INSTANCE

Note
Refer PWM_GENERATOR enum for mapping between custom name and instance
Enumerator
ADC_PWM_HS_NOT_AVAILABLE 

PWM HS not available

Definition at line 117 of file adc_types.h.

◆ ADC_PWM_TRIGGERS

Enumerator
ADC_PWM_TRIGGERS_NOT_AVAILABLE 

PWM HS triggers available

Definition at line 127 of file adc_types.h.

◆ ADC_RESOLUTION_TYPE

Enumerator
ADC_6_BIT_RESOLUTION 

ADC Resolution of 6 bit

ADC_8_BIT_RESOLUTION 

ADC Resolution of 8 bit

ADC_10_BIT_RESOLUTION 

ADC Resolution of 10 bit

ADC_12_BIT_RESOLUTION 

ADC Resolution of 12 bit

Definition at line 90 of file adc_types.h.

Function Documentation

◆ ADC1_ChannelCallback()

void ADC1_ChannelCallback ( enum ADC_CHANNEL channel,
uint16_t adcVal )
Parameters
[in]channel- conversion completed channel
[in]adcVal- conversion result of channel
Returns
none

Definition at line 521 of file adc1.c.

+ Here is the caller graph for this function:

◆ ADC1_ChannelCallbackRegister()

void ADC1_ChannelCallbackRegister ( void(*)(enum ADC_CHANNEL channel, uint16_t adcVal) callback)
Parameters
[in]callback- Address of the callback function.
Returns
none

Definition at line 513 of file adc1.c.

+ Here is the caller graph for this function:

◆ ADC1_ChannelSelect()

static void ADC1_ChannelSelect ( enum ADC_CHANNEL channel)
inlinestatic
Precondition
ADC1_Initialize() function should have been called before calling this function.
Parameters
[in]channel- Channel for conversion
Returns
none

Definition at line 161 of file adc1.h.

◆ ADC1_ChannelTasks()

void ADC1_ChannelTasks ( enum ADC_CHANNEL channel)
Precondition
ADC1_Initialize() function should have been
called before calling this function.
Parameters
[in]channel- Selected channel.
Returns
none
Note
This function has to be polled to notify channel callbacks and clear the channel interrupt flags in non-interrupt mode of ADC

Definition at line 590 of file adc1.c.

◆ ADC1_CommonCallback()

void ADC1_CommonCallback ( void )
Parameters
none
Returns
none

Definition at line 440 of file adc1.c.

+ Here is the caller graph for this function:

◆ ADC1_CommonCallbackRegister()

void ADC1_CommonCallbackRegister ( void(*)(void) callback)
Parameters
[in]callback- Address of the callback function.
Returns
none

Definition at line 432 of file adc1.c.

+ Here is the caller graph for this function:

◆ ADC1_ComparatorCallback()

void ADC1_ComparatorCallback ( enum ADC_CMP comparator)
Parameters
[in]comparator- comparator in which compare event occurred
Returns
none

Definition at line 657 of file adc1.c.

+ Here is the caller graph for this function:

◆ ADC1_ComparatorCallbackRegister()

void ADC1_ComparatorCallbackRegister ( void(*)(enum ADC_CMP comparator) callback)
Parameters
[in]callback- Address of the callback function.
Returns
none

Definition at line 649 of file adc1.c.

+ Here is the caller graph for this function:

◆ ADC1_ConversionResultGet()

static uint16_t ADC1_ConversionResultGet ( enum ADC_CHANNEL channel)
inlinestatic
Precondition
This inline function returns the conversion value only after the conversion is complete. Conversion completion status can be checked using ADC1_IsConversionComplete(channel) function.
Parameters
[in]channel- Selected channel
Returns
Returns the analog to digital converted value

Definition at line 179 of file adc1.h.

◆ ADC1_CorePowerEnable()

void ADC1_CorePowerEnable ( enum ADC_DEDICATED_CORE core)
Parameters
[in]core- Selected core
Returns
none

Definition at line 399 of file adc1.c.

+ Here is the caller graph for this function:

◆ ADC1_Deinitialize()

void ADC1_Deinitialize ( void )
Parameters
none
Returns
none

Definition at line 294 of file adc1.c.

◆ ADC1_Disable()

static void ADC1_Disable ( void )
inlinestatic
Precondition
ADC1_Initialize function should have been called before calling this function.
Parameters
none
Returns
none

Definition at line 122 of file adc1.h.

◆ ADC1_Enable()

static void ADC1_Enable ( void )
inlinestatic
Precondition
ADC1_Initialize function should have been called before calling this function.
Parameters
none
Returns
none

Definition at line 109 of file adc1.h.

◆ ADC1_IndividualChannelInterruptDisable()

static void ADC1_IndividualChannelInterruptDisable ( enum ADC_CHANNEL channel)
inlinestatic
Parameters
[in]channel- Selected channel
Returns
none

Definition at line 367 of file adc1.h.

◆ ADC1_IndividualChannelInterruptEnable()

static void ADC1_IndividualChannelInterruptEnable ( enum ADC_CHANNEL channel)
inlinestatic
Parameters
[in]channel- Selected channel
Returns
none

Definition at line 336 of file adc1.h.

◆ ADC1_IndividualChannelInterruptFlagClear()

static void ADC1_IndividualChannelInterruptFlagClear ( enum ADC_CHANNEL channel)
inlinestatic
Parameters
[in]channel- Selected channel
Returns
none

Definition at line 398 of file adc1.h.

◆ ADC1_IndividualChannelInterruptPrioritySet()

static void ADC1_IndividualChannelInterruptPrioritySet ( enum ADC_CHANNEL channel,
enum INTERRUPT_PRIORITY priorityValue )
inlinestatic
Parameters
[in]channel- Selected channel
[in]priorityValue- The numerical value of interrupt priority
Returns
none

Definition at line 426 of file adc1.h.

◆ ADC1_Initialize()

void ADC1_Initialize ( void )
Parameters
none
Returns
none

Definition at line 89 of file adc1.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ADC1_InterruptDisable()

static void ADC1_InterruptDisable ( void )
inlinestatic
Parameters
none
Returns
none

Definition at line 271 of file adc1.h.

◆ ADC1_InterruptEnable()

static void ADC1_InterruptEnable ( void )
inlinestatic
Parameters
none
Returns
none

Definition at line 260 of file adc1.h.

◆ ADC1_InterruptFlagClear()

static void ADC1_InterruptFlagClear ( void )
inlinestatic
Parameters
none
Returns
none

Definition at line 282 of file adc1.h.

◆ ADC1_InterruptPrioritySet()

static void ADC1_InterruptPrioritySet ( uint16_t priorityValue)
inlinestatic
Parameters
[in]priorityValue- The numerical value of interrupt priority
Returns
none

Definition at line 293 of file adc1.h.

◆ ADC1_IsConversionComplete()

static bool ADC1_IsConversionComplete ( enum ADC_CHANNEL channel)
inlinestatic
Precondition
ADC1_SoftwareTriggerEnable() function should have been called before calling this function.
Parameters
[in]channel- Selected channel
Returns
true - Conversion is complete.
false - Conversion is not complete.

Definition at line 215 of file adc1.h.

◆ ADC1_ResolutionSet()

static void ADC1_ResolutionSet ( enum ADC_RESOLUTION_TYPE resolution)
inlinestatic
Parameters
[in]resolution- Resolution type
Returns
none

Definition at line 247 of file adc1.h.

◆ ADC1_SharedCorePowerEnable()

void ADC1_SharedCorePowerEnable ( void )
Parameters
none
Returns
none

Definition at line 423 of file adc1.c.

+ Here is the caller graph for this function:

◆ ADC1_SoftwareTriggerDisable()

static void ADC1_SoftwareTriggerDisable ( void )
inlinestatic
Precondition
ADC1_Initialize function should have been called before calling this function.
Parameters
none
Returns
none

Definition at line 148 of file adc1.h.

◆ ADC1_SoftwareTriggerEnable()

static void ADC1_SoftwareTriggerEnable ( void )
inlinestatic
Precondition
ADC1_Initialize function should have been called before calling this function.
Parameters
none
Returns
none

Definition at line 135 of file adc1.h.

◆ ADC1_Tasks()

void ADC1_Tasks ( void )
Precondition
ADC1_Initialize() function should have been called before calling this function.
Parameters
none
Returns
none
Note
This function has to be polled to notify callbacks and clear the interrupt flags in non-interrupt mode of ADC

Definition at line 499 of file adc1.c.

Variable Documentation

◆ ADC1

const struct ADC_INTERFACE ADC1
extern

Definition at line 67 of file adc1.c.