diff options
Diffstat (limited to 'Software/Embedded_SW/Embedded')
36 files changed, 828 insertions, 376 deletions
diff --git a/Software/Embedded_SW/Embedded/.cproject b/Software/Embedded_SW/Embedded/.cproject index 20edaeefb..89dc72b30 100644 --- a/Software/Embedded_SW/Embedded/.cproject +++ b/Software/Embedded_SW/Embedded/.cproject @@ -169,7 +169,7 @@ </toolChain> </folderInfo> <sourceEntries> - <entry excluding="Common/protobuf-c/person-pb-c.c|JigCommands.c|PWM.c|USBCDCD.c|Message.c|Pin_config.c|src|Configuration.c|SlowMotors.c|Timer.c|Communication.c|FastMotors.c|ADCUtils.c|Drivers/L6470|Pin.c|ADCLogger.c|Flashstore.c|Profile.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/> + <entry excluding="PWM.c|USBCDCD.c|Message.c|Pin_config.c|src|Configuration.c|Timer.c|Communication.c|FastMotors.c|ADCUtils.c|Drivers/L6470|Pin.c|ADCLogger.c|Flashstore.c|Profile.c" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/> </sourceEntries> </configuration> </storageModule> diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c index ce36f57e6..d39c335ef 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FileSystem.c @@ -44,14 +44,18 @@ ErrorCode FileError_to_ErrorCode[FR_INVALID_PARAMETER+1] = {ERROR_CODE__NONE,ERR ERROR_CODE__FILE_REQUEST_INVALID_PARAMETER}; -FIL *FileHandle = 0; //the system supports a single active file +FIL *UploadFileHandle = 0; //the system supports a single active file +FIL *DownloadFileHandle = 0; //the system supports a single active file char FileHandleChar[5]; char ErrorMsg[100]; #define MAX_CHUNK_LENGTH 2000 -int FileLength = 0; -int FileReceivedLength = 0; +int32_t FileLength = 0; +int32_t FileReceivedLength = 0; +int32_t FileSentLength = 0; static char g_cCwdBuf[50] = "/"; uint32_t WrittenBytes = 0; +uint32_t ReadBytes = 0; + ErrorCode getErrorCode(FRESULT Fresult) { @@ -77,12 +81,12 @@ uint32_t FileUploadRequestFunc(MessageContainer* requestContainer) FileUploadResponse response = FILE_UPLOAD_RESPONSE__INIT; WrittenBytes=0; - FileHandle = my_malloc(sizeof(FIL)); - if (FileHandle == 0) + UploadFileHandle = my_malloc(sizeof(FIL)); + if (UploadFileHandle == 0) Fresult = FR_DENIED; else { - Fresult = f_open(FileHandle,request->path,FA_READ | FA_WRITE | FA_OPEN_ALWAYS ); + Fresult = f_open(UploadFileHandle,request->path,FA_READ | FA_WRITE | FA_OPEN_ALWAYS ); if (Fresult == FR_OK) { FileLength = request->length; @@ -93,8 +97,8 @@ uint32_t FileUploadRequestFunc(MessageContainer* requestContainer) } else { - free (FileHandle); - FileHandle = 0; + free (UploadFileHandle); + UploadFileHandle = 0; } } @@ -115,7 +119,6 @@ uint32_t FileUploadRequestFunc(MessageContainer* requestContainer) return OK; } - uint32_t FileChunkUploadRequestFunc(MessageContainer* requestContainer) { //uint32_t status = OK; @@ -131,7 +134,7 @@ uint32_t FileChunkUploadRequestFunc(MessageContainer* requestContainer) FIL *ReceivedFileHandle; //the system supports a single active file // if (request->uploadid == 1) - ReceivedFileHandle = FileHandle; + ReceivedFileHandle = UploadFileHandle; // memcpy (&ReceivedFileHandle,request->uploadid,sizeof(ReceivedFileHandle)); //if (ReceivedFileHandle == FileHandle) //{ @@ -147,7 +150,8 @@ uint32_t FileChunkUploadRequestFunc(MessageContainer* requestContainer) { REPORT_MSG (FileReceivedLength,"file upload ended successfully"); f_close(ReceivedFileHandle); - free (FileHandle); + free (UploadFileHandle); + FileReceivedLength = 0; } else { @@ -155,7 +159,8 @@ uint32_t FileChunkUploadRequestFunc(MessageContainer* requestContainer) { REPORT_MSG (FileReceivedLength,"file upload too much data!"); f_close(ReceivedFileHandle); - free (FileHandle); + free (UploadFileHandle); + FileReceivedLength = 0; } } } @@ -183,6 +188,124 @@ uint32_t FileChunkUploadRequestFunc(MessageContainer* requestContainer) return OK; } +uint32_t FileDownloadRequestFunc(MessageContainer* requestContainer) +{ + //uint32_t status = OK; + + FRESULT Fresult = FR_OK; + FILINFO* fno; + + MessageContainer responseContainer; + + FileDownloadRequest* request = file_download_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); + + FileDownloadResponse response = FILE_DOWNLOAD_RESPONSE__INIT; + + ReadBytes=0; + FileSentLength = 0; + + fno = my_malloc(sizeof(FILINFO)); + if (fno == 0) + Fresult = FR_DENIED; + else + { + memset (fno,0,sizeof(FILINFO)); + Fresult = f_stat(request->filename,fno); + FileLength = fno->fsize; + DownloadFileHandle = my_malloc(sizeof(FIL)); + if (DownloadFileHandle == 0) + Fresult = FR_DENIED; + else + { + Fresult = f_open(DownloadFileHandle,request->filename,FA_READ ); + if (Fresult == FR_OK) + { + response.has_maxchunklength = true; + response.maxchunklength = MAX_CHUNK_LENGTH; + strcpy(FileHandleChar, "1234"); + response.downloadid = FileHandleChar; //supporting only single file at each time. + } + + } + } + + + responseContainer = createContainer(MESSAGE_TYPE__FileDownloadResponse, requestContainer->token, false, &response, &file_download_response__pack, &file_download_response__get_packed_size); + if (Fresult!= FR_OK) + { + responseContainer.error = getErrorCode(Fresult); + responseContainer.errormessage = "File operation error"; + } + responseContainer.continuous = false; + uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); + size_t container_size = message_container__pack(&responseContainer, container_buffer); + my_free(responseContainer.data.data); + file_download_request__free_unpacked(request,NULL); + SendChars(container_buffer, container_size); + my_free(fno); + + return OK; +} +uint32_t FileChunkDownloadRequestFunc(MessageContainer* requestContainer) +{ + MessageContainer responseContainer; + FileChunkDownloadRequest* request = file_chunk_download_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); + FileChunkDownloadResponse response = FILE_CHUNK_DOWNLOAD_RESPONSE__INIT; + FRESULT Fresult = FR_OK; + FIL *SentFileHandle; //the system supports a single active file + + SentFileHandle = DownloadFileHandle; + char *Buffer = 0; + Buffer = my_malloc (MAX_CHUNK_LENGTH); + if (Buffer != NULL) + { + Fresult = f_read(SentFileHandle,Buffer,2000,&ReadBytes ); + if(Fresult != FR_OK) + { + LOG_ERROR (Fresult,"f_write error"); + } + else + { + response.has_buffer = true; + response.buffer.len = ReadBytes; + response.buffer.data = Buffer; + FileSentLength += ReadBytes; + if (FileSentLength == FileLength) + { + REPORT_MSG (FileSentLength,"file download ended successfully"); + f_close(SentFileHandle); + free (DownloadFileHandle); + FileSentLength = 0; + } + else + { + if (FileSentLength > FileLength) + { + REPORT_MSG (FileSentLength,"file download too much data!"); + f_close(SentFileHandle); + free (DownloadFileHandle); + FileSentLength = 0; + } + } + } + } + + responseContainer = createContainer(MESSAGE_TYPE__FileChunkDownloadResponse, requestContainer->token, false, &response, &file_chunk_download_response__pack, &file_chunk_download_response__get_packed_size); + if (Fresult!= OK) + { + responseContainer.error = getErrorCode(Fresult); + responseContainer.errormessage = "File operation error"; + } + responseContainer.continuous = false; + uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); + size_t container_size = message_container__pack(&responseContainer, container_buffer); + file_chunk_download_request__free_unpacked(request,NULL); + my_free(responseContainer.data.data); + my_free(Buffer); + SendChars(container_buffer, container_size); + + return OK; +} uint32_t ExecuteProcessRequestFunc(MessageContainer* requestContainer) { uint32_t status = OK; @@ -251,15 +374,15 @@ uint32_t CreateRequestFunc(MessageContainer* requestContainer) } else { - FileHandle = my_malloc(sizeof(FIL)); - if (FileHandle == 0) + UploadFileHandle = my_malloc(sizeof(FIL)); + if (UploadFileHandle == 0) Fresult = FR_DENIED; else { - Fresult = f_open(FileHandle,request->path,FA_CREATE_NEW); + Fresult = f_open(UploadFileHandle,request->path,FA_CREATE_NEW); if (Fresult == FR_OK) { - if (f_close (FileHandle)!= FR_OK) + if (f_close (UploadFileHandle)!= FR_OK) { Fresult = FR_LOCKED; } @@ -272,7 +395,7 @@ uint32_t CreateRequestFunc(MessageContainer* requestContainer) usnprintf(ErrorMsg, 100, "File Operation failed error code %d",Fresult); } - free (FileHandle); + free (UploadFileHandle); responseContainer = createContainer(MESSAGE_TYPE__CreateResponse, requestContainer->token, false, &response, &create_response__pack, &create_response__get_packed_size); if (Fresult!= OK) @@ -304,7 +427,7 @@ uint32_t DeleteRequestFunc(MessageContainer* requestContainer) //int NumOfFiles = 0; FRESULT Fresult = FR_OK; - Fresult |= f_opendir(&dir, g_cCwdBuf); + /*Fresult |= f_opendir(&dir, g_cCwdBuf); if(Fresult != FR_OK) { LOG_ERROR (Fresult,"f_write error"); @@ -320,10 +443,10 @@ uint32_t DeleteRequestFunc(MessageContainer* requestContainer) if (isDirectory(fno->fattrib)) { //============================ - Fresult = f_opendir(&dir, request->path); /* Open the directory */ + Fresult = f_opendir(&dir, request->path); if (Fresult == FR_OK) { - Fresult = f_readdir(&dir, &fno); /* Read a directory item */ + Fresult = f_readdir(&dir, &fno); if (Fresult == FR_OK) { if(fno->fname[0] ==0) @@ -343,7 +466,9 @@ uint32_t DeleteRequestFunc(MessageContainer* requestContainer) Fresult = f_unlink(request->path); } } - } + }*/ + Fresult = f_unlink(request->path); + responseContainer = createContainer(MESSAGE_TYPE__DeleteResponse, requestContainer->token, false, &response, &delete_response__pack, &delete_response__get_packed_size); if (Fresult!= OK) { @@ -384,10 +509,10 @@ uint32_t GetStorageInfoRequestFunc(MessageContainer* requestContainer) tot_sect = (fs->n_fatent - 2) * fs->csize; fre_sect = fre_clust * fs->csize; response.has_capacity = true; - response.capacity = tot_sect/2; + response.capacity = tot_sect/2*1024; response.has_freespace = true; - response.freespace = fre_sect/2; - response.root = "0:"; + response.freespace = fre_sect/2*1024; + response.root = "/"; } @@ -463,7 +588,6 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) FilesInfo[i] = &Data[i]; Data[i].has_attribute = true; Data[i].attribute = fno[i]->fattrib; - Data[i].has_length = true; Data[i].name = fno[i]->fname; Data[i].has_length = true; Data[i].length = fno[i]->fsize; @@ -476,7 +600,10 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) if (i==0) usnprintf(&FullPath[i], 50, "%s", request->path); else - usnprintf(&FullPath[i], 50, "%s%c%c%s", request->path,'\\','\\'/*"/"*/, fno[i]->fname); + if (strlen(request->path)==1) //info under the root + usnprintf(&FullPath[i], 50, "%s%s", request->path, fno[i]->fname); + else + usnprintf(&FullPath[i], 50, "%s%s%s", request->path,"/", fno[i]->fname); Data[i].fullpath = &FullPath[i]; } @@ -509,107 +636,6 @@ uint32_t GetFilesRequestFunc(MessageContainer* requestContainer) } return Fresult; } -uint32_t FileDownloadRequestFunc(MessageContainer* requestContainer) -{ - //uint32_t status = OK; - - FRESULT Fresult = FR_OK; - - MessageContainer responseContainer; - - FileDownloadRequest* request = file_download_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); - - FileDownloadResponse response = FILE_DOWNLOAD_RESPONSE__INIT; - - WrittenBytes=0; - FileHandle = my_malloc(sizeof(FIL)); - if (FileHandle == 0) - Fresult = FR_DENIED; - else - { - Fresult = f_open(FileHandle,request->filename,FA_READ ); - if (Fresult == FR_OK) - { - response.has_maxchunklength = true; - response.maxchunklength = MAX_CHUNK_LENGTH; - strcpy(FileHandleChar, "1234"); - response.downloadid = FileHandleChar; //supporting only single file at each time. - } - - } - - - responseContainer = createContainer(MESSAGE_TYPE__FileDownloadResponse, requestContainer->token, false, &response, &file_download_response__pack, &file_download_response__get_packed_size); - if (Fresult!= FR_OK) - { - responseContainer.error = getErrorCode(Fresult); - responseContainer.errormessage = "File operation error"; - } - responseContainer.continuous = false; - uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); - size_t container_size = message_container__pack(&responseContainer, container_buffer); - my_free(responseContainer.data.data); - file_download_request__free_unpacked(request,NULL); - SendChars(container_buffer, container_size); - - return OK; -} -uint32_t FileChunkDownloadRequestFunc(MessageContainer* requestContainer) -{ - MessageContainer responseContainer; - FileChunkDownloadRequest* request = file_chunk_download_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); - FileChunkDownloadResponse response = FILE_CHUNK_DOWNLOAD_RESPONSE__INIT; - FRESULT Fresult = FR_OK; - FIL *ReceivedFileHandle; //the system supports a single active file - - ReceivedFileHandle = FileHandle; - char *Buffer = 0; - Buffer = my_malloc (2000); - if (Buffer != NULL) - { - Fresult = f_read(ReceivedFileHandle,response.buffer.data,2000,&WrittenBytes ); - if(Fresult != FR_OK) - { - LOG_ERROR (Fresult,"f_write error"); - } - else - { - response.buffer.len = WrittenBytes; - FileReceivedLength += WrittenBytes; - if (FileReceivedLength == FileLength) - { - REPORT_MSG (FileReceivedLength,"file download ended successfully"); - f_close(ReceivedFileHandle); - free (FileHandle); - } - else - { - if (FileReceivedLength > FileLength) - { - REPORT_MSG (FileReceivedLength,"file download too much data!"); - f_close(ReceivedFileHandle); - free (FileHandle); - } - } - } - } - - responseContainer = createContainer(MESSAGE_TYPE__FileChunkDownloadResponse, requestContainer->token, false, &response, &file_chunk_download_response__pack, &file_chunk_download_response__get_packed_size); - if (Fresult!= OK) - { - responseContainer.error = getErrorCode(Fresult); - responseContainer.errormessage = "File operation error"; - } - responseContainer.continuous = false; - uint8_t* container_buffer = my_malloc(message_container__get_packed_size(&responseContainer)); - size_t container_size = message_container__pack(&responseContainer, container_buffer); - file_chunk_download_request__free_unpacked(request,NULL); - my_free(responseContainer.data.data); - my_free(Buffer); - SendChars(container_buffer, container_size); - - return OK; -} FRESULT FileWrite(void * buffer, uint16_t size,char *path) { FRESULT Fresult = FR_OK; diff --git a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c index 35bde3636..dcb8cf8f2 100644 --- a/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c +++ b/Software/Embedded_SW/Embedded/Common/SWUpdate/FirmwareUpgrade.c @@ -24,13 +24,12 @@ #include "drivers/FPGA/Full_Vme/FPGA_Programming_Up.h" #include "Common/SWUpdate/FileSystem.h" - uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) { - uint32_t status = OK; void* buffer = NULL; uint32_t Bytes = 0; char SWINFOPath[100]; + char FullPath[50]; FRESULT Fresult = FR_OK; int File_i; @@ -41,12 +40,13 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) ActivateVersionResponse response = ACTIVATE_VERSION_RESPONSE__INIT; VersionPackageDescriptor* VersionPackage;// = VERSION_PACKAGE_DESCRIPTOR__INIT; + FPGA_ID FileDestinationToFPGAId[VERSION_FILE_DESTINATION__FPGA3+1] = {MAX_FPGA,FPGA1,FPGA2,FPGA3}; + strcpy (SWINFOPath,request->path); - strcat(SWINFOPath,"//SWINFO.DAT"); + strcat(SWINFOPath,"/file1.pck"); Fresult = FileRead(SWINFOPath, &Bytes, &buffer); - if (Fresult == FR_OK) { VersionPackage = version_package_descriptor__unpack(NULL,Bytes,buffer); @@ -61,17 +61,19 @@ uint32_t ActivateVersionRequestFunc(MessageContainer* requestContainer) case VERSION_FILE_DESTINATION__FPGA3: //validate //update - Fresult = FPGA_Programming_Up( VersionPackage->filedescriptors[File_i]->destination, VersionPackage->filedescriptors[File_i]->filename, false); + usnprintf(FullPath, 50, "%s%s%s", request->path,"/", VersionPackage->filedescriptors[File_i]->filename); + + Fresult = FPGA_Programming_Request( FileDestinationToFPGAId[VersionPackage->filedescriptors[File_i]->destination], FullPath, false); break; default: - LOG_ERROR (VersionPackage->filedescriptors[File_i]->destination,"wrong fule update Destination"); + LOG_ERROR (VersionPackage->filedescriptors[File_i]->destination,"wrong file update Destination"); Fresult = FR_INVALID_NAME; break; } } } responseContainer = createContainer(MESSAGE_TYPE__ActivateVersionResponse, requestContainer->token, false, &response, &activate_version_response__pack, &activate_version_response__get_packed_size); - if (status!= OK) + if (Fresult!= OK) { responseContainer.error = FileError_to_ErrorCode[Fresult]; responseContainer.errormessage = "Activate Version Request error"; 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 b896e168c..7dece0d08 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,3,5,5}; +TangoVersion_t _gTangoVersion = {1,3,6,1}; #define BUILD_DATE __DATE__ char Dat[50] = BUILD_DATE; char _gTangoName [MAX_STRING_LEN] = "Tango01 ";//d diff --git a/Software/Embedded_SW/Embedded/Communication/Container.c b/Software/Embedded_SW/Embedded/Communication/Container.c index ba1f8eea9..bb6b82743 100644 --- a/Software/Embedded_SW/Embedded/Communication/Container.c +++ b/Software/Embedded_SW/Embedded/Communication/Container.c @@ -383,6 +383,12 @@ void receive_callback(char* buffer, size_t length) case MESSAGE_TYPE__FileChunkUploadRequest: FileChunkUploadRequestFunc(requestContainer); break; + case MESSAGE_TYPE__FileDownloadRequest: + FileDownloadRequestFunc(requestContainer); + break; + case MESSAGE_TYPE__FileChunkDownloadRequest: + FileChunkDownloadRequestFunc(requestContainer); + break; case MESSAGE_TYPE__ExecuteProcessRequest: ExecuteProcessRequestFunc(requestContainer); break; diff --git a/Software/Embedded_SW/Embedded/DataDef.h b/Software/Embedded_SW/Embedded/DataDef.h index 4c7698c1b..5397d2f6c 100644 --- a/Software/Embedded_SW/Embedded/DataDef.h +++ b/Software/Embedded_SW/Embedded/DataDef.h @@ -198,12 +198,26 @@ enum #define BIT31 0x80000000 //0x01 << 31 +#define MAX_PWM_Command 100 + +typedef enum +{ + //Don't change the value - keep it according to the bits in F3_GPO_02_bus + CART_1 = 1, + CART_2 = 2, + CART_3 = 3, + //------------- + POWER_ON_OFF, + THREAD_JOGGING , + THREAD_LOAD , +}PANEL_BUTTONS_LEDS_ID; + typedef enum { MODE_OFF = 0, MODE_ON = 1, }OPERATION_MODE; - +/* typedef enum { //according to the bits of the leds in F3_GPO_01_bus @@ -211,7 +225,8 @@ typedef enum THREAD_LOADING = 2, JOGGING = 3, }BUTTON; - +*/ +/* typedef enum { //According to the bits of the leds in F3_GPO_02_bus @@ -219,7 +234,7 @@ typedef enum CART2 = 2, CART3 = 3, }CARTREGE; - +*/ //--------------------- #define MaxFlashWords 128 //1K #define MaxFlashBytes MaxFlashWords*4 //4K Byte diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c index 13c31fb49..fdcf33587 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.c @@ -199,7 +199,7 @@ uint32_t Read_Fans_Tacho() #ifndef EVALUATION_BOARD // The big Fan in the drawer - Drawer_Fan_Speed_RPM = Calculate_Tacho_Fan_Speed(25000000, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg0); + Drawer_Fan_Speed_RPM = Calculate_Tacho_Fan_Speed(29166666, 0X02, F1_Prescaler1_reg5, F1_Tacho_reg0); if( Drawer_Fan_Speed_RPM < 1000 ) // need to work around 3000 RPM Status|= 0x01;// not working / Low Speed @@ -246,31 +246,31 @@ uint32_t Read_Fans_Tacho() } //------------------------- WHS ---------------------- -uint32_t WHS_Read_Blower_Tach() -{ - //TODO: check if we need to change the Prescaler - //F2_Prescaler1_reg10 - prescaled clocks for counter of signal Blower Tacho. 8 bits - - - /* - RPM=60* (Sys_clk/PreScalar)/ F2_Tacho_reg0 - - Where : - - Sys_clk =25*10^6 (25Mhz) - PresScalar(default) =250 - - Mati - */ - uint32_t RPM; - uint32_t Temp = 6000000; // 60* (Sys_clk/PreScalar) - RPM = Temp / GPI_BLOWER_TACH; - - return RPM; -} +//uint32_t WHS_Read_Blower_Tach() +//{ +// //TODO: check if we need to change the Prescaler +// //F2_Prescaler1_reg10 - prescaled clocks for counter of signal Blower Tacho. 8 bits +// +// +// /* +// RPM=60* (Sys_clk/PreScalar)/ F2_Tacho_reg0 +// +// Where : +// +// Sys_clk =25*10^6 (25Mhz) +// PresScalar(default) =250 +// +// Mati +// */ +// uint32_t RPM; +// uint32_t Temp = 6000000; // 60* (Sys_clk/PreScalar) +// RPM = Temp / GPI_BLOWER_TACH; +// +// return RPM; +//} //------------------------- Dryer Blower ---------------------- - +/* uint32_t Dryer_Read_Blower_Tach() { uint32_t RPM; @@ -278,21 +278,66 @@ uint32_t Dryer_Read_Blower_Tach() RPM = WHS_Read_Blower_Tach(); // Temporary using WHS Tacho return RPM; } +*/ +uint32_t Read_Dryer_Fan_Tacho() +{ + + uint32_t Drayer_Fan_Speed_RPM = 0; + + Drayer_Fan_Speed_RPM = Calculate_Tacho_Fan_Speed(25000000, 12, F1_Prescaler1_reg5, F1_Tacho_reg8); + + + return Drayer_Fan_Speed_RPM; +} -void Control_Dryer_Fan_PWM(uint8_t PWN_Command_Precent)// 0 - 100% +void Control_Dryer_Fan_PWM(uint8_t PWM_Command_Precent)// 0 - 100% { // change to cycle to 100 in order to work with %, with constant FREQ uint8_t Freq = 0xFF;//divider Clock = 25M/divider - if(PWN_Command_Precent > 100) - PWN_Command_Precent = 100; + if(PWM_Command_Precent > 100) + PWM_Command_Precent = 100; GPO_BLOWER_PWM_FREQ = Freq; - GPO_BLOWER_PWM_LOW = PWN_Command_Precent + 1; - GPO_BLOWER_PWM_HIGH = 101 - PWN_Command_Precent; + GPO_BLOWER_PWM_LOW = PWM_Command_Precent + 1; + GPO_BLOWER_PWM_HIGH = 101 - PWM_Command_Precent; // low + high = 0xFF in order use the same freq (and change the freq only by Add 0x112). // there is option to change only the high (low + freq constasnt) this will chnga the freq } + +void Machine_Idle_Breathing_Led() //if (Ten_msTick) +{ + static uint8_t PWM_Command_Precent = 0;// 0 - 100% + static uint8_t direction = UP; + + F3_low_var_LED1 = PWM_Command_Precent + 1; + F3_high_var_LED1 = MAX_PWM_Command + 1 - PWM_Command_Precent; + + if(direction == UP) + { + if (PWM_Command_Precent == MAX_PWM_Command) + { + direction = DOWN; //"0" + } + else + { + PWM_Command_Precent++; + } + } + else + if(direction == DOWN) + { + if (PWM_Command_Precent == 0) + { + direction = UP;//"1" + } + else + { + PWM_Command_Precent--; + } + } +} + diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.h b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.h index b1cfa3735..93e0046b6 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.h +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA.h @@ -8,10 +8,13 @@ void FPGA_Init(); //void FPGA_Read_limit_Switches(void); uint32_t Read_Fans_Tacho(); -uint32_t WHS_Read_Blower_Tach(); +//uint32_t WHS_Read_Blower_Tach(); -uint32_t Dryer_Read_Blower_Tach(); -void Control_Dryer_Fan_PWM(uint8_t PWN_Command_Precent); +//uint32_t Dryer_Read_Blower_Tach(); +void Control_Dryer_Fan_PWM(uint8_t PWM_Command_Precent); +void Machine_Idle_Breathing_Led(); + +uint32_t Read_Dryer_Fan_Tacho(); diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_Comm.h b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_Comm.h index 7c052fcde..942846679 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_Comm.h +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_Comm.h @@ -146,6 +146,11 @@ #define F1_LDANCER1_ROTENC_DATA_p_RX_msb (*((volatile short *)(FPGA1_BASE | 0x1C2))) //16 bit MSB if nessesary #define F1_LDANCER1_ROTENC_DATA_p_TX (*((volatile short *)(FPGA1_BASE | 0x1CE))) //This register triggers a TX transmission +//FPGA VER 050219 +#define F1_GPO_02_bus (*((volatile short *)(FPGA3_BASE | 0x1D0))) //General purpose GPIO register +#define F1_Tacho_reg8 (*((volatile short *)(FPGA3_BASE | 0x1E0))) //This Register stores the Tacho counter +#define F1_Tacho_reg9 (*((volatile short *)(FPGA3_BASE | 0x1E2))) //This Register stores the Tacho counter A to A +// //SPI_MOTO_RLOADING_A1 #define F1_MOTO_RLOADING_A1_TX_00 (*((volatile short *)(FPGA1_BASE | 0x200))) //The second register to be shifted out of the spi. The msb bit of this register is shifted out first. #define F1_MOTO_RLOADING_A1_TX_01 (*((volatile short *)(FPGA1_BASE | 0x202))) //The first register to be shifted out of the spi. The msb bit of this register is shifted out first. @@ -265,7 +270,8 @@ #define F1_MOTO_LPIVOT1_A1_RX_01 (*((volatile short *)(FPGA1_BASE | 0x306))) //The 16 Lsb bits of the shifted in data. #define F1_MOTO_LPIVOT1_A1_WORDS (*((volatile short *)(FPGA1_BASE | 0x308))) //The amount of spi words (usually byte sized) per transmission. - +//FPGA VER 050219 +#define F1_gpo_cnt_A_reg (*((volatile short *)(FPGA1_BASE | 0x3B0))) //This Register stores the costumer Tacho counter A to A ( F1_gpo_cnt_A_reg must be greater than 1 => F1_gpo_cnt_A_reg>=1) #define F1_Tacho_reg0 (*((volatile short *)(FPGA1_BASE | 0x3C0))) //This Register stores the Tacho counter #define F1_Tacho_reg1 (*((volatile short *)(FPGA1_BASE | 0x3C2))) //This Register stores the Tacho counter @@ -284,7 +290,7 @@ #define F1_Prescaler1_reg2 (*((volatile short *)(FPGA1_BASE | 0x3E2))) //Parameter for prescaler divisions - 6bit ssi low duty cycle value for prescaler #define F1_Prescaler1_reg3 (*((volatile short *)(FPGA1_BASE | 0x3E4))) //Parameter for prescaler divisions - 3bit spi moto low duty cycle value for pmw #define F1_Prescaler1_reg4 (*((volatile short *)(FPGA1_BASE | 0x3E6))) //Parameter for prescaler divisions - 3bit spi moto high duty cycle value for pmw -#define F1_Prescaler1_reg5 (*((volatile short *)(FPGA1_BASE | 0x3E8))) //Parameter for prescaler divisions - amount of prescaled clocks for counter of signal All Tachos +#define F1_Prescaler1_reg5 (*((volatile short *)(FPGA1_BASE | 0x3E8))) //Parameter for prescaler divisions - Parameter for prescaler divisions -amount of prescaled clocks for counter of signal All Tachos. ####8_Bit##### #define F1_Prescaler1_reg6 (*((volatile short *)(FPGA1_BASE | 0x3EA))) //Parameter for prescaler divisions #define F1_Prescaler1_reg7 (*((volatile short *)(FPGA1_BASE | 0x3EC))) //Parameter for prescaler divisions #define F1_Prescaler1_reg8 (*((volatile short *)(FPGA1_BASE | 0x3EE))) //Parameter for prescaler divisions @@ -358,7 +364,7 @@ //GPO_REGISTER #define F2_GPO_REGISTER (*((volatile short *)(FPGA2_BASE | 0x0F2))) //Writes to values. Readback thevaluessthat are currently in the GPO register -#define F2_Prescaler1_reg10 (*((volatile short *)(FPGA2_BASE | 0x102))) //Parameter for prescaler divisions -amount of prescaled clocks for counter of signal Blower Tacho. +#define F2_Prescaler1_reg10 (*((volatile short *)(FPGA2_BASE | 0x102))) //Variable for prescaler divisions -amount of prescaled clocks for counter of signal Blower Tacho. 8 bits #define F2_Prescaler1_reg11 (*((volatile short *)(FPGA2_BASE | 0x112))) //Parameter for prescaler divisions -amount of prescaled clocks clk input of pwm of signal F2_GPO_BLOWER_PWM. 8bits #define F2_Prescaler1_reg12 (*((volatile short *)(FPGA2_BASE | 0x122))) //Variable for prescaler divisions -amount of prescaled clocks clk input of prescaler of signal VALVE registers. 16bits #define F2_Prescaler1_reg13 (*((volatile short *)(FPGA2_BASE | 0x132))) //Variable for prescaler divisions -amount of prescaled clocks clk input of prescaler of signal debouncer of the limit switch. 14bits @@ -682,6 +688,25 @@ #define F3_SPARE2_ROTENC_DATA_p_2_RX_msb (*((volatile short *)(FPGA3_BASE | 0x2D2))) //16 bit MSB if nessesary #define F3_SPARE2_ROTENC_DATA_p_2_TX (*((volatile short *)(FPGA3_BASE | 0x2DE))) //This register triggers a TX transmission +//PWM LEDS FPGA VER 050219 +#define F3_low_var_LED1 (*((volatile short *)(FPGA3_BASE | 0x390))) //Parameter for prescaler divisions - 8bit low duty cycle value for pmw +#define F3_high_var_LED1 (*((volatile short *)(FPGA3_BASE | 0x392))) //Parameter for prescaler divisions - 8bit high duty cycle value for pmw +#define F3_low_var_LED2 (*((volatile short *)(FPGA3_BASE | 0x394))) //Parameter for prescaler divisions - 8bit low duty cycle value for pmw +#define F3_high_var_LED2 (*((volatile short *)(FPGA3_BASE | 0x396))) //Parameter for prescaler divisions - 8bit high duty cycle value for pmw +#define F3_low_var_LED3 (*((volatile short *)(FPGA3_BASE | 0x398))) //Parameter for prescaler divisions - 8bit low duty cycle value for pmw +#define F3_high_var_LED3 (*((volatile short *)(FPGA3_BASE | 0x39A))) //Parameter for prescaler divisions - 8bit high duty cycle value for pmw +#define F3_low_var_LED4 (*((volatile short *)(FPGA3_BASE | 0x39C))) //Parameter for prescaler divisions - 8bit low duty cycle value for pmw +#define F3_high_var_LED4 (*((volatile short *)(FPGA3_BASE | 0x39E))) //Parameter for prescaler divisions - 8bit high duty cycle value for pmw +#define F3_low_var_SPARE1_1 (*((volatile short *)(FPGA3_BASE | 0x3A0))) //Parameter for prescaler divisions - 8bit low duty cycle value for pmw - unused according the costumer request +#define F3_high_var_SPARE1_1 (*((volatile short *)(FPGA3_BASE | 0x3A2))) //Parameter for prescaler divisions - 8bit high duty cycle value for pmw - unused according the costumer reques +#define F3_low_var_SPARE1_2 (*((volatile short *)(FPGA3_BASE | 0x3A4))) //Parameter for prescaler divisions - 8bit low duty cycle value for pmw +#define F3_high_var_SPARE1_2 (*((volatile short *)(FPGA3_BASE | 0x3A6))) //Parameter for prescaler divisions - 8bit high duty cycle value for pmw +#define F3_low_var_SPARE2_1 (*((volatile short *)(FPGA3_BASE | 0x3A8))) //Parameter for prescaler divisions - 8bit low duty cycle value for pmw +#define F3_high_var_SPARE2_1 (*((volatile short *)(FPGA3_BASE | 0x3AA))) //Parameter for prescaler divisions - 8bit high duty cycle value for pmw +#define F3_low_var_SPARE2_2 (*((volatile short *)(FPGA3_BASE | 0x3AC))) //Parameter for prescaler divisions - 8bit low duty cycle value for pmw +#define F3_high_var_SPARE2_2 (*((volatile short *)(FPGA3_BASE | 0x3AE))) //Parameter for prescaler divisions - 8bit high duty cycle value for pmw +// + #define F3_Prescaler1_reg9 (*((volatile short *)(FPGA3_BASE | 0x3C2))) //Variable for prescaler divisions -amount of prescaled clocks clk input of prescaler of signal debouncer of the limit switch. 14bits. The value inserted here is multiply by 8 before being set. #define F3_SW_RESET_reg (*((volatile short *)(FPGA3_BASE | 0x3D0))) //This register resets the MCU @@ -699,6 +724,24 @@ //Test #define F3_Test (*((volatile short *)(FPGA3_BASE | 0x3F0))) //Readback not - gives the inverse of the written to value + +// ----------------------- BLOWER ----------------------- +#define GPI_BLOWER_TACH F2_Tacho_reg0 + +//WHS GPO_BLOWER_PWM - See the stub "GPO_BLOWER_PWM.cs" +#define GPO_BLOWER_PWM_FREQ F2_Prescaler1_reg11 +#define GPO_BLOWER_PWM_LOW F2_Prescaler1_reg6 +#define GPO_BLOWER_PWM_HIGH F2_Prescaler1_reg7 + +// ----------------------- LEDS ----------------------- +#define F3_LOw_Cart_Led1 F3_low_var_SPARE1_2 +#define F3_High_Cart_Led1 F3_high_var_SPARE1_2 +#define F3_LOw_Cart_Led2 F3_low_var_SPARE2_1 +#define F3_High_Cart_Led2 F3_high_var_SPARE2_1 +#define F3_LOw_Cart_Led3 F3_low_var_SPARE2_2 +#define F3_High_Cart_Led3 F3_high_var_SPARE2_2 + + //1 Version1_Direct typedef union { diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c index 51b00c235..49b1ce649 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.c @@ -20,6 +20,8 @@ FPGA_GPI FPGA_Gpi; bool FPGA_Gpi_Buf[MAX_GPI] = {0}; +extern bool Machine_Idle_Mode; + void Read_FPGA_GPI_Rgisters() { uint32_t i; @@ -545,17 +547,12 @@ void WHS_Read_GPI_Registers() F3_GPI_01_Reg.ushort = F3_GPI_01_D; } -//bool WHS_GET_GPI_AIRFLOW_FLAP() -//{ -// return F2_GPI_Reg.bits.F2_GPI_AIRFLOW_FLAP; -//} - bool WHS_GPI_CHILLER_FAULT() { return F2_GPI_Reg.bits.F2_GPI_CHILLER_FAULT; } -bool Waste_OverFull() +bool WHS_GPI_WASTE_OVERFULL() { return F2_GPI_Reg.bits.F2_WASTE_OVERFULL_NO; } @@ -575,12 +572,31 @@ bool WHS_GPI_WCONTAINER_WARN() return F3_GPI_01_Reg.bits.F3_GPI_WCONTAINER_WARN; } -bool Waste_Flow_Switch() +bool WHS_GPI_WASTE_FLOW_SWITCH() { return F2_GPI_Reg.bits.F2_WASTE_FLOW_SW_NO; } +uint8_t GPO_Waste_Pressure_Software_Stop(uint8_t TrueToStop) +{ + //GPO_SPARE1_1 (New BP: DISP_SAFETY_STOP_INPUT) Connected to WASTE_PRESS_SW and Stop from MCU + uint8_t Status = OK; + switch(TrueToStop) + { + case true: + F3_GPO_02_bus |= STOP ; + break; + case false: + F3_GPO_02_bus &= ~(STOP); + break; + default: + Status = ERROR; + break; + } + + return Status; +} //-------------------------------------- bool Get_COVER_1_State(COVERS_ENUM CoverId) { @@ -632,7 +648,7 @@ void Pumps_Control(PUMPS_ENUM Pump_Id, bool Direction) //1 - OPEN, 0 - CLOSE ?? F1_gpo_01 = F1_GPO_Reg.ushort; } - +/* uint8_t Buttons_LEDS(BUTTON Button, OPERATION_MODE LED_Mode) { uint8_t Status = OK; @@ -652,7 +668,7 @@ uint8_t Buttons_LEDS(BUTTON Button, OPERATION_MODE LED_Mode) return Status; } - +*/ uint8_t Buzzer(OPERATION_MODE Buzzer_Mode) { uint8_t Status = OK; @@ -683,8 +699,8 @@ bool Read_PWR_Button()//TODO move to GPIO folder return IsPowerPressed; } - -uint8_t Cartridges_LEDS(CARTREGE Cartridge, OPERATION_MODE LED_Mode) +/* +uint8_t Cartridges_LEDS(CARTREGE Cartridge, OPERATION_MODE LED_Mode) // CART1_LAMP, CART2_LAMP,CART3_LAMP { uint8_t Status = OK; @@ -703,24 +719,102 @@ uint8_t Cartridges_LEDS(CARTREGE Cartridge, OPERATION_MODE LED_Mode) return Status; } +*/ +uint8_t Pannel_Leds(PANEL_BUTTONS_LEDS_ID Pannel_Led_Id, OPERATION_MODE LED_Mode) +{ + uint8_t Status = OK; + + short Low_Reg; + short High_Reg; + + switch(LED_Mode) + { + case MODE_ON: + Low_Reg = 1; + High_Reg = MAX_PWM_Command +1; + break; + case MODE_OFF: + Low_Reg = MAX_PWM_Command +1; + High_Reg = 1; + break; + default: + Status = ERROR; + break; + } + + if(Status == OK) + { + switch(Pannel_Led_Id) + { + case POWER_ON_OFF: + F3_low_var_LED1 = Low_Reg; + F3_high_var_LED1 = High_Reg; + Machine_Idle_Mode = false; + break; + case THREAD_JOGGING: + F3_low_var_LED2 = Low_Reg; + F3_high_var_LED2 = High_Reg; + break; + case THREAD_LOAD: + F3_low_var_LED3 = Low_Reg; + F3_high_var_LED3 = High_Reg; + break; + case CART_1: + F3_LOw_Cart_Led1 = Low_Reg; + F3_High_Cart_Led1 = High_Reg; + break; + case CART_2: + F3_LOw_Cart_Led2 = Low_Reg; + F3_High_Cart_Led2 = High_Reg; + break; + case CART_3: + F3_LOw_Cart_Led3 = Low_Reg; + F3_High_Cart_Led3 = High_Reg; + break; + default: + Status = ERROR; + break; + } + } + return Status; +} + +uint8_t Init_Machine_Leds() +{ + uint8_t Status = OK; + + F3_Prescaler1_reg5 = 0x03; // PWM LED Prescaler default in FPGA just to verify + + Status |= Pannel_Leds(POWER_ON_OFF,MODE_ON); + + Status |= Pannel_Leds(THREAD_JOGGING,MODE_OFF); + Status |= Pannel_Leds(THREAD_LOAD,MODE_OFF); + + Status |= Pannel_Leds(CART_1,MODE_OFF); + Status |= Pannel_Leds(CART_2,MODE_OFF); + Status |= Pannel_Leds(CART_3,MODE_OFF); + + return Status; +} + -bool Read_Cartridge_Button(CARTREGE Cartridge)//TODO Update the polarity!!! +bool Read_Cartridge_Button(PANEL_BUTTONS_LEDS_ID Cartridge)//TODO Update the polarity!!! { bool IsCartPressed = false; - if((Cartridge == CART1) && (F3_CARTx_PRES_02_Direct & BIT7)) + if((Cartridge == CART_1) && (F3_CARTx_PRES_02_Direct & BIT7)) IsCartPressed = true; else - if((Cartridge == CART2) && (F3_CARTx_PRES_02_Direct & BIT6)) + if((Cartridge == CART_2) && (F3_CARTx_PRES_02_Direct & BIT6)) IsCartPressed = true; else - if((Cartridge == CART3) && (F3_CARTx_PRES_02_Direct & BIT5)) + if((Cartridge == CART_3) && (F3_CARTx_PRES_02_Direct & BIT5)) IsCartPressed = true; return IsCartPressed; } -uint32_t Control_Dryer_Fan(bool StartStop, uint8_t PWN_Command_Precent)//use START or STOP, 0 - 100% +uint32_t Control_Dryer_Fan(bool StartStop, uint8_t PWM_Command_Precent)//use START or STOP, 0 - 100% { uint32_t status = OK; @@ -731,7 +825,7 @@ uint32_t Control_Dryer_Fan(bool StartStop, uint8_t PWN_Command_Precent)//use STA F1_gpo_01 = F1_GPO_Reg.ushort; if(StartStop == START) - Control_Dryer_Fan_PWM(PWN_Command_Precent);// 0 - 100% + Control_Dryer_Fan_PWM(PWM_Command_Precent);// 0 - 100% return status; } diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h index 47dc04bb5..1def86036 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h @@ -187,7 +187,7 @@ uint32_t ActivateDilutorPump(); uint32_t DeActivateDilutorPump(); void Power_Off(); void Power_Reset(); -uint8_t Buttons_LEDS(BUTTON Button, OPERATION_MODE LED_Mode); +//uint8_t Buttons_LEDS(BUTTON Button, OPERATION_MODE LED_Mode); uint8_t Buzzer(OPERATION_MODE Buzzer_Mode); bool Read_PWR_Button();//TODO move to GPIO folder @@ -202,13 +202,14 @@ uint32_t DeActivateAllSSR(); uint32_t ReadBreakSensor(); void WHS_Read_GPI_Registers(); -bool WHS_GET_GPI_AIRFLOW_FLAP(); bool WHS_GPI_CHILLER_FAULT(); -bool Waste_OverFull(); -bool Waste_Flow_Switch(); +bool WHS_GPI_CHILLER_STAT1(); +bool WHS_GPI_WASTE_FLOW_SWITCH(); +bool WHS_GPI_WASTE_OVERFULL(); bool WHS_GPI_SW_FILTER_PRES(); bool WHS_GPI_WCONTAINER_FULL(); bool WHS_GPI_WCONTAINER_WARN(); +uint8_t GPO_Waste_Pressure_Software_Stop(uint8_t TrueToStop); typedef enum { @@ -229,10 +230,11 @@ typedef enum void Pumps_Control(PUMPS_ENUM Pump_Id, bool Direction); -uint32_t Control_Dryer_Fan(bool StartStop, uint8_t PWN_Command_Precent); +uint32_t Control_Dryer_Fan(bool StartStop, uint8_t PWM_Command_Precent); bool Check_Disp_Sfaty_Stop_Indication(uint8_t Dispenser_ID); bool Emergency_Push_Button_Report(); bool Dryer_Door_Switch(); - +uint8_t Pannel_Leds(PANEL_BUTTONS_LEDS_ID Pannel_Led_Id, OPERATION_MODE LED_Mode); +uint8_t Init_Machine_Leds(); #endif /* DRIVERS_FPGA_FPGA_GPIO_FPGA_GPIO_H_ */ diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_Rename.h b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_Rename.h index 4675dad9f..8a7ce08c1 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_Rename.h +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_Rename.h @@ -45,10 +45,7 @@ //#define CART3_RST aaaaaaaa #define GPO_DH_MAGNET GPO_TFEED_BREAK_1 -// ----------------------- BLOWER ----------------------- -#define GPI_BLOWER_TACH F2_Tacho_reg0 -//WHS GPO_BLOWER_PWM - See the stub "GPO_BLOWER_PWM.cs" -#define GPO_BLOWER_PWM_FREQ F2_Prescaler1_reg11 -#define GPO_BLOWER_PWM_LOW F2_Prescaler1_reg6 -#define GPO_BLOWER_PWM_HIGH F2_Prescaler1_reg7 + + + diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c index 06f082bca..f2026b611 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/FPGA_SPI_Comm.c @@ -139,10 +139,10 @@ uint32_t Read_Motors_Driver_Type(TimerMotors_t i) { uint32_t status = OK; - SysCtlDelay(120000); + SysCtlDelay(12000); Fpga_Spi[i].TX_MOSI = (x_GET_PARAM | x_ADC_OUT)<<8; FPGA_SPI_Transnit(i); - SysCtlDelay(120000); + SysCtlDelay(12000); FPGA_Get_Res(i); MotorDriverResponse[i].ADC = Fpga_Spi[i].RX_MISO; @@ -450,13 +450,11 @@ uint32_t FPGA_MotorConfig_callback(TimerMotors_t _motorId, uint32_t ReadValue) uint32_t speed_calc = 0; //static char Motor_Type_Flag = 0; char CM_VM = 0; - if (_motorId > NUM_OF_MOTORS) return ERROR; - - /*if(Motor_Type_Flag == 0) - { - Read_Motors_Driver_Type(1); - Motor_Type_Flag = 1; - }*/ + if (_motorId > NUM_OF_MOTORS) + { + LOG_ERROR (_motorId, "Invalid motor id"); + return ERROR; + } switch (ConfigStages[_motorId]) { diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c index 534e2fb44..cb4b413e5 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.c @@ -14,8 +14,8 @@ #include "FPGA_Programming_Up.h" #include <inc/hw_memmap.h> - - +#include "Modules/Control/Control.h" +#include "Modules/Control/MillisecTask.h" extern short int main_vme(); @@ -69,8 +69,8 @@ FRESULT FPGA_Programming_Up(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot FPGA_JTAG.GPI_TDO.Pin = GPIO_PIN_7; break; default: - //return error - break; + return FR_INVALID_OBJECT; + //break; } FileHandlevme = malloc(sizeof(FIL)); @@ -79,7 +79,7 @@ FRESULT FPGA_Programming_Up(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot { return(fresult); } - main_vme(); + fresult = main_vme(); @@ -91,4 +91,64 @@ FRESULT FPGA_Programming_Up(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot return fresult; } +/****************************************************************************** + * ======== messageTsk ======== + * Task for this function is created statically. See the project's .cfg file. + * this message task is created statically in system initialization, + ******************************************************************************/ +Mailbox_Handle FPGALoadMsgQ = NULL; +typedef enum +{ + OneFPGALoad, +}FPGALoadMessages; + +typedef struct FPGALoadMessage{ + uint16_t messageId; + FPGA_ID FPGA_Id; + char * FullPath; + bool IncludeReboot; +}FPGALoadMessageStruc; +char FPGAFullPath[MAX_FPGA][50]; + +FRESULT FPGA_Programming_Request(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot) +{ + FPGALoadMessageStruc FPGALoadMessage; + + strcpy(FPGAFullPath[FPGA_Id],FullPath); + FPGALoadMessage.messageId = OneFPGALoad; + FPGALoadMessage.FPGA_Id = FPGA_Id; + FPGALoadMessage.FullPath = FPGAFullPath[FPGA_Id]; + FPGALoadMessage.IncludeReboot = IncludeReboot; + if (FPGALoadMsgQ != NULL) + Mailbox_post(FPGALoadMsgQ , &FPGALoadMessage, BIOS_NO_WAIT); + return FR_OK; +} + + +void FPGALoadTask(UArg arg0, UArg arg1) +{ + FPGALoadMessageStruc FPGALoadMessage; + Error_Block eb; + Error_init(&eb); + + FPGALoadMsgQ = Mailbox_create(sizeof(FPGALoadMessageStruc), 4, NULL,&eb); + + while(1) + { + Mailbox_pend(FPGALoadMsgQ , &FPGALoadMessage, BIOS_WAIT_FOREVER); + switch (FPGALoadMessage.messageId) + { + case OneFPGALoad: + //ControlStop(); + //MillisecStop(); + FPGA_Programming_Up(FPGALoadMessage.FPGA_Id,FPGALoadMessage.FullPath,FPGALoadMessage.IncludeReboot); + //ControlStart(); + //MillisecStart(); + //printf( "Finished Load FPGA %d File %s\n", FPGALoadMessage.FPGA_Id,FPGALoadMessage.FullPath ); + break; + default: + break; + } + } +} diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.h b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.h index 91ad2a61a..b752f24b3 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.h +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/FPGA_Programming_Up.h @@ -32,8 +32,10 @@ typedef struct GPIO GPI_TDO; //GPI FPGA->MCU }FPGA_JTAG_GPIO; +//Independent task non blocking call +FRESULT FPGA_Programming_Request(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot); +//direct blocking call FRESULT FPGA_Programming_Up(FPGA_ID FPGA_Id, char * FullPath, bool IncludeReboot); - #endif /* DRIVERS_FPGA_FULL_VME_FPGA_PROGRAMMING_UP_H_ */ diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/ispvme/ispvm_ui.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/ispvme/ispvm_ui.c index 0a94f4afd..c216b9aad 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/ispvme/ispvm_ui.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/ispvme/ispvm_ui.c @@ -237,7 +237,7 @@ unsigned char GetByte() ***************************************************************/ void vme_out_char(unsigned char charOut) { - printf("%c",charOut); + //printf("%c",charOut); } /*************************************************************** * @@ -250,7 +250,7 @@ void vme_out_char(unsigned char charOut) ***************************************************************/ void vme_out_hex(unsigned char hexOut) { - printf("%.2X",hexOut); + //printf("%.2X",hexOut); } /*************************************************************** * @@ -265,7 +265,7 @@ void vme_out_string(char *stringOut) { if(stringOut) { - printf("%s",stringOut); + //printf("%s",stringOut); } } @@ -653,8 +653,8 @@ signed char ispVM( /*const char * a_pszFilename*/ ) //AVI- ***************************************************************/ if ( cRetCode == 0 && g_usExpectedCRC != 0 && ( g_usExpectedCRC != g_usCalculatedCRC ) ) { - printf( "Expected CRC: 0x%.4X\n", g_usExpectedCRC ); - printf( "Calculated CRC: 0x%.4X\n", g_usCalculatedCRC ); + //printf( "Expected CRC: 0x%.4X\n", g_usExpectedCRC ); + //printf( "Calculated CRC: 0x%.4X\n", g_usCalculatedCRC ); return VME_CRC_FAILURE; } diff --git a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/ispvme/ivm_core.c b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/ispvme/ivm_core.c index d57f44c37..7afad1f1f 100644 --- a/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/ispvme/ivm_core.c +++ b/Software/Embedded_SW/Embedded/Drivers/FPGA/Full_Vme/ispvme/ivm_core.c @@ -379,7 +379,7 @@ void PrintData( unsigned short a_iDataSize, unsigned char * a_pucData ) //09/11/07 NN Type cast mismatch variables usByteSize = (unsigned short)(a_iDataSize / 8); } - printf( "(" ); + //printf( "(" ); //09/11/07 NN Type cast mismatch variables for ( usByteIndex = (signed short)(usByteSize - 1); usByteIndex >= 0; usByteIndex-- ) { ucByte = a_pucData[ usByteIndex ]; @@ -406,14 +406,14 @@ void PrintData( unsigned short a_iDataSize, unsigned char * a_pucData ) * ***************************************************************/ - printf( "%.02X", ucFlipByte ); + //printf( "%.02X", ucFlipByte ); if ( ( usByteSize - usByteIndex ) % 40 == 39 ) { - printf( "\n\t\t" ); + //printf( "\n\t\t" ); } if(usByteIndex < 0) break; } - printf( ")" ); + //printf( ")" ); } #endif //VME_DEBUG @@ -520,10 +520,10 @@ signed char ispVMCode() #ifdef VME_DEBUG if ( g_usDataType & LHEAP_IN ) { - printf( "LDELAY %s ", GetState( ucState ) ); + //printf( "LDELAY %s ", GetState( ucState ) ); } else { - printf( "STATE %s;\n", GetState( ucState ) ); + //printf( "STATE %s;\n", GetState( ucState ) ); } #endif //VME_DEBUG break; @@ -534,15 +534,15 @@ signed char ispVMCode() #ifdef VME_DEBUG switch( cOpcode ) { case SIR: - printf( "SIR " ); + //printf( "SIR " ); break; case SDR: case XSDR: if ( g_usDataType & LHEAP_IN ) { - printf( "LSDR " ); + //printf( "LSDR " ); } else { - printf( "SDR " ); + //printf( "SDR " ); } break; } @@ -583,10 +583,10 @@ signed char ispVMCode() usDelay &= ~0x8000; if ( g_usDataType & LHEAP_IN ) { - printf( "%.2E SEC;\n", ( float ) usDelay / 1000 ); + //printf( "%.2E SEC;\n", ( float ) usDelay / 1000 ); } else { - printf( "RUNTEST %.2E SEC;\n", ( float ) usDelay / 1000 ); + //printf( "RUNTEST %.2E SEC;\n", ( float ) usDelay / 1000 ); } } else { @@ -598,10 +598,10 @@ signed char ispVMCode() ***************************************************************/ if ( g_usDataType & LHEAP_IN ) { - printf( "%.2E SEC;\n", ( float ) usDelay / 1000000 ); + //printf( "%.2E SEC;\n", ( float ) usDelay / 1000000 ); } else { - printf( "RUNTEST %.2E SEC;\n", ( float ) usDelay / 1000000 ); + //printf( "RUNTEST %.2E SEC;\n", ( float ) usDelay / 1000000 ); } } #endif //VME_DEBUG @@ -619,7 +619,7 @@ signed char ispVMCode() ispVMClocks( usToggle ); #ifdef VME_DEBUG - printf( "RUNTEST %d TCK;\n", usToggle ); + //printf( "RUNTEST %d TCK;\n", usToggle ); #endif //VME_DEBUG break; case ENDDR: @@ -633,7 +633,7 @@ signed char ispVMCode() g_ucEndDR = GetByte(); #ifdef VME_DEBUG - printf( "ENDDR %s;\n", GetState( g_ucEndDR ) ); + //printf( "ENDDR %s;\n", GetState( g_ucEndDR ) ); #endif //VME_DEBUG break; case ENDIR: @@ -647,7 +647,7 @@ signed char ispVMCode() g_ucEndIR = GetByte(); #ifdef VME_DEBUG - printf( "ENDIR %s;\n", GetState( g_ucEndIR ) ); + //printf( "ENDIR %s;\n", GetState( g_ucEndIR ) ); #endif //VME_DEBUG break; case HIR: @@ -658,16 +658,16 @@ signed char ispVMCode() #ifdef VME_DEBUG switch( cOpcode ) { case HIR: - printf( "HIR " ); + //printf( "HIR " ); break; case TIR: - printf( "TIR " ); + //printf( "TIR " ); break; case HDR: - printf( "HDR " ); + //printf( "HDR " ); break; case TDR: - printf( "TDR " ); + //printf( "TDR " ); break; } #endif //VME_DEBUG @@ -685,7 +685,7 @@ signed char ispVMCode() } #ifdef VME_DEBUG - printf( ";\n" ); + //printf( ";\n" ); #endif //VME_DEBUG break; case MEM: @@ -701,7 +701,7 @@ signed char ispVMCode() g_usMaxSize = (unsigned short) ispVMDataSize(); #ifdef VME_DEBUG - printf( "// MEMSIZE %d\n", g_usMaxSize ); + //printf( "// MEMSIZE %d\n", g_usMaxSize ); #endif //VME_DEBUG break; case VENDOR: @@ -716,19 +716,19 @@ signed char ispVMCode() switch ( cOpcode ) { case LATTICE: #ifdef VME_DEBUG - printf( "// VENDOR LATTICE\n" ); + //printf( "// VENDOR LATTICE\n" ); #endif //VME_DEBUG g_cVendor = LATTICE; break; case ALTERA: #ifdef VME_DEBUG - printf( "// VENDOR ALTERA\n" ); + //printf( "// VENDOR ALTERA\n" ); #endif //VME_DEBUG g_cVendor = ALTERA; break; case XILINX: #ifdef VME_DEBUG - printf( "// VENDOR XILINX\n" ); + //printf( "// VENDOR XILINX\n" ); #endif //VME_DEBUG g_cVendor = XILINX; break; @@ -865,7 +865,7 @@ signed char ispVMCode() if(g_iFrequency == 1) g_iFrequency = 1000; #ifdef VME_DEBUG - printf( "FREQUENCY %.2E HZ;\n", ( float ) g_iFrequency * 1000 ); + //printf( "FREQUENCY %.2E HZ;\n", ( float ) g_iFrequency * 1000 ); #endif //VME_DEBUG } else @@ -873,7 +873,7 @@ signed char ispVMCode() if(g_iFrequency == 0) g_iFrequency = 1000; #ifdef VME_DEBUG - printf( "FREQUENCY %.2E HZ;\n", ( float ) g_iFrequency ); + //printf( "FREQUENCY %.2E HZ;\n", ( float ) g_iFrequency ); #endif //VME_DEBUG } break; @@ -957,7 +957,7 @@ signed char ispVMCode() ***************************************************************/ #ifdef VME_DEBUG - printf( "\nINVALID OPCODE: 0x%.2X\n", cOpcode ); + //printf( "\nINVALID OPCODE: 0x%.2X\n", cOpcode ); #endif //VME_DEBUG return VME_INVALID_FILE; @@ -1455,29 +1455,29 @@ signed char ispVMShift( signed char a_cCode ) } #ifdef VME_DEBUG - printf( "%d ", g_usiDataSize ); + //printf( "%d ", g_usiDataSize ); if ( g_usDataType & TDI_DATA ) { - printf( "TDI " ); + //printf( "TDI " ); PrintData( g_usiDataSize, g_pucInData ); } if ( g_usDataType & TDO_DATA ) { - printf( "\n\t\tTDO " ); + //printf( "\n\t\tTDO " ); PrintData( g_usiDataSize, g_pucOutData ); } if ( g_usDataType & MASK_DATA ) { - printf( "\n\t\tMASK " ); + //printf( "\n\t\tMASK " ); PrintData( g_usiDataSize, g_pucOutMaskData ); } if ( g_usDataType & DMASK_DATA ) { - printf( "\n\t\tDMASK " ); + //printf( "\n\t\tDMASK " ); PrintData( g_usiDataSize, g_pucOutDMaskData ); } - printf( ";\n" ); + //printf( ";\n" ); #endif //VME_DEBUG if ( g_usDataType & TDO_DATA || g_usDataType & DMASK_DATA ) { @@ -1586,7 +1586,7 @@ signed char ispVMAmble( signed char Code ) g_usiDataSize = (unsigned short)ispVMDataSize(); #ifdef VME_DEBUG - printf( "%d", g_usiDataSize ); + //printf( "%d", g_usiDataSize ); #endif //VME_DEBUG if ( g_usiDataSize ) { @@ -1631,7 +1631,7 @@ signed char ispVMAmble( signed char Code ) ispVMData( g_pucHIRData ); #ifdef VME_DEBUG - printf( " TDI " ); + //printf( " TDI " ); PrintData( g_usHeadIR, g_pucHIRData ); #endif //VME_DEBUG } @@ -1660,7 +1660,7 @@ signed char ispVMAmble( signed char Code ) ispVMData( g_pucTIRData ); #ifdef VME_DEBUG - printf( " TDI " ); + //printf( " TDI " ); PrintData( g_usTailIR, g_pucTIRData ); #endif //VME_DEBUG } @@ -1689,7 +1689,7 @@ signed char ispVMAmble( signed char Code ) ispVMData( g_pucHDRData ); #ifdef VME_DEBUG - printf( " TDI " ); + //printf( " TDI " ); PrintData( g_usHeadDR, g_pucHDRData ); #endif //VME_DEBUG } @@ -1718,7 +1718,7 @@ signed char ispVMAmble( signed char Code ) ispVMData( g_pucTDRData ); #ifdef VME_DEBUG - printf( " TDI " ); + //printf( " TDI " ); PrintData( g_usTailDR, g_pucTDRData ); #endif //VME_DEBUG } @@ -2017,7 +2017,7 @@ signed char ispVMLCOUNT( unsigned short a_usCountSize ) } #ifdef VME_DEBUG - printf( "LCOUNT %d;\n", a_usCountSize ); + //printf( "LCOUNT %d;\n", a_usCountSize ); #endif //VME_DEBUG /**************************************************************************** @@ -2092,12 +2092,12 @@ signed char ispVMLCOUNT( unsigned short a_usCountSize ) } ispVMStateMachine( ucState ); #ifdef VME_DEBUG - printf( "LDELAY %s ", GetState( ucState ) ); + //printf( "LDELAY %s ", GetState( ucState ) ); #endif //VME_DEBUG break; case SIR: #ifdef VME_DEBUG - printf( "SIR " ); + //printf( "SIR " ); #endif //VME_DEBUG /*************************************************************** * @@ -2110,7 +2110,7 @@ signed char ispVMLCOUNT( unsigned short a_usCountSize ) case SDR: #ifdef VME_DEBUG - printf( "LSDR " ); + //printf( "LSDR " ); #endif //VME_DEBUG /*************************************************************** * @@ -2143,7 +2143,7 @@ signed char ispVMLCOUNT( unsigned short a_usCountSize ) ***************************************************************/ usDelay &= ~0x8000; - printf( "%.2E SEC;\n", ( float ) usDelay / 1000 ); + //printf( "%.2E SEC;\n", ( float ) usDelay / 1000 ); } else { @@ -2153,7 +2153,7 @@ signed char ispVMLCOUNT( unsigned short a_usCountSize ) * ***************************************************************/ - printf( "%.2E SEC;\n", ( float ) usDelay / 1000000 ); + //printf( "%.2E SEC;\n", ( float ) usDelay / 1000000 ); } #endif //VME_DEBUG break; @@ -2169,7 +2169,7 @@ signed char ispVMLCOUNT( unsigned short a_usCountSize ) ispVMClocks( usToggle ); #ifdef VME_DEBUG - printf( "RUNTEST %d TCK;\n", usToggle ); + //printf( "RUNTEST %d TCK;\n", usToggle ); #endif //VME_DEBUG break; case ENDLOOP: @@ -2216,7 +2216,7 @@ signed char ispVMLCOUNT( unsigned short a_usCountSize ) ***************************************************************/ #ifdef VME_DEBUG - printf( "\nINVALID OPCODE: 0x%.2X\n", cOpcode ); + //printf( "\nINVALID OPCODE: 0x%.2X\n", cOpcode ); #endif //VME_DEBUG return VME_INVALID_FILE; @@ -2391,8 +2391,8 @@ void ispVMStateMachine( signed char cNextJTAGState ) void ispVMStart() { #ifdef VME_DEBUG - printf( "// ISPVM EMBEDDED ADDED\n" ); - printf( "STATE RESET;\n" ); + //printf( "// ISPVM EMBEDDED ADDED\n" ); + //printf( "STATE RESET;\n" ); #endif ispVMStateMachine( RESET ); /*step devices to RESET state*/ @@ -2410,9 +2410,9 @@ void ispVMStart() void ispVMEnd() { #ifdef VME_DEBUG - printf( "// ISPVM EMBEDDED ADDED\n" ); - printf( "STATE RESET;\n" ); - printf( "RUNTEST 1.00E-001 SEC;\n" ); + //printf( "// ISPVM EMBEDDED ADDED\n" ); + //printf( "STATE RESET;\n" ); + //printf( "RUNTEST 1.00E-001 SEC;\n" ); #endif ispVMStateMachine( RESET ); /*step devices to RESET state */ @@ -2704,7 +2704,7 @@ signed char ispVMRead( unsigned short a_usiDataSize ) *****************************************************************************/ #ifdef VME_DEBUG - printf( "RECEIVED TDO (" ); + //printf( "RECEIVED TDO (" ); #else vme_out_string( "Display Data: 0x" ); #endif //VME_DEBUG @@ -2728,9 +2728,9 @@ signed char ispVMRead( unsigned short a_usiDataSize ) cMaskByte >>= 1; } #ifdef VME_DEBUG - printf( "%.2X", cDataByte ); + //printf( "%.2X", cDataByte ); if ( ( ( ( a_usiDataSize + 7 ) / 8 ) - usDataSizeIndex ) % 40 == 39 ) { - printf( "\n\t\t" ); + //printf( "\n\t\t" ); } #else vme_out_hex( cDataByte ); @@ -2738,7 +2738,7 @@ signed char ispVMRead( unsigned short a_usiDataSize ) } #ifdef VME_DEBUG - printf( ")\n\n" ); + //printf( ")\n\n" ); #else vme_out_string( "\n\n" ); #endif //VME_DEBUG @@ -2761,7 +2761,7 @@ signed char ispVMRead( unsigned short a_usiDataSize ) else { #ifdef VME_DEBUG - printf( "TOTAL ERRORS: %d\n", usErrorCount ); + //printf( "TOTAL ERRORS: %d\n", usErrorCount ); #endif //VME_DEBUG return VME_VERIFICATION_FAILURE; @@ -3039,7 +3039,7 @@ signed char ispVMProcessLVDS( unsigned short a_usLVDSCount ) g_usLVDSPairCount = a_usLVDSCount; #ifdef VME_DEBUG - printf( "LVDS %d (", a_usLVDSCount ); + //printf( "LVDS %d (", a_usLVDSCount ); #endif //VME_DEBUG /*************************************************************** @@ -3063,17 +3063,17 @@ signed char ispVMProcessLVDS( unsigned short a_usLVDSCount ) #ifdef VME_DEBUG if ( usLVDSIndex < g_usLVDSPairCount - 1 ) { - printf( "%d:%d, ", g_pLVDSList[ usLVDSIndex ].usPositiveIndex, g_pLVDSList[ usLVDSIndex ].usNegativeIndex ); + //printf( "%d:%d, ", g_pLVDSList[ usLVDSIndex ].usPositiveIndex, g_pLVDSList[ usLVDSIndex ].usNegativeIndex ); } else { - printf( "%d:%d", g_pLVDSList[ usLVDSIndex ].usPositiveIndex, g_pLVDSList[ usLVDSIndex ].usNegativeIndex ); + //printf( "%d:%d", g_pLVDSList[ usLVDSIndex ].usPositiveIndex, g_pLVDSList[ usLVDSIndex ].usNegativeIndex ); } #endif //VME_DEBUG } #ifdef VME_DEBUG - printf( ");\n", a_usLVDSCount ); + //printf( ");\n", a_usLVDSCount ); #endif //VME_DEBUG return( 0 ); diff --git a/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/Control_File_System.c b/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/Control_File_System.c index c17d1335d..c58be6664 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/Control_File_System.c +++ b/Software/Embedded_SW/Embedded/Drivers/Flash_Memory/FATFS/Control_File_System.c @@ -90,7 +90,7 @@ static FATFS g_sFatFs; //} //tFResultString; -static int response ; +//static int response ; char FlashReadstring [35]; char FlashReadstring1 [35]; diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c index 566cb1cc6..940cd136c 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.c @@ -22,6 +22,7 @@ #include "driverlib/i2c.h" #include "drivers/I2C_Communication/I2C.h" #include "Blower.h" +#include "modules/control/control.h" DAC_Union DAC; @@ -159,7 +160,71 @@ uint32_t Turn_the_Blower_Off() return status; } +uint32_t mInitial_mV, mTarget_mV; +uint32_t mInterval = eOneSecond*20; +uint32_t BlowerControlId = 0xFF; +uint32_t Gradual_Increase_Blower_Callback(uint32_t DispenserId, uint32_t ReadValue) +{ + if ((mTarget_mV-mInitial_mV)<100) + { + Control_Voltage_To_Blower(mTarget_mV); + Report("Finished Increasing blower",__FILE__,__LINE__,(int)mTarget_mV,RpWarning,(int)millisecondCounter,0); + if (RemoveControlCallback(BlowerControlId, Gradual_Increase_Blower_Callback )==OK) + { + Report("Remove control callback",__FILE__,__LINE__,(int)1,RpWarning,(int)BlowerControlId,0); + BlowerControlId = 0xFF; + } + else + { + Report("Fixing Remove control ",__FILE__,__LINE__,(int)GetControlLowDevice_i(),RpWarning,(int)BlowerControlId,0); + if (RemoveControlCallback(GetControlLowDevice_i(),Gradual_Increase_Blower_Callback)==OK) + { + Report("Remove control callback fixed",__FILE__,__LINE__,(int)1,RpWarning,(int)BlowerControlId,0); + BlowerControlId = 0xFF; + } + else + Report("Remove control callback failed",__FILE__,__LINE__,(int)1,RpWarning,(int)BlowerControlId,0); + } + return OK; + } + mInitial_mV = mInitial_mV+100; + Control_Voltage_To_Blower(mInitial_mV); + Report("Increasing blower",__FILE__,__LINE__,(int)mInitial_mV,RpWarning,(int)millisecondCounter,0); + return OK; +} + +uint32_t Gradual_Increase_Blower(uint32_t Initial_mV,uint32_t Target_mV) +{ + mInitial_mV = Initial_mV; + mTarget_mV = Target_mV; + if ((mTarget_mV-mInitial_mV)<100) + { + Control_Voltage_To_Blower(mTarget_mV); + Report("Finished Increasing blower",__FILE__,__LINE__,(int)mTarget_mV,RpWarning,(int)millisecondCounter,0); + return OK; + } + mInitial_mV = Initial_mV+100; + Control_Voltage_To_Blower(mInitial_mV); + Report("Increasing blower",__FILE__,__LINE__,(int)mInitial_mV,RpWarning,(int)millisecondCounter,0); + BlowerControlId = AddControlCallback( Gradual_Increase_Blower_Callback, mInterval,getBlowerState ,0, 0, 0 ); + if (BlowerControlId == 0xFF) + { + Report("Add control callback failed",__FILE__,__LINE__,(int)0,RpWarning,(int)BlowerControlId,0); + return ERROR; + } +} +uint32_t Cancel_Gradual_Increase_Blower(uint32_t Initial_mV) +{ + Control_Voltage_To_Blower(Initial_mV); + Report("Cancelled Increasing blower",__FILE__,__LINE__,(int)Initial_mV,RpWarning,(int)millisecondCounter,0); + if (RemoveControlCallback(BlowerControlId, Gradual_Increase_Blower_Callback )==OK) + { + Report("Remove control callback",__FILE__,__LINE__,(int)1,RpWarning,(int)BlowerControlId,0); + BlowerControlId = 0xFF; + } + return OK; +} diff --git a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.h b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.h index 56a42a885..8f08e8d8c 100644 --- a/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.h +++ b/Software/Embedded_SW/Embedded/Drivers/I2C_Communication/DAC/Blower.h @@ -52,7 +52,8 @@ uint32_t Turn_the_Blower_On(); uint32_t Control_Voltage_To_Blower(uint32_t mV); uint32_t Turn_the_Blower_Off(); uint32_t getBlowerState(void); - +uint32_t Gradual_Increase_Blower(uint32_t Initial_mV,uint32_t Target_mV); +uint32_t Cancel_Gradual_Increase_Blower(uint32_t Initial_mV); #endif /* DRIVERS_I2C_COMMUNICATION_DAC_BLOWER_H_ */ diff --git a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c index 4c6b18030..b3ab21f0a 100644 --- a/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c +++ b/Software/Embedded_SW/Embedded/Drivers/USB_Communication/USBCDCD.c @@ -810,6 +810,13 @@ void USBCDCD_init(void) /* State specific variables */ state = USBCDCD_STATE_UNCONFIGURED; + /*added lines for drivers version 4.178*/ + uint32_t g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |SYSCTL_OSC_MAIN |SYSCTL_USE_PLL |SYSCTL_CFG_VCO_480), 120000000); + USBDCDFeatureSet(0, USBLIB_FEATURE_CPUCLK, &g_ui32SysClock); + //uint32_t ui32PLLRate; + //SysCtlVCOGet(SYSCTL_XTAL_25MHZ, &ui32PLLRate); + //USBDCDFeatureSet(0, USBLIB_FEATURE_USBPLL, &ui32PLLRate); + /* Set the USB stack mode to Device mode with VBUS monitoring */ USBStackModeSet(0, eUSBModeForceDevice, 0); diff --git a/Software/Embedded_SW/Embedded/Embedded.cfg b/Software/Embedded_SW/Embedded/Embedded.cfg index 97c95a452..45ed20a54 100644 --- a/Software/Embedded_SW/Embedded/Embedded.cfg +++ b/Software/Embedded_SW/Embedded/Embedded.cfg @@ -116,6 +116,12 @@ MillisecTaskParams.stackSize = 2048; MillisecTaskParams.priority = 12; Program.global.millisec = Task.create("&MillisecTask", MillisecTaskParams); +var FPGALoad = new Task.Params(); +FPGALoad.instance.name = "FPGALoad"; +FPGALoad.stackSize = 4096; +FPGALoad.priority = 5; +Program.global.FPGALoad = Task.create("&FPGALoadTask", FPGALoad); + var ControlTaskParams = new Task.Params(); ControlTaskParams.instance.name = "control"; ControlTaskParams.stackSize = 2048; diff --git a/Software/Embedded_SW/Embedded/Main.c b/Software/Embedded_SW/Embedded/Main.c index 430bb1181..64505193d 100644 --- a/Software/Embedded_SW/Embedded/Main.c +++ b/Software/Embedded_SW/Embedded/Main.c @@ -83,6 +83,8 @@ static volatile uint32_t g_ui32SysTickCount = 0; // Flags used to pass commands from interrupt context to the main loop. static volatile uint32_t g_ui32Flags; +bool Machine_Idle_Mode = false; + //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) { @@ -205,7 +207,13 @@ int main(void) //GetFiles(); - to start jtag //GetVmeByte(); - //////////////////////////// + // + //test_avi(); //example for shai + + #ifndef EVALUATION_BOARD + Init_Machine_Leds(); + #endif + // Enable interrupts to the processor. // diff --git a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c index eb4d0a49a..4f78d2134 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/MillisecTask.c @@ -83,6 +83,8 @@ bool watchdogCriticalAlarm = false; uint32_t msec_millisecondCounter = 0; +extern bool Machine_Idle_Mode; + MillisecMotorDataStruc ScrewSetMaxSpeedPending = {0}; MillisecMotorDataStruc ScrewMovePending = {0}; MillisecMotorDataStruc MotorData[NUM_OF_MOTORS] = {0}; @@ -420,6 +422,7 @@ uint32_t MillisecLoop(uint32_t tick) Dancer_Data[FEEDER_DANCER] = Read_Dancer_Position(FEEDER_DANCER); Dancer_Data[POOLER_DANCER] = Read_Dancer_Position(POOLER_DANCER); Dancer_Data[WINDER_DANCER] = Read_Dancer_Position(WINDER_DANCER); + return OK; } uint32_t MillisecLowLoop(uint32_t tick) @@ -445,6 +448,8 @@ uint32_t MillisecLowLoop(uint32_t tick) //Speed_Data = Calculate_Speed_Sensor_Velocity(); //MillisecReadFromTempSensor(Sensor_Read, NULL); //if (Sensor_Read++ >= MAX_TEMPERATURE_SENSOR_ID) Sensor_Read = 0; + if(Machine_Idle_Mode == true) + Machine_Idle_Breathing_Led(); } if (Hundred_msTick) { diff --git a/Software/Embedded_SW/Embedded/Modules/Control/control.c b/Software/Embedded_SW/Embedded/Modules/Control/control.c index 8349e7f91..100fefbd8 100644 --- a/Software/Embedded_SW/Embedded/Modules/Control/control.c +++ b/Software/Embedded_SW/Embedded/Modules/Control/control.c @@ -51,6 +51,7 @@ #include <inc/hw_ints.h> #include "drivers/adc_sampling/adc.h" +#include "Modules/General/buttons.h" #include "control.h" #include "MillisecTask.h" @@ -157,10 +158,20 @@ void ControlStop(void) uint32_t ControlActivityLed( uint32_t Parameter1) { static bool flag = false; + static uint8_t counter; + const uint8_t Blink_Freq = 15;//odd number + if (flag==true) { COMM_RED_LED_ON; ACTIVITY_RED_LED_OFF; // Heaters indication - all the Heaters OFF + if(power.color == fastBILNK) + Pannel_Leds(POWER_ON_OFF,MODE_OFF); + + if((power.color == BLINK) && (counter % Blink_Freq == 0) ) + { + Pannel_Leds(POWER_ON_OFF,MODE_OFF); + } flag = false; } else @@ -168,8 +179,22 @@ uint32_t ControlActivityLed( uint32_t Parameter1) COMM_RED_LED_OFF; if (HeaterActive > 0)// Blink the led on heating ACTIVITY_RED_LED_ON;// Heaters indication - at least one of the Heaters is ON + + if(power.color == fastBILNK) + Pannel_Leds(POWER_ON_OFF,MODE_ON); + + if((power.color == BLINK) && (counter % Blink_Freq == 0) ) + { + Pannel_Leds(POWER_ON_OFF,MODE_ON); + } + flag = true; } + + if (counter < 0xFF) + counter++; + else + counter = Blink_Freq + 1; return OK; } uint32_t ControlEmptyCBFunction(uint32_t IfIndex, uint32_t ReadValue) @@ -208,8 +233,8 @@ uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlF uint32_t device_i; uint32_t deviceId = 0xFF; - if (CtrlFrequency == eOneMillisecond) - { + //if (CtrlFrequency == eOneMillisecond) + //{ for(device_i = 0;device_i < MAX_TANGO_CONTROL_DEVICES;device_i++) { if (ControlArray[device_i].ControlActive == false) @@ -218,8 +243,8 @@ uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlF break; } } - if ((deviceId!=0xFF )&&(deviceId> MaxHighDevices)) - MaxHighDevices = deviceId; + /* if ((deviceId!=0xFF )&&(deviceId> MaxHighDevices)) + // MaxHighDevices = deviceId; } else { @@ -231,7 +256,7 @@ uint32_t AddControlCallback( ControlCBFunction Callback, CTRL_TIMING_ENUM CtrlF break; } } - } + }*/ if (deviceId == 0xFF) { @@ -348,7 +373,8 @@ uint32_t ControlLoop(uint32_t tick) Tick998 = (tick%eOneSecond == 996) ?true:false; */ //ROM_IntMasterDisable(); - for (ControlDevice_i = 0; ControlDevice_i < MaxHighDevices;ControlDevice_i++) + //for (ControlDevice_i = 0; ControlDevice_i < MaxHighDevices;ControlDevice_i++) + for (ControlDevice_i = 0; ControlDevice_i < MAX_TANGO_CONTROL_DEVICES;ControlDevice_i++) { if (ControlArray[ControlDevice_i].ControlActive) { diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticActions.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticActions.c index 2011444e2..ae362d189 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticActions.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/DiagnosticActions.c @@ -58,7 +58,7 @@ uint32_t SetComponentValueRequestRequestFunc(MessageContainer* requestContainer) { Turn_the_Blower_On(); intvoltage = voltage; - Control_Voltage_To_Blower(intvoltage); + Cancel_Gradual_Increase_Blower(intvoltage); } break; default: diff --git a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c index b00db94eb..f93bf8f60 100644 --- a/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c +++ b/Software/Embedded_SW/Embedded/Modules/Diagnostics/Diagnostics.c @@ -99,7 +99,7 @@ DoubleArray DiagnosticsDispenserPressure[MAX_SYSTEM_DISPENSERS]; HeaterState **heatersstates; HeaterState HeaterInfo[HEATER_TYPE__MixerHeater+1]; DigitalInterfaceState **digitalinterfacestates; -DigitalInterfaceState DigitalOutputState[MAX_HEATERS_NUM]; +DigitalInterfaceState DigitalOutputState[MAX_HEATERS_NUM/*+1*/]; /*double dispenser1motorfrequency[DIAGNOSTICS_LIMIT]; double dispenser2motorfrequency[DIAGNOSTICS_LIMIT]; double dispenser3motorfrequency[DIAGNOSTICS_LIMIT]; @@ -237,6 +237,9 @@ void DiagnosticsLoadDigitalValues(void) DigitalOutputState[9].interfaceio = INTERFACE_IOS__GPO_MIXCHIP_SSR4_CTRL; DigitalOutputState[9].value = GetHeaterState(9); + //DigitalOutputState[9].interfaceio = INTERFACE_IOS__GPO_SPARE_SSR13_CTRL; + //DigitalOutputState[9].value = GetHeaterState(9); + } void DiagnosticLoadTemperature(int HeaterId, int temperature) { @@ -315,30 +318,15 @@ void Diagnostic100msecCollection(void) return; DiagnosticLoadSpeedSensor(getSensorSpeedData()); -// dancer1angle[DiagnosticsIndex] = Control_Read_Dancer_Position(WINDER_DANCER, 0,0); -// dancer2angle[DiagnosticsIndex] = Control_Read_Dancer_Position(POOLER_DANCER, 0,0); -// dancer3angle[DiagnosticsIndex] = Control_Read_Dancer_Position(FEEDER_DANCER, 0,0); //if (JobIsActive()) { -/* DiagnosticLoadMotor(FEEDER_MOTOR, MotorGetSpeed (HARDWARE_MOTOR_TYPE__MOTO_RDRIVING)); ThreadGetMotorSpeed - DiagnosticLoadMotor(DRYER_MOTOR, MotorGetSpeed (HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING)); - DiagnosticLoadMotor(POOLER_MOTOR, MotorGetSpeed (HARDWARE_MOTOR_TYPE__MOTO_LDRIVING)); - DiagnosticLoadMotor(WINDER_MOTOR, MotorGetSpeed (HARDWARE_MOTOR_TYPE__MOTO_WINDER)); - DiagnosticLoadMotor(SCREW_MOTOR, MotorGetSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW));*/ DiagnosticLoadMotor(FEEDER_MOTOR, ThreadGetMotorSpeed (FEEDER_MOTOR)); DiagnosticLoadMotor(DRYER_MOTOR, ThreadGetMotorSpeed (DRYER_MOTOR)); DiagnosticLoadMotor(POOLER_MOTOR, ThreadGetMotorSpeed (POOLER_MOTOR)); DiagnosticLoadMotor(WINDER_MOTOR, ThreadGetMotorSpeed (WINDER_MOTOR)); DiagnosticLoadMotor(SCREW_MOTOR, ThreadGetMotorSpeed (SCREW_MOTOR)); } -/* - feedermotorfrequency[DiagnosticsIndex] = MotorGetSpeed (HARDWARE_MOTOR_TYPE__MOTO_RDRIVING); - dryermotor[DiagnosticsIndex] = MotorGetSpeed (HARDWARE_MOTOR_TYPE__MOTO_DRYER_DRIVING); - pollermotor[DiagnosticsIndex] = MotorGetSpeed (HARDWARE_MOTOR_TYPE__MOTO_LDRIVING); - windermotor[DiagnosticsIndex] = MotorGetSpeed (HARDWARE_MOTOR_TYPE__MOTO_WINDER); - screwmotor[DiagnosticsIndex] = MotorGetSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW); -*/ DiagnosticLoadTemperature(HARDWARE_PID_CONTROL_TYPE__MixerHeater, TemperatureSensorRead( TEMP_SENSE_ANALOG_MIXCHIP_TEMP)); DiagnosticLoadTemperature(HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ1, TemperatureSensorRead(TEMP_SENSE_ANALOG_DYEINGH_TEMP1)); DiagnosticLoadTemperature(HARDWARE_PID_CONTROL_TYPE__HeadHeaterZ2, TemperatureSensorRead(TEMP_SENSE_ANALOG_DYEINGH_TEMP2)); @@ -350,21 +338,9 @@ void Diagnostic100msecCollection(void) DiagnosticLoadTemperature(HARDWARE_PID_CONTROL_TYPE__DryerAirTemperature, TemperatureSensorRead(TEMP_SENSE_ANALOG_DRYER_TEMP1)); DiagnosticLoadTemperature(HARDWARE_PID_CONTROL_TYPE__DryerHeaterMain, TemperatureSensorRead(TEMP_SENSE_ANALOG_DRYER_TEMP2)); DiagnosticLoadTemperature(HARDWARE_PID_CONTROL_TYPE__DryerHeaterSecondary, TemperatureSensorRead(TEMP_SENSE_ANALOG_DRYER_TEMP3)); - /* - mixertemperature[DiagnosticsIndex] = TemperatureSensorRead(TEMP_SENSE_AN_ENCLOSURETEMP3)/100; - headzone1temperature[DiagnosticsIndex] = TemperatureSensorRead(TEMP_SENSE_ANALOG_DYEINGH_TEMP1)/100; - headzone2temperature[DiagnosticsIndex] = TemperatureSensorRead(TEMP_SENSE_ANALOG_DYEINGH_TEMP2)/100; - headzone3temperature[DiagnosticsIndex] = TemperatureSensorRead(TEMP_SENSE_ANALOG_DYEINGH_TEMP3)/100; - headzone4temperature[DiagnosticsIndex] = TemperatureSensorRead(TEMP_SENSE_ANALOG_DYEINGH_TEMP4)/100; - headzone5temperature[DiagnosticsIndex] = TemperatureSensorRead(TEMP_SENSE_ANALOG_DYEINGH_TEMP5)/100; - headzone6temperature[DiagnosticsIndex] = TemperatureSensorRead(TEMP_SENSE_ANALOG_MIXCHIP_TEMP)/100; - dryerzone1temperature[DiagnosticsIndex] = TemperatureSensorRead(TEMP_SENSE_ANALOG_DRYER_TEMP1)/100; - dryerzone2temperature[DiagnosticsIndex] = TemperatureSensorRead(TEMP_SENSE_ANALOG_DRYER_TEMP2)/100; - dryerzone3temperature[DiagnosticsIndex] = TemperatureSensorRead(TEMP_SENSE_ANALOG_DRYER_TEMP3)/100; -*/ for (i=0;i<MAX_SYSTEM_DISPENSERS;i++) { - dispensermotorfrequency[i][DiagnosticsIndex] = MotorGetSpeed(HARDWARE_MOTOR_TYPE__MOTO_DISPENSER_1+i); + dispensermotorfrequency[i][DiagnosticsIndex] = IdsGetMotorSpeed(i); dispenserspressure[i][DiagnosticsIndex] = GetDispenserPressure(i); //Read_MidTank_Pressure_Sensor MidTankpressure[i][0] = Get_MidTank_Pressure_Sensor(i); } diff --git a/Software/Embedded_SW/Embedded/Modules/General/buttons.c b/Software/Embedded_SW/Embedded/Modules/General/buttons.c index 68199d19f..f80727dfc 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/buttons.c +++ b/Software/Embedded_SW/Embedded/Modules/General/buttons.c @@ -10,8 +10,9 @@ #include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h"//#include "FPGA_GPIO.h" // use for FPGA IO #include "DataDef.h" // use for FPGA IO #include "Modules/Control/control.h" // use for FPGA IO - +#include "Modules/General/buttons.h" #include "StateMachines/Printing/PrintingSTM.h" +#include "drivers/FPGA/FPGA_GPIO/FPGA_GPIO.h" #include <stdlib.h> #include <stdint.h> @@ -26,15 +27,8 @@ int ch_to_power_down(); int ch_to_power_up(); int thredJog(); -typedef enum -{ - colorOFF = 0, - BLUE, - BLINK, - fastBILNK, - BREATHING -} PBcolor; +/* typedef enum { OFFPB = 0, @@ -43,7 +37,7 @@ typedef enum LONGPB , REPLONGPB //repeat long PB }PBstat; - +*/ typedef enum { MSEC = 0, @@ -53,47 +47,26 @@ typedef enum MORE5000 }timems; -typedef enum -{ - sttOFF = 0, - sttON, - sttDISABLE, - sttENABLE, - sttIDLE, - sttJOGGING, - sttRDY, - sttPRELOAD, - sttLOADING, - sttLOADSUCSESS, - sttLOADFAIL -} PBmachinState; + //enum PBstat OnOffPBstate = OFFPB; //enum PBstat ret //enum PBstat threadPB = OFFPB; -struct button -{ - char bttn_name[10]; //option - int bttn_status; // 0=release 1=press - /* enum */ PBstat Action; //offPB,shortPB,longPB,countPB,replongPB - /* enum */ PBcolor color; //off, blue, blink, bithing - /* enum */ PBmachinState state; //sttOFF, sttON, sttDISABLE, sttENABLE, sttIDLE, sttJOGGING - uint32_t count; -}; -struct button power , jog, load; + +button power , jog, load; uint32_t ButtonsCallBackFunction(uint32_t IfIndex, uint32_t ReadValue); uint32_t ButtonsCBFunction(uint32_t IfIndex, uint32_t ReadValue); -uint32_t ShortLongOffPB(uint8_t OnOffPB, struct button *pBtn); -uint32_t StateMachine(struct button *pBtn); +uint32_t ShortLongOffPB(uint8_t OnOffPB, button *pBtn); +uint32_t StateMachine( button *pBtn); uint32_t ButtonJogCallBackFunction(uint32_t IfIndex, uint32_t ReadValue); uint32_t ButtonJogCBFunction(uint32_t IfIndex, uint32_t ReadValue); uint8_t thraedJogging(uint8_t off); -uint32_t setJoggingEnableCondition(struct button *pBtn); -uint32_t joggingMachine(uint8_t OnOffPB, struct button *pBtn); +uint32_t setJoggingEnableCondition( button *pBtn); +uint32_t joggingMachine(uint8_t OnOffPB, button *pBtn); uint32_t ButtonLoadCallBackFunction(uint32_t IfIndex, uint32_t ReadValue); @@ -251,7 +224,7 @@ int StopTimer() //ShortLongOffPB( OnOffPB, &ret) -uint32_t ShortLongOffPB(uint8_t OnOffPB, struct button *pBtn) +uint32_t ShortLongOffPB(uint8_t OnOffPB, button *pBtn) { uint8_t parameter = 0 ; // why we need it!!!! @@ -333,7 +306,7 @@ uint32_t ShortLongOffPB(uint8_t OnOffPB, struct button *pBtn) -uint32_t StateMachine(struct button *pBtn) //short press(=0)/long press(=1) +uint32_t StateMachine( button *pBtn) //short press(=0)/long press(=1) { uint8_t parameter = 1; @@ -373,10 +346,12 @@ uint32_t StateMachine(struct button *pBtn) //short press(=0)/long press(=1) { case LONGPB: //Power off from idle pBtn->state = sttOFF; // todo + Pannel_Leds(POWER_ON_OFF,MODE_OFF); //AVI+ - TODO option MODE_ON to stop Breathing and the led will turn off in power down REPORT_MSG(parameter,"Power state is OFF "); break; case SHORTPB: //Wake up from idle pBtn->state = sttON;// to do ? + Pannel_Leds(POWER_ON_OFF,MODE_ON); //AVI+ REPORT_MSG(parameter,"Power state is ON "); break; default: @@ -406,7 +381,7 @@ return 0; -uint32_t setJoggingEnableCondition(struct button *pBtn) +uint32_t setJoggingEnableCondition( button *pBtn) { if (0 // 1. @@ -443,12 +418,13 @@ return 0; */ -uint32_t joggingMachine(uint8_t OnOffPB, struct button *pBtn) +uint32_t joggingMachine(uint8_t OnOffPB, button *pBtn) { if (sttDISABLE == pBtn->state) { // jogging is disable pBtn->color = colorOFF; + Pannel_Leds(THREAD_JOGGING,MODE_OFF);//AVI+ } else { @@ -456,6 +432,7 @@ uint32_t joggingMachine(uint8_t OnOffPB, struct button *pBtn) { ThreadAbortJoggingFunc(); // to do!!!! pBtn->color = BLUE; + Pannel_Leds(THREAD_JOGGING,MODE_ON);//AVI+ } else { @@ -534,5 +511,13 @@ ShortLongOffPB( threadPB, ret,struct button *pBtn); } */ +void test_avi() +{ + + power.color = BLINK; + //power.color = fastBILNK + //Machine_Idle_Mode = true; + +} diff --git a/Software/Embedded_SW/Embedded/Modules/General/buttons.h b/Software/Embedded_SW/Embedded/Modules/General/buttons.h index 897fb6031..e7a611e9b 100644 --- a/Software/Embedded_SW/Embedded/Modules/General/buttons.h +++ b/Software/Embedded_SW/Embedded/Modules/General/buttons.h @@ -1,6 +1,51 @@ #ifndef BUTTONS_H #define BUTTONS_H +typedef enum +{ + colorOFF = 0, + BLUE, + BLINK, + fastBILNK, + BREATHING +} PBcolor; + +typedef enum +{ + OFFPB = 0, + COUNTPB , + SHORTPB , + LONGPB , + REPLONGPB //repeat long PB +}PBstat; + +typedef enum +{ + sttOFF = 0, + sttON, + sttDISABLE, + sttENABLE, + sttIDLE, + sttJOGGING, + sttRDY, + sttPRELOAD, + sttLOADING, + sttLOADSUCSESS, + sttLOADFAIL +} PBmachinState; + +typedef struct +{ + char bttn_name[10]; //option + int bttn_status; // 0=release 1=press + /* enum */ PBstat Action; //offPB,shortPB,longPB,countPB,replongPB + /* enum */ PBcolor color; //off, blue, blink, bithing + /* enum */ PBmachinState state; //sttOFF, sttON, sttDISABLE, sttENABLE, sttIDLE, sttJOGGING + uint32_t count; +}button; + +extern button power , jog, load; + uint32_t Buttons_Init(void); uint32_t Button_load_Init(void); uint32_t Button_JOG_Init(void); diff --git a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c index d6f661789..aa9e4df4a 100644 --- a/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Heaters/Heaters_print.c @@ -453,9 +453,9 @@ uint32_t PrepareHeater(int HeaterId, uint32_t SetTemperatue) { Turn_the_Blower_On();//Turn on with the Default_Voltage if (BlowerCfg.heatingvoltage) - Control_Voltage_To_Blower(BlowerCfg.heatingvoltage); + Cancel_Gradual_Increase_Blower(BlowerCfg.heatingvoltage); else - Control_Voltage_To_Blower(BlowerCfg.voltage-500); + Cancel_Gradual_Increase_Blower(BlowerCfg.voltage-500); } if (SetTemperatue) @@ -717,8 +717,8 @@ uint32_t HeaterControlCBFunction(uint32_t IfIndex, uint32_t readValue) { Turn_the_Blower_On();//Turn on with the Default_Voltage if (BlowerCfg.voltage) - Control_Voltage_To_Blower(BlowerCfg.voltage); - + Gradual_Increase_Blower(BlowerCfg.heatingvoltage,BlowerCfg.voltage); + //Control_Voltage_To_Blower(BlowerCfg.voltage); } } return OK; diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c index 579c503bf..e748ea631 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_dispenser.c @@ -33,6 +33,7 @@ double DispenserPreparePressure = DISPENSER_BUILD_PRESSURE_LIMIT; uint32_t DispenserPrepareTimeout = DISPENSER_BUILD_PRESSURE_TIMEOUT; uint32_t DispenserPrepareTimeLag = DISPENSER_BUILD_PRESSURE_LAG; uint32_t DispenserPrepareTime[MAX_SYSTEM_DISPENSERS] = {0,0,0,0,0,0,0,0}; +uint32_t CurrentDispenserSpeed[MAX_SYSTEM_DISPENSERS] = {0, 0, 0, 0, 0, 0, 0, 0,}; callback_fptr DispenserCallback[MAX_SYSTEM_DISPENSERS] = {0, 0, 0, 0, 0, 0, 0, 0,}; uint32_t DispenserControlId[MAX_SYSTEM_DISPENSERS] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; @@ -49,6 +50,13 @@ void IDS_Dispenser_SetTimeOutValues(uint32_t CloseTimeout, uint32_t OpenTimeout) CloseValveTimeout = CloseTimeout; OpenValveTimeout = OpenTimeout; } + +//******************************************************************************************************************** +uint32_t IdsGetMotorSpeed(uint32_t DispenserId) +{ + return CurrentDispenserSpeed[DispenserId]; +} + uint32_t IDS_Dispenser_EmptyCBFunction(uint32_t IfIndex, uint32_t ReadValue) { return OK; @@ -79,6 +87,7 @@ uint32_t IDS_Dispenser_Build_Pressure_Callback(uint32_t DispenserId, uint32_t Re TimerMotors_t HW_Motor_Id = DispenserIdToMotorId[DispenserId]; MotorStop(HW_Motor_Id,Hard_Hiz); + CurrentDispenserSpeed[DispenserId] = 0; if (DispenserCallback[DispenserId]) { @@ -107,6 +116,7 @@ uint32_t IDS_Dispenser_Build_Pressure_Callback(uint32_t DispenserId, uint32_t Re DispenserPrepareTime[DispenserId]=0; TimerMotors_t HW_Motor_Id = DispenserIdToMotorId[DispenserId]; MotorSetSpeed(HW_Motor_Id, DispenserPrepareSpeed); + CurrentDispenserSpeed[DispenserId] = DispenserPrepareSpeed; } return OK; @@ -114,6 +124,7 @@ uint32_t IDS_Dispenser_Build_Pressure_Callback(uint32_t DispenserId, uint32_t Re uint32_t IDS_Dispenser_StopMotorCallback(uint32_t DispenserId, uint32_t ReadValue) { + Report("IDS_Dispenser_Close_Valve_And_Stop_Motor callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)msec_millisecondCounter,0); if (RemoveControlCallback(DispenserControlId[DispenserId], IDS_Dispenser_StopMotorCallback )==OK) { Report("Remove control callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); @@ -135,6 +146,7 @@ uint32_t IDS_Dispenser_Build_Pressure_Callback(uint32_t DispenserId, uint32_t Re TimerMotors_t HW_Motor_Id = DispenserIdToMotorId[DispenserId]; MotorStop(HW_Motor_Id,Hard_Hiz); + CurrentDispenserSpeed[DispenserId] = 0; if (DispenserCallback[DispenserId]) { @@ -147,8 +159,7 @@ uint32_t IDS_Dispenser_Build_Pressure_Callback(uint32_t DispenserId, uint32_t Re uint32_t IDS_Dispenser_Close_Valve_And_Stop_Motor(int DispenserId, callback_fptr callback) { DispenserCallback[DispenserId] = callback; - - Report("Control3WayValvesWithCallback called ",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)0,0); + Report("IDS_Dispenser_Close_Valve_And_Stop_Motor",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)msec_millisecondCounter,0); Control3WayValvesWithCallback ((Valves_t)DispenserId, CloseValve, NULL); //direction: MidTank_Dispenser or Dispenser_Mixer if (DispenserControlId[DispenserId] != 0xFF) @@ -165,6 +176,7 @@ uint32_t IDS_Dispenser_Build_Pressure_Callback(uint32_t DispenserId, uint32_t Re uint32_t IDS_Dispenser_OpenValveCallback(uint32_t DispenserId, uint32_t ReadValue) { + Report("IDS_Dispenser_Start_Motor_and_Open_Valve Callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)msec_millisecondCounter,0); if (RemoveControlCallback(DispenserControlId[DispenserId], IDS_Dispenser_OpenValveCallback )==OK) { @@ -199,8 +211,10 @@ uint32_t IDS_Dispenser_Start_Motor_and_Open_Valve(int DispenserId, int MotorSpee TimerMotors_t HW_Motor_Id = DispenserIdToMotorId[DispenserId]; MotorSetSpeed(HW_Motor_Id, MotorSpeed); + CurrentDispenserSpeed[DispenserId] = MotorSpeed; if (DispenserControlId[DispenserId] != 0xFF) Report("Cannot Add control callback",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)DispenserControlId[DispenserId],0); + Report("IDS_Dispenser_Start_Motor_and_Open_Valve",__FILE__,__LINE__,(int)DispenserId,RpWarning,(int)msec_millisecondCounter,0); DispenserControlId[DispenserId] = AddControlCallback( IDS_Dispenser_OpenValveCallback, OpenValveTimeout, IDS_Dispenser_EmptyCBFunction,DispenserId, DispenserId, 0 ); if (DispenserControlId[DispenserId] == 0xFF) diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h index 7d8a204ac..8f58bac3e 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_ex.h @@ -61,5 +61,6 @@ void IDS_Dispenser_Content_Calculation (char DispenserId); float CalculateDispenserPressure (int DispenserId); float GetDispenserPressure(int DispenserId); +uint32_t IdsGetMotorSpeed(uint32_t DispenserId); #endif /* MODULES_IDS_IDS_EX_H_ */ diff --git a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c index 119624e3d..5ee8a150d 100644 --- a/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c +++ b/Software/Embedded_SW/Embedded/Modules/IDS/IDS_print.c @@ -319,6 +319,15 @@ uint32_t IDSPreSegmentState(void *JobDetails, int SegmentId) DispenserPreSegmentReady[DispenserId] = false; REPORT_MSG(DispenserId,"IDS_Valve_Presegment start"); IDS_Dispenser_Set_Flow_Params(DispenserId,0,0); + if (JobTicket->segments[DispenserId]->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->dispenserstepdivision != DISPENSER_STEP_DIVISION__Auto) + { + MotorSetMicroStep(HW_Motor_Id, JobTicket->segments[DispenserId]->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->dispenserstepdivision); + } + else + { + MotorSetMicroStep(HW_Motor_Id, MotorsCfg[HW_Motor_Id].microstep); + } + if (JobTicket->segments[SegmentId]->brushstops[0]->dispensers[Dispenser_i]->nanolitterpersecond==0) { //MotorStop(HW_Motor_Id,Hard_Hiz); @@ -397,14 +406,14 @@ uint32_t IDSPreSegmentState(void *JobDetails, int SegmentId) JobTicket->segments[CurrentSegment]->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->nanoliterperpulse; if (JobTicket->segments[CurrentSegment]->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->dispenserstepdivision != DISPENSER_STEP_DIVISION__Auto) { - MotorSetMicroStep(HW_Motor_Id, JobTicket->segments[CurrentSegment]->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->dispenserstepdivision); + //MotorSetMicroStep(HW_Motor_Id, JobTicket->segments[CurrentSegment]->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->dispenserstepdivision); segmentfirst_speed/=JobTicket->segments[CurrentSegment]->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->dispenserstepdivision; //the dye supply is calculated based on a 1/8 microstep IDS_Dispenser_Set_Flow_Params ( DispenserId, JobTicket->segments[CurrentSegment]->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->nanoliterperpulse , JobTicket->segments[CurrentSegment]->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->dispenserstepdivision); } else { - segmentfirst_speed/=MotorsCfg[HW_Motor_Id].microstep; //the dye supply is calculated based on a 1/8 microstep + //segmentfirst_speed/=MotorsCfg[HW_Motor_Id].microstep; //the dye supply is calculated based on a 1/8 microstep IDS_Dispenser_Set_Flow_Params ( DispenserId, JobTicket->segments[CurrentSegment]->brushstops[JobBrushStopId]->dispensers[Dispenser_i]->nanoliterperpulse ,MotorsCfg[HW_Motor_Id].microstep); } diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c index 58ade0802..e2f97d970 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/ThreadLoad.c @@ -129,9 +129,9 @@ { Turn_the_Blower_On();//Turn on with the Default_Voltage if (BlowerCfg.heatingvoltage) - Control_Voltage_To_Blower(BlowerCfg.heatingvoltage); + Cancel_Gradual_Increase_Blower(BlowerCfg.heatingvoltage); else - Control_Voltage_To_Blower(BlowerCfg.voltage-500); + Cancel_Gradual_Increase_Blower(BlowerCfg.voltage-500); Control_Dryer_Fan(STOP,75);//use START or STOP, 0 - 100% LoadStages++; ThreadLoadStateMachine(LoadStages); diff --git a/Software/Embedded_SW/Embedded/Software Release Notes.txt b/Software/Embedded_SW/Embedded/Software Release Notes.txt new file mode 100644 index 000000000..dd8679721 --- /dev/null +++ b/Software/Embedded_SW/Embedded/Software Release Notes.txt @@ -0,0 +1,11 @@ +Embedded SW Release note - Version 1.3.7.0 +This version includes massive changes in job handling, files support and hardware changes. also cleans multiple bugs and improves machine handing, cleans and removes unnecessary code from the SW files. +it contains thet basis for improving the process and the operator control ability. +1. file system: File system full handling, SW Upgrade support for FPGA, Load HW Config and embedded parameters from file, Dispensers activity stored in file. +2. alarm handling: new list supports system definitions version 2. overheat/underheat type A/B handled, +3. driver level support for all new HW/Backplan features. initial support for operator buttons. (tamper switches, WHS readout and sensors, buttons, magnet, head and cleaning motors and switches...) +4. additional RAM space in internal RAM for additional development space +5. Initial support for thread insertion fullprocess - not tested yet. +6. bugs solved in control activity, in job handling and more. real time handling improved in main control functions +7. IDS Infrastructure for testing: pressure bulding before job, coordinated activation of motors and valves (motor starts before valve opens, stops after valve closes. + diff --git a/Software/Embedded_SW/Embedded/tm4c129xnczad.cmd b/Software/Embedded_SW/Embedded/tm4c129xnczad.cmd index d63d890cd..25916dae2 100644 --- a/Software/Embedded_SW/Embedded/tm4c129xnczad.cmd +++ b/Software/Embedded_SW/Embedded/tm4c129xnczad.cmd @@ -42,7 +42,7 @@ MEMORY { /* Application stored in and executes from internal flash */ - FLASH (RX) : origin = APP_BASE, length = 0x000B0000 + FLASH (RX) : origin = APP_BASE, length = 0x000D0000 /* Application stored in and executes from internal flash */ FLASH_RAM (RWX) : origin = FLASH_RAM_BASE, length = 0x00030000 /* Application uses internal RAM for data */ |
