GLOBAL_ADC: GLOBAL_ADC.c Source File

Modbus RTU XMC47

GLOBAL_ADC.c
Go to the documentation of this file.
1 
78 /***********************************************************************************************************************
79  * HEADER FILES
80  **********************************************************************************************************************/
81 
83 #include "global_adc.h"
84 
85 /***********************************************************************************************************************
86  * MACROS
87  **********************************************************************************************************************/
88 
89 /***********************************************************************************************************************
90  * LOCAL DATA
91  **********************************************************************************************************************/
92 
93 /***********************************************************************************************************************
94  * LOCAL ROUTINES
95  **********************************************************************************************************************/
96 
97  /**********************************************************************************************************************
98  * API IMPLEMENTATION
99  **********************************************************************************************************************/
100 
101 /*This function returns the version of the GLOBAL_ADC APP*/
102 DAVE_APP_VERSION_t GLOBAL_ADC_GetAppVersion(void)
103 {
104  DAVE_APP_VERSION_t version;
105 
106  version.major = (uint8_t) GLOBAL_ADC_MAJOR_VERSION;
107  version.minor = (uint8_t) GLOBAL_ADC_MINOR_VERSION;
108  version.patch = (uint8_t) GLOBAL_ADC_PATCH_VERSION;
109 
110  return version;
111 }
112 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
117 {
118  XMC_ASSERT("GLOBAL_ADC_Init:Invalid handle_ptr", (handle_ptr != NULL))
119 #if (XMC_VADC_GROUP_AVAILABLE == 1U)
120  uint32_t group_index;
121 #endif
122 
123  if (GLOBAL_ADC_UNINITIALIZED == handle_ptr->init_state)
124  {
125  /* Initialize an instance of Global hardware */
126  XMC_VADC_GLOBAL_Init(handle_ptr->module_ptr, handle_ptr->global_config_handle);
127 
128  /* Initialize all the Groups */
129 #if (XMC_VADC_GROUP_AVAILABLE == 1U)
130  for(group_index = (uint32_t)0; group_index < XMC_VADC_MAXIMUM_NUM_GROUPS; group_index++)
131  {
132  /*Initialize Group*/
133  XMC_VADC_GROUP_Init(handle_ptr->group_ptrs_array[group_index]->group_handle,
134  handle_ptr->group_ptrs_array[group_index]->group_config_handle);
135 
136  /* Switch on the converter of the Group[group_index]*/
137  XMC_VADC_GROUP_SetPowerMode(handle_ptr->group_ptrs_array[group_index]->group_handle,
138  XMC_VADC_GROUP_POWERMODE_NORMAL);
139 
140  /* Disable the post calibration option for the respective group*/
141  if ((bool)false == handle_ptr->group_ptrs_array[group_index]->post_calibration)
142  {
143  XMC_VADC_GLOBAL_DisablePostCalibration(handle_ptr->module_ptr,group_index);
144  }
145 
146 #if(XMC_VADC_SHS_AVAILABLE == 1U)
147  XMC_VADC_GLOBAL_SHS_EnableAcceleratedMode(handle_ptr->global_shs_ptr, (XMC_VADC_GROUP_INDEX_t)group_index);
148 #endif
149 
150  handle_ptr->group_ptrs_array[group_index]->state = GLOBAL_ADC_SUCCESS;
151  }
152 #if(XMC_VADC_SHS_AVAILABLE == 1U)
153  XMC_VADC_GLOBAL_SHS_SetClockDivider(handle_ptr->global_shs_ptr, (uint8_t) GLOBAL_ADC_DIVS_VALUE);
154 #endif
155 #endif /* _XMC_VADC_GROUP_AVAILABLE_ */
156 #if(XMC_VADC_SHS_AVAILABLE == 1U)
157  XMC_VADC_GLOBAL_SHS_SetAnalogReference(handle_ptr->global_shs_ptr, GLOBAL_ADC_AREF_VALUE);
158 #endif
159  if((bool)true == handle_ptr->enable_startup_calibration)
160  {
161  XMC_VADC_GLOBAL_StartupCalibration(handle_ptr->module_ptr);
162  }
163  handle_ptr->init_state = GLOBAL_ADC_SUCCESS;
164  }
165  return (handle_ptr->init_state);
166 }