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
- Committer:
- JonFreeman
- Date:
- 2019-03-04
- Revision:
- 14:6bcec5ac21ca
- Parent:
- 12:a25bdf135348
File content as of revision 14:6bcec5ac21ca:
#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]);
}
}
*/
void error_handling_Jan_2019::report_any (bool retain) {
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]);
if (!retain)
TS_fault[i] = 0;
}
}
}