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
Diff: error_handler.cpp
- Revision:
- 12:a25bdf135348
- Child:
- 14:6bcec5ac21ca
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/error_handler.cpp Mon Jan 14 16:39:41 2019 +0000 @@ -0,0 +1,78 @@ +#include "mbed.h" +#include "Electric_Loco.h" +/*class error_handling_Jan_2019 +{ + int32_t TS_fault[NUMOF_REPORTABLE_TS_ERRORS] ; // Some number of reportable error codes, accessible through set and read members + public: + error_handling_Jan_2019 () { // default constructor + for (int i = 0; i < (sizeof(TS_fault) / sizeof(int32_t)); i++) + TS_fault[i] = 0; + } + void set (uint32_t, int32_t) ; + uint32_t read (uint32_t) ; + bool all_good () ; + void report_any () ; +} ; +*/ + +const char * FaultList[] = { +/* + FAULT_0, + FAULT_BOARD_ID_IN_MSG, + FAULT_TS, + FAULT_PC, + FAULT_COM, + FAULT_COM_NO_MATCH, + FAULT_COM_LINE_LEN, + FAULT_QSPI, + FAULT_ODOMETER, + FAULT_MAX, + NUMOF_REPORTABLE_TS_ERRORS +*/ + "Zero", + "BoardID in msg", + "TouchScreen", + "pc", + "com no match", + "com line len", + "qspi", + "odometer", + "max", + "endoflist", + " ", + } ; + +bool error_handling_Jan_2019::all_good () { + for (int i = 0; i < NUMOF_REPORTABLE_TS_ERRORS; i++) + if (TS_fault[i]) + return false; + return true; +} + +/**void error_handling_Jan_2019::set (uint32_t err_no, int32_t bits_to_set) { + Used to set bits in error int + Uses OR to set new bits without clearing other bits set previously +*/ +void error_handling_Jan_2019::set (uint32_t err_no, int32_t bits_to_set) { + TS_fault[err_no] |= bits_to_set; // Uses OR to set new bits without clearing other bits set previously +} + +/**void error_handling_Jan_2019::clr (uint32_t err_no) { + Used to clear all bits in error int +*/ +void error_handling_Jan_2019::clr (uint32_t err_no) { + TS_fault[err_no] = 0; +} + +uint32_t error_handling_Jan_2019::read (uint32_t err_no) { + return TS_fault[err_no]; +} + +extern Serial pc; +void error_handling_Jan_2019::report_any () { + for (int i = 0; i < NUMOF_REPORTABLE_TS_ERRORS; i++) { + if (TS_fault[i]) + pc.printf ("Error report, number %d, value %d, %s\r\n", i, TS_fault[i], FaultList[i]); + } +} +