GLOBAL_ADC
|
GLOBAL_ADC.c
Go to the documentation of this file.
00001 00072 /*********************************************************************************************************************** 00073 * HEADER FILES 00074 **********************************************************************************************************************/ 00075 00077 #include "global_adc.h" 00078 00079 /*********************************************************************************************************************** 00080 * MACROS 00081 **********************************************************************************************************************/ 00082 00083 /*********************************************************************************************************************** 00084 * LOCAL DATA 00085 **********************************************************************************************************************/ 00086 00087 /*********************************************************************************************************************** 00088 * LOCAL ROUTINES 00089 **********************************************************************************************************************/ 00090 00091 /********************************************************************************************************************** 00092 * API IMPLEMENTATION 00093 **********************************************************************************************************************/ 00094 00095 /*This function returns the version of the GLOBAL_ADC APP*/ 00096 DAVE_APP_VERSION_t GLOBAL_ADC_GetAppVersion(void) 00097 { 00098 DAVE_APP_VERSION_t version; 00099 00100 version.major = (uint8_t) GLOBAL_ADC_MAJOR_VERSION; 00101 version.minor = (uint8_t) GLOBAL_ADC_MINOR_VERSION; 00102 version.patch = (uint8_t) GLOBAL_ADC_PATCH_VERSION; 00103 00104 return version; 00105 } 00106 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ 00110 GLOBAL_ADC_STATUS_t GLOBAL_ADC_Init(GLOBAL_ADC_t *const handle_ptr) 00111 { 00112 XMC_ASSERT("GLOBAL_ADC_Init:Invalid handle_ptr", (handle_ptr != NULL)) 00113 #if (XMC_VADC_GROUP_AVAILABLE == 1U) 00114 uint32_t group_index; 00115 #endif 00116 00117 if (GLOBAL_ADC_UNINITIALIZED == handle_ptr->init_state) 00118 { 00119 /* Initialize an instance of Global hardware */ 00120 XMC_VADC_GLOBAL_Init(handle_ptr->module_ptr, handle_ptr->global_config_handle); 00121 00122 /* Initialize all the Groups */ 00123 #if (XMC_VADC_GROUP_AVAILABLE == 1U) 00124 for(group_index = (uint32_t)0; group_index < XMC_VADC_MAXIMUM_NUM_GROUPS; group_index++) 00125 { 00126 /*Initialize Group*/ 00127 XMC_VADC_GROUP_Init(handle_ptr->group_ptrs_array[group_index]->group_handle, 00128 handle_ptr->group_ptrs_array[group_index]->group_config_handle); 00129 00130 /* Switch on the converter of the Group[group_index]*/ 00131 XMC_VADC_GROUP_SetPowerMode(handle_ptr->group_ptrs_array[group_index]->group_handle, 00132 XMC_VADC_GROUP_POWERMODE_NORMAL); 00133 00134 /* Disable the post calibration option for the respective group*/ 00135 if ((bool)false == handle_ptr->group_ptrs_array[group_index]->post_calibration) 00136 { 00137 XMC_VADC_GLOBAL_DisablePostCalibration(handle_ptr->module_ptr,group_index); 00138 } 00139 00140 #if(XMC_VADC_SHS_AVAILABLE == 1U) 00141 XMC_VADC_GLOBAL_SHS_EnableAcceleratedMode(handle_ptr->global_shs_ptr, (XMC_VADC_GROUP_INDEX_t)group_index); 00142 #endif 00143 00144 handle_ptr->group_ptrs_array[group_index]->state = GLOBAL_ADC_SUCCESS; 00145 } 00146 #endif /* _XMC_VADC_GROUP_AVAILABLE_ */ 00147 if((bool)true == handle_ptr->enable_startup_calibration) 00148 { 00149 XMC_VADC_GLOBAL_StartupCalibration(handle_ptr->module_ptr); 00150 } 00151 handle_ptr->init_state = GLOBAL_ADC_SUCCESS; 00152 } 00153 return (handle_ptr->init_state); 00154 }