-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupporting_functions.c
More file actions
52 lines (47 loc) · 1.91 KB
/
supporting_functions.c
File metadata and controls
52 lines (47 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
******************************************************************************
* File Name : supporting_functions.c
* Description : User defined common functions that can be used across projects
* Author : Ashraf Suyyagh
* Version : 1.0.0
* Date : January 14th, 2016
******************************************************************************
*/
#include "supporting_functions.h"
/**
* @brief A function used to relay information (PRINTF) that a specific error has occured
* and gets the system into infinite loop. User can modify the output error message
* @retval None
*/
//AT TAs & STUDENTS
//Feel free to use or discard this function, you can add more Error definitions and assign
//them codes in the supporting_functions.h file
//Many functions in the drivers return a status code, usually HAL_OK or HAL_ERROR. You can check
//the output of your driver function call and either proceed or call this function to print
//whatever error message you want. Helps you in debugging your code at many points during developing
//your codes
void Error_Handler (uint16_t error_code){
//User error handling code, could use printf to relay information to user
switch (error_code){
case RCC_CONFIG_FAIL:
printf("ERROR: Error in initialising System Clocks \n");
break;
case TIM_INIT_FAIL:
printf("ERROR: Error in initialising Timer base \n");
break;
case ADC_INIT_FAIL:
printf("ERROR: Error in initialising ADC \n");
break;
case ADC_CH_CONFIG_FAIL:
printf("ERROR: Error in initialising ADC Channel Configuration \n");
break;
case ADC_MULTIMODE_FAIL:
printf("ERROR: Error in initialising ADC Multimode\\DMA \n");
break;
case EXTI_SPI1_FAIL:
printf("ERROR: Error in initialising SPI1 \n");
break;
default: printf ("ERROR: AN ERROR OCCURED \n");
break;
}
}