diff options
| author | Avi Levkovich <avi@twine-s.com> | 2020-08-25 10:08:01 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2020-08-25 10:08:01 +0300 |
| commit | 338edba081dba2a2aefb634811be1cc84ec93d64 (patch) | |
| tree | 0021538796c254a8eab8527e8461a2e831e68c1c /Software/Embedded_SW/Embedded/Common | |
| parent | 49ddda1cc22d6cbb72f499b37e5db32c95252dfa (diff) | |
| download | Tango-338edba081dba2a2aefb634811be1cc84ec93d64.tar.gz Tango-338edba081dba2a2aefb634811be1cc84ec93d64.zip | |
merge
Diffstat (limited to 'Software/Embedded_SW/Embedded/Common')
5 files changed, 94 insertions, 21 deletions
diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c index 013a06e22..3a1a4ab83 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c @@ -56,14 +56,15 @@ uint32_t ActivateVersionCallBackFunction(uint32_t IfIndex, uint32_t BusyFlag) MessageContainer responseContainer; bool last = true; - usnprintf(activateString, 1000, "file %d of %d bytes %d of %d",CurrentRunningFile+1,NumberOfFiles,vme_index,CurrentFileSize); - - Report(activateString,__FILE__,__LINE__,(int)CurrentRunningFile,RpWarning,CurrentFileSize,0); - if (CurrentRunningFile<NumberOfFiles) { last = false; } + + usnprintf(activateString, 1000, "file %d of %d bytes %d of %d last %d",CurrentRunningFile+1,NumberOfFiles,vme_index,CurrentFileSize,last); + + Report(activateString,__FILE__,__LINE__,(int)CurrentRunningFile,RpWarning,CurrentFileSize,0); + responseContainer = createContainer(MESSAGE_TYPE__ActivateVersionResponse, ActivateToken, last, &response, &activate_version_response__pack, &activate_version_response__get_packed_size); responseContainer.has_continuous = true; responseContainer.continuous = true; diff --git a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c index 06a4ed090..64002276c 100644 --- a/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c +++ b/Software/Embedded_SW/Embedded/Common/SW_Info/SW_Info.c @@ -20,7 +20,7 @@ typedef struct } TangoVersion_t; -TangoVersion_t _gTangoVersion = {1,4,6,40}; +TangoVersion_t _gTangoVersion = {1,4,6,43}; #define BUILD_DATE __DATE__ char Dat[50] = BUILD_DATE; char _gTangoName [MAX_STRING_LEN] = "Tango01 ";//e diff --git a/Software/Embedded_SW/Embedded/Common/Utilities/delay.c b/Software/Embedded_SW/Embedded/Common/Utilities/delay.c new file mode 100644 index 000000000..ef095fe5b --- /dev/null +++ b/Software/Embedded_SW/Embedded/Common/Utilities/delay.c @@ -0,0 +1,42 @@ +/* + * delay.c - Delay in millisecond and microsecond functions + * + * Convert from SysCtlDelay in TivaWare library to milliseconds and microseconds delay. + * + * Created on: Dec 13, 2018 + * Author: avi + */ + +#include <stdint.h> +#include <stdbool.h> +#include "driverlib/sysctl.h" +#include "Include.h" + + + +void delayms(uint32_t ui32ms) +{ + //SysCtlClockGet(); + // 1 clock cycle = 1 / SysCtlClockGet() second + // 1 SysCtlDelay = 3 clock cycle = 3 / SysCtlClockGet() second + // 1 second = SysCtlClockGet() / 3 + // 0.001 second = 1 ms = SysCtlClockGet() / 3 / 1000 + //int i; + + //for(i=0;i<(ui32ms);i++) + + //if(ui32ms == 10) + // ui32ms = 20; + + SysCtlDelay( ui32ms * (SYS_CLK_FREQ / 3 / 1000)); +} + +void delayUs(uint32_t ui32Us) +{ + SysCtlDelay(ui32Us * (SYS_CLK_FREQ / 3 / 1000000)); +} + + + + + diff --git a/Software/Embedded_SW/Embedded/Common/Utilities/delay.h b/Software/Embedded_SW/Embedded/Common/Utilities/delay.h new file mode 100644 index 000000000..a070cae1d --- /dev/null +++ b/Software/Embedded_SW/Embedded/Common/Utilities/delay.h @@ -0,0 +1,17 @@ +/* + * delay.h + * + * Created on: Dec 13, 2018 + * Author: avi + */ + +#ifndef COMMON_UTILITIES_DELAY_H_ +#define COMMON_UTILITIES_DELAY_H_ + +void delayms(uint32_t ui32ms); + +void delayUs(uint32_t ui32Us); + + + +#endif /* COMMON_UTILITIES_DELAY_H_ */ diff --git a/Software/Embedded_SW/Embedded/Common/report/reportInit.c b/Software/Embedded_SW/Embedded/Common/report/reportInit.c index 5c8646bf1..7ffbe5b6d 100644 --- a/Software/Embedded_SW/Embedded/Common/report/reportInit.c +++ b/Software/Embedded_SW/Embedded/Common/report/reportInit.c @@ -68,7 +68,7 @@ PackageHandle MaintFilter; char LogPath[50] = "0://ErrFile.txt"; char protobufToken[36+1] = {0}; -char message[300]; +char RepMessage[300]; FRESULT LogFresult = FR_OK; FIL *LogFileHandle = 0; //the system supports a single active file bool isReportActive(void) @@ -81,23 +81,32 @@ bool isReportActive(void) } uint32_t OpenLogFile(void) { - /*int len; - uint32_t Bytes = 0; - LogFresult = f_open(LogFileHandle,LogPath,FA_OPEN_ALWAYS | FA_WRITE | FA_READ); - if (LogFresult == FR_OK) + int len; + uint32_t Bytes = 0; + LogFileHandle = my_malloc(sizeof(FIL)); + if (LogFileHandle) { - if (LogFileHandle->fsize < 100000) - f_lseek(LogFileHandle, LogFileHandle->fsize); - len = usnprintf(message, 80, "Log File %s %s",__DATE__, __TIME__); - LogFresult = f_write(LogFileHandle,message,len,&Bytes ); - }*/ + LogFresult = f_open(LogFileHandle,LogPath,FA_READ | FA_WRITE | FA_OPEN_ALWAYS); + if (LogFresult == FR_OK) + { + if (LogFileHandle->fsize < 50000) + f_lseek(LogFileHandle, LogFileHandle->fsize); + else + f_lseek(LogFileHandle, 0); + len = usnprintf(RepMessage, 80, "Log File %s %s",__DATE__, __TIME__); + LogFresult = f_write(LogFileHandle,RepMessage,len,&Bytes ); + } + } + else + LogFresult = FR_INT_ERR; + return LogFresult; } uint32_t CloseLogFile(void) { /* perform default error output */ - //LogFresult = f_close(LogFileHandle); - + LogFresult = f_close(LogFileHandle); + LogFileHandle = NULL; return LogFresult; } uint32_t LogToFile(char *message, /* The formatted message */ @@ -109,13 +118,15 @@ uint32_t LogToFile(char *message, /* The formatted message { /* print user supplied error code */ - /* uint32_t Bytes = 0; + uint32_t Bytes = 0; int len; + if (LogFileHandle == NULL) + return OK; - len = usnprintf(message, 300, "%s, file %s line %d code %d sev %d,param %d",message,FileName, LineNumber,errorCode, Severity, parameter); - LogFresult = f_write(LogFileHandle,message,len,&Bytes );*/ + len = usnprintf(RepMessage, 300, "\r\n%s, file %s line %d code %d sev %d,param %d",message,FileName, LineNumber,errorCode, Severity, parameter); + LogFresult = f_write(LogFileHandle,RepMessage,len,&Bytes ); - return LogFresult; + return LogFresult; } int ReportResponseFunc(char *message, /* The formatted message */ char *FileName, @@ -315,6 +326,8 @@ uint32_t ReportInitMessage(MessageContainer* requestContainer) StartDebugLogRequest* request = start_debug_log_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); ustrncpy (protobufToken, requestContainer->token,36); + if (LogFileHandle != NULL) + f_sync(LogFileHandle); DistributorHandle ReportHandle = ReportAddDistributor("ProtoBuf"); //CloseLogFile(); if (ReportHandle == NULL) status |= 0x8; |
