Touch screen drivers control dashboard for miniature locomotive. Features meters for speed, volts, power. Switches for lights, horns. Drives multiple STM3_ESC brushless motor controllers for complete brushless loco system as used in "The Brute" - www.jons-workshop.com
Dependencies: TS_DISCO_F746NG mbed Servo LCD_DISCO_F746NG BSP_DISCO_F746NG QSPI_DISCO_F746NG AsyncSerial FastPWM
error_handler.cpp
00001 #include "mbed.h" 00002 #include "Electric_Loco.h" 00003 /*class error_handling_Jan_2019 00004 { 00005 int32_t TS_fault[NUMOF_REPORTABLE_TS_ERRORS] ; // Some number of reportable error codes, accessible through set and read members 00006 public: 00007 error_handling_Jan_2019 () { // default constructor 00008 for (int i = 0; i < (sizeof(TS_fault) / sizeof(int32_t)); i++) 00009 TS_fault[i] = 0; 00010 } 00011 void set (uint32_t, int32_t) ; 00012 uint32_t read (uint32_t) ; 00013 bool all_good () ; 00014 void report_any () ; 00015 } ; 00016 */ 00017 00018 const char * FaultList[] = { 00019 /* 00020 FAULT_0, 00021 FAULT_BOARD_ID_IN_MSG, 00022 FAULT_TS, 00023 FAULT_PC, 00024 FAULT_COM, 00025 FAULT_COM_NO_MATCH, 00026 FAULT_COM_LINE_LEN, 00027 FAULT_QSPI, 00028 FAULT_ODOMETER, 00029 FAULT_MAX, 00030 NUMOF_REPORTABLE_TS_ERRORS 00031 */ 00032 "Zero", 00033 "BoardID in msg", 00034 "TouchScreen", 00035 "pc", 00036 "com no match", 00037 "com line len", 00038 "qspi", 00039 "odometer", 00040 "max", 00041 "endoflist", 00042 " ", 00043 } ; 00044 00045 bool error_handling_Jan_2019::all_good () { 00046 for (int i = 0; i < NUMOF_REPORTABLE_TS_ERRORS; i++) 00047 if (TS_fault[i]) 00048 return false; 00049 return true; 00050 } 00051 00052 /**void error_handling_Jan_2019::set (uint32_t err_no, int32_t bits_to_set) { 00053 Used to set bits in error int 00054 Uses OR to set new bits without clearing other bits set previously 00055 */ 00056 void error_handling_Jan_2019::set (uint32_t err_no, int32_t bits_to_set) { 00057 TS_fault[err_no] |= bits_to_set; // Uses OR to set new bits without clearing other bits set previously 00058 } 00059 00060 /**void error_handling_Jan_2019::clr (uint32_t err_no) { 00061 Used to clear all bits in error int 00062 */ 00063 void error_handling_Jan_2019::clr (uint32_t err_no) { 00064 TS_fault[err_no] = 0; 00065 } 00066 00067 uint32_t error_handling_Jan_2019::read (uint32_t err_no) { 00068 return TS_fault[err_no]; 00069 } 00070 00071 extern Serial pc; 00072 /*void error_handling_Jan_2019::report_any () { 00073 for (int i = 0; i < NUMOF_REPORTABLE_TS_ERRORS; i++) { 00074 if (TS_fault[i]) 00075 pc.printf ("Error report, number %d, value %d, %s\r\n", i, TS_fault[i], FaultList[i]); 00076 } 00077 } 00078 */ 00079 00080 void error_handling_Jan_2019::report_any (bool retain) { 00081 for (int i = 0; i < NUMOF_REPORTABLE_TS_ERRORS; i++) { 00082 if (TS_fault[i]) { 00083 pc.printf ("Error report, number %d, value %d, %s\r\n", i, TS_fault[i], FaultList[i]); 00084 if (!retain) 00085 TS_fault[i] = 0; 00086 } 00087 } 00088 } 00089
Generated on Thu Jul 14 2022 06:50:34 by 1.7.2