GLOBAL_SCU_XMC1
|
GLOBAL_SCU_XMC1.c
Go to the documentation of this file.
00001 00055 /*********************************************************************************************************************** 00056 * HEADER FILES 00057 **********************************************************************************************************************/ 00058 #include "global_scu_xmc1.h" 00059 /*********************************************************************************************************************** 00060 * MACROS 00061 **********************************************************************************************************************/ 00062 #define GLOBAL_SCU_XMC1_CHECK_EVENT(event) ((event == GLOBAL_SCU_XMC1_EVENT_WDT_WARNING) || \ 00063 (event == GLOBAL_SCU_XMC1_EVENT_RTC_PERIODIC) || \ 00064 (event == GLOBAL_SCU_XMC1_EVENT_RTC_ALARM) || \ 00065 (event == GLOBAL_SCU_XMC1_EVENT_LOSS_EXT_CLOCK) || \ 00066 (event == GLOBAL_SCU_XMC1_EVENT_DCO1_OUT_SYNC)) 00067 00068 /*********************************************************************************************************************** 00069 * LOCAL DATA 00070 **********************************************************************************************************************/ 00071 00072 /*********************************************************************************************************************** 00073 * LOCAL ROUTINES 00074 **********************************************************************************************************************/ 00075 #if (UC_SERIES != XMC14) 00076 void SCU_0_IRQHandler(void); 00077 void SCU_1_IRQHandler(void); 00078 void SCU_2_IRQHandler(void); 00079 #else 00080 void IRQ0_Handler(void); 00081 void IRQ1_Handler(void); 00082 void IRQ2_Handler(void); 00083 #endif 00084 /********************************************************************************************************************** 00085 * API IMPLEMENTATION 00086 **********************************************************************************************************************/ 00087 00088 /* 00089 * API to retrieve the version of the GLOBAL_SCU_XMC1 APP 00090 */ 00091 DAVE_APP_VERSION_t GLOBAL_SCU_XMC1_GetAppVersion(void) 00092 { 00093 DAVE_APP_VERSION_t version; 00094 00095 version.major = GLOBAL_SCU_XMC1_MAJOR_VERSION; 00096 version.minor = GLOBAL_SCU_XMC1_MINOR_VERSION; 00097 version.patch = GLOBAL_SCU_XMC1_PATCH_VERSION; 00098 00099 return (version); 00100 } 00101 00102 /* Function to configure SCU Interrupts based on user configuration. 00103 * 00104 */ 00105 GLOBAL_SCU_XMC1_STATUS_t GLOBAL_SCU_XMC1_Init(GLOBAL_SCU_XMC1_t*const handle) 00106 { 00107 GLOBAL_SCU_XMC1_STATUS_t initstatus; 00108 00109 XMC_ASSERT("GLOBAL_SCU_XMC1_Init:HandlePtr NULL", (handle != NULL)); 00110 00111 initstatus = (GLOBAL_SCU_XMC1_STATUS_t)CPU_CTRL_XMC1_Init(CPU_CTRL_HANDLE); 00112 00113 if (initstatus == GLOBAL_SCU_XMC1_STATUS_SUCCESS) 00114 { 00115 if (handle->initialized == false) 00116 { 00117 NVIC_SetPriority((IRQn_Type)0U,handle->config->priority[0]); 00118 NVIC_SetPriority((IRQn_Type)1U,handle->config->priority[1]); 00119 NVIC_SetPriority((IRQn_Type)2U,handle->config->priority[2]); 00120 00121 /* enable the IRQ0 */ 00122 if (handle->config->enable_at_init[0] == true) 00123 { 00124 #if (UC_SERIES == XMC14) 00125 XMC_SCU_SetInterruptControl(0, XMC_SCU_IRQCTRL_SCU_SR0_IRQ0); 00126 #endif 00127 NVIC_EnableIRQ((IRQn_Type)0U); 00128 } 00129 /* enable the IRQ1 */ 00130 if (handle->config->enable_at_init[1] == true) 00131 { 00132 #if (UC_SERIES == XMC14) 00133 XMC_SCU_SetInterruptControl(1, XMC_SCU_IRQCTRL_SCU_SR1_IRQ1); 00134 #endif 00135 NVIC_EnableIRQ((IRQn_Type)1U); 00136 } 00137 /* enable the IRQ2 */ 00138 if (handle->config->enable_at_init[2] == true) 00139 { 00140 #if (UC_SERIES == XMC14) 00141 XMC_SCU_SetInterruptControl(2, XMC_SCU_IRQCTRL_SCU_SR2_IRQ2); 00142 #endif 00143 NVIC_EnableIRQ((IRQn_Type)2U); 00144 } 00145 handle->initialized = true; 00146 } 00147 else 00148 { 00149 initstatus = GLOBAL_SCU_XMC1_STATUS_SUCCESS; 00150 } 00151 } 00152 else 00153 { 00154 initstatus = GLOBAL_SCU_XMC1_STATUS_FAILURE; 00155 } 00156 00157 return (initstatus); 00158 } 00159 00160 #if (UC_SERIES != XMC14) 00161 /* 00162 * @brief SCU_0 Interrupt Handler 00163 */ 00164 void SCU_0_IRQHandler(void) 00165 { 00166 XMC_SCU_IRQHandler(0); 00167 } 00168 00169 /* SCU_1 Interrupt Handler. 00170 * 00171 */ 00172 void SCU_1_IRQHandler(void) 00173 { 00174 XMC_SCU_IRQHandler(1); 00175 } 00176 00177 /* SCU2 Interrupt Handler. 00178 * 00179 */ 00180 void SCU_2_IRQHandler(void) 00181 { 00182 XMC_SCU_IRQHandler(2); 00183 } 00184 #else 00185 /* 00186 * @brief IRQ0 Interrupt Handler 00187 */ 00188 void IRQ0_Handler(void) 00189 { 00190 XMC_SCU_IRQHandler(0); 00191 } 00192 00193 /* IRQ1 Interrupt Handler. 00194 * 00195 */ 00196 void IRQ1_Handler(void) 00197 { 00198 XMC_SCU_IRQHandler(1); 00199 } 00200 00201 /* IRQ2 Interrupt Handler. 00202 * 00203 */ 00204 void IRQ2_Handler(void) 00205 { 00206 XMC_SCU_IRQHandler(2); 00207 } 00208 00209 #endif 00210 00211 /* 00212 * @brief Function to register callback event 00213 */ 00214 GLOBAL_SCU_XMC1_STATUS_t GLOBAL_SCU_XMC1_RegisterCallback(const GLOBAL_SCU_XMC1_EVENT_t event, 00215 const GLOBAL_SCU_XMC1_EVENT_HANDLER_t handler) 00216 { 00217 GLOBAL_SCU_XMC1_STATUS_t status; 00218 00219 XMC_ASSERT("GLOBAL_SCU_XMC1_RegisterCallback: Invalid event", (GLOBAL_SCU_XMC1_CHECK_EVENT(event))); 00220 XMC_ASSERT("GLOBAL_SCU_XMC1_RegisterCallback: NULL Handle", (handler != NULL)); 00221 00222 status = (GLOBAL_SCU_XMC1_STATUS_t)XMC_SCU_INTERRUPT_SetEventHandler(event, handler); 00223 00224 return (status); 00225 }