diff options
| author | Avi Levkovich <avi@twine-s.com> | 2019-04-23 18:12:04 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2019-04-23 18:12:04 +0300 |
| commit | f66316aa44ae0d45e24ddf97ac14205ea9ad5cc6 (patch) | |
| tree | 1d5dd66acd36adfbb7898afed26a8d290a299165 /Software/Embedded_SW | |
| parent | 8fee48ffc4ac129074cd6c240cd9098cc4c7e0c6 (diff) | |
| download | Tango-f66316aa44ae0d45e24ddf97ac14205ea9ad5cc6.tar.gz Tango-f66316aa44ae0d45e24ddf97ac14205ea9ad5cc6.zip | |
add function to init the I/O registers in all the dispenser's card at once
Diffstat (limited to 'Software/Embedded_SW')
4 files changed, 129 insertions, 14 deletions
diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.c index 790f77f8a..3d1ad4f8c 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.c @@ -15,6 +15,8 @@ #include <Drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.h> #include <Drivers/I2C_Communication/I2C.h> +TCA9534Regs* Disp_IO_Reg; + uint8_t TCA9534Init(uint8_t Dispenser_ID, TCA9534Regs* Regs)//1 { uint8_t status = PASSED; @@ -267,6 +269,43 @@ uint8_t TCA9534ByPass(uint8_t Dispenser_ID, TCA9534Regs* Regs, bool EnableByPass } +uint8_t Init_Dispensers_IO_Registers(TCA9534Regs* Regs) +{ + uint8_t status = PASSED; + + uint8_t i; + + for(i=0;i<8;i++) + { + if(Dispenser_struct[i].Type == DISP_TYPE_EEPROM128KB) + { + status |= TCA9534Init(i, &Regs); + } + } + + return status; +} + +uint8_t Read_Dispensers_IO_Registers(TCA9534Regs* Regs) +{ + uint8_t status = PASSED; + + uint8_t i; + + for(i=0;i<8;i++) + { + if(Dispenser_struct[i].Type == DISP_TYPE_EEPROM128KB) + { + status |= TCA9534SetReadInputReg(i); + status |= TCA9534ReadInputReg(i, &Regs); + } + } + + return status; +} + + + bool Read_Notification_Disp_UP(uint8_t Dispenser_ID, TCA9534Regs* Regs) { return Regs->Input[Dispenser_ID].bit.DISP_UP; diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.h index af1470da5..e8784a2ff 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.h +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/Dispenser_Card/IO_Ports/Dispenser_IO.h @@ -50,6 +50,8 @@ typedef struct { TCA9534_union Config[8]; } TCA9534Regs; +extern TCA9534Regs* Disp_IO_Reg; + uint8_t TCA9534Init(uint8_t Dispenser_ID, TCA9534Regs* Regs); uint8_t TCA9534SetReadInputReg(uint8_t Dispenser_ID); uint8_t TCA9534ReadInputReg(uint8_t Dispenser_ID, TCA9534Regs* Regs); @@ -61,5 +63,7 @@ bool Read_Notification_Disp_Down(uint8_t Dispenser_ID, TCA9534Regs* Regs); bool Read_Notification_Realy_On(uint8_t Dispenser_ID, TCA9534Regs* Regs); bool Read_Notification_Over_Press(uint8_t Dispenser_ID, TCA9534Regs* Regs); uint8_t test_IO(); +uint8_t Init_Dispensers_IO_Registers(TCA9534Regs* Regs); +uint8_t Read_Dispensers_IO_Registers(TCA9534Regs* Regs); #endif /* DRIVERS_I2C_COMMUNICATION_DISPENSERS_IO_PORT_IO_H_ */ diff --git a/Software/Embedded_SW/Embedded/Embedded.cfg b/Software/Embedded_SW/Embedded/Embedded.cfg index 7efea86f4..1127c5a30 100644 --- a/Software/Embedded_SW/Embedded/Embedded.cfg +++ b/Software/Embedded_SW/Embedded/Embedded.cfg @@ -212,7 +212,16 @@ var Text = xdc.useModule('xdc.runtime.Text'); Text.isLoaded = true; //Text.isLoaded = false; - +/* ================ Error configuration ================ */ +/* set errHook (defined in main.c) as the error + * hook function. Strings begining with '&' + * can be assigned to function pointers to + * reference unspecified external functions + */ +Error.raiseHook = "&errHook"; + +/* set user-defined code for E_generic errors */ +Error.E_generic.code = 28; /* ================ Types configuration ================ */ var Types = xdc.useModule('xdc.runtime.Types'); diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index a125ef10c..fbdbe04a4 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,11 @@ #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 +86,7 @@ //***************************************************************************** #define TICKS_PER_SECOND 1000 + //***************************************************************************** // // Global system tick counter @@ -94,19 +105,71 @@ 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://SysInfo//ErrorFile.txt"; + 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) + { + len = usnprintf(message, 80, "%s %s",__DATE__, __TIME__); + Fresult = f_write(FileHandle,message,len,&Bytes ); + /* print user supplied error code */ + len = usnprintf(message, 300, "error %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,"app 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,"assertion violation: ",22,&Bytes ); + } + + /* perform default error output */ + f_close(FileHandle); + } + my_free(FileHandle); + } + Power_Reset(); } + //***************************************************************************** // // Interrupt handler for the system tick counter. @@ -177,7 +240,7 @@ int main(void) #endif #ifdef WATCHDOG - InitWatchdog(ui32SysClock); + InitWatchdog(ui32SysClock*2); #endif CommunicationTaskInit(); @@ -225,6 +288,8 @@ int main(void) // //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 @@ -242,8 +307,6 @@ int main(void) IDLE_TASK_package_init(); -// HWControlId = AddControlCallback( MainHWInitCallBackFunction, 2* eOneSecond/*eHundredMillisecond*/, MainDummyFunction,0,0, 0 ); - Start_InitSequence(); PowerIdleInit(); BIOS_start(); |
