diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2019-04-28 19:35:39 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2019-04-28 19:35:39 +0300 |
| commit | 3bed1b881037c06d160573583be4d85dc186d3a7 (patch) | |
| tree | a5589db7ec95ab23e378247effe1a6a178c73a40 /Software/Embedded_SW/Embedded/Main.c | |
| parent | 4dd32805d32e9e5e0769d12e537c81383563810f (diff) | |
| download | Tango-3bed1b881037c06d160573583be4d85dc186d3a7.tar.gz Tango-3bed1b881037c06d160573583be4d85dc186d3a7.zip | |
version 1.3.9.3: segments and gradients handling, diagnostics is faster. code faiure handling
Diffstat (limited to 'Software/Embedded_SW/Embedded/Main.c')
| -rw-r--r-- | Software/Embedded_SW/Embedded/Main.c | 94 |
1 files changed, 81 insertions, 13 deletions
diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index a125ef10c..64bac419e 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -25,6 +25,12 @@ #include "Communication/CommunicationTask.h" +#include <xdc/runtime/Error.h> +#include <xdc/runtime/System.h> +#include <xdc/runtime/Types.h> + +#include <xdc/runtime/Main.h> +#include <xdc/runtime/Assert.h> #include <drivers/Flash_Memory/Flash_Memory.h> #include "drivers/Flash_ram/FlashProgram.h" @@ -67,7 +73,10 @@ #include "Modules/General/buttons.h" #include "Modules/Waste/Waste.h" +#include <Drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.h> //#define WATCHDOG + + //***************************************************************************** // // The system tick rate expressed both as ticks per second and a millisecond @@ -76,6 +85,7 @@ //***************************************************************************** #define TICKS_PER_SECOND 1000 + //***************************************************************************** // // Global system tick counter @@ -94,19 +104,75 @@ F1_GPO_REG F1_GPO_Reg; F3_GPO_01_REG F3_GPO_01_Reg; -//MessageContainer createContainer(MessageType type, char* token, protobuf_c_boolean completed, void* response, size_t (*packPtr)(void*, uint8_t*), size_t (*sizePtr)(void*)); -uint32_t MainDummyFunction(uint32_t IfIndex, uint32_t ReadValue) -{ - return OK; -} -uint32_t HWControlId; +Types_Site *site; +Error_Id eid; +int eCode; -uint32_t MainHWInitCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) +/* ======== errHook ======== */ +Void errHook(Error_Block *eb) { - RemoveControlCallback(HWControlId, MainHWInitCallBackFunction ); - HWConfigurationInit(); - return OK; + FRESULT Fresult = FR_OK; + FIL *FileHandle = 0; //the system supports a single active file + uint32_t Bytes = 0; + char ErrorPath[50] = "0://ErrorFile.txt"; + char File[50] = ""; + char message[300]; + int len; + + STATUS_GREEN_LED_OFF; + ACTIVITY_GREEN_LED_OFF; + COMM_GREEN_LED_OFF; + + STATUS_RED_LED_ON; + ACTIVITY_RED_LED_ON; + COMM_RED_LED_ON; + + site = Error_getSite(eb); + eid = Error_getId(eb); + eCode = Error_getCode(eb); + FileHandle = my_malloc(sizeof(FIL)); + if (FileHandle == 0) + Fresult = FR_DENIED; + else + { + Fresult = f_open(FileHandle,ErrorPath,FA_OPEN_ALWAYS | FA_WRITE | FA_READ); + if (Fresult == FR_OK) + { + strcpy(File,site->file); + len = usnprintf(message, 80, "\r\n%s %s %s",__DATE__, __TIME__,File); + Fresult = f_write(FileHandle,message,len,&Bytes ); + /* print user supplied error code */ + len = usnprintf(message, 300, "\r\nerror %d, eid %d file %s line %d mod %d", + eCode, eid, site->file, + site->line, + site->mod); + Fresult = f_write(FileHandle,message,len,&Bytes ); + + LOG_ERROR (eCode, "error # "); + /* check originator's mod id against known mods */ + if (site->mod == Main_Module_id()) { + Fresult = f_write(FileHandle,"\r\napp error: ",12,&Bytes ); + } + + /* check error id against known errors */ + if (eid == Error_E_generic) { + Fresult = f_write(FileHandle,"generic: ",10,&Bytes ); + } + else if (eid == Assert_E_assertFailed) { + System_printf("assertion violation: "); + Fresult = f_write(FileHandle,"\r\nassertion violation: ",22,&Bytes ); + } + + /* perform default error output */ + f_close(FileHandle); + } + Task_sleep (200); + my_free(FileHandle); + } + //Power_Reset(); + SysCtlReset(); } + //***************************************************************************** // // Interrupt handler for the system tick counter. @@ -177,7 +243,7 @@ int main(void) #endif #ifdef WATCHDOG - InitWatchdog(ui32SysClock); + InitWatchdog(ui32SysClock*2); #endif CommunicationTaskInit(); @@ -196,8 +262,8 @@ int main(void) Heaters_Init(); MotorsInit(); //Shai WHS_HW_test(); // for WHS sensor test - WHS_init(); - Buttons_Init(); + //WHS_init(); + //Buttons_Init(); //IDS_ModuleInit(); Valve_Set(VALVE_MIXCHIP_WASTECH, Mixer_Waste); @@ -224,6 +290,8 @@ int main(void) //I2C_NFC_Test(); // //test_avi(); //example for shai + Init_Dispensers_IO_Registers(&Disp_IO_Reg); + Set_Speed_Sensor_TypeII_Registers(2,2);//set default values //Read_Speed_Sensor_TypeII();//must be delay between Set_Speed_Sensor_TypeII_Registers to Read_Speed_Sensor_TypeII |
