diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2018-07-26 11:00:03 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2018-07-26 11:00:03 +0300 |
| commit | c280718d3396dd8ebe6fc48e2a700eeaa206de5e (patch) | |
| tree | e27becbc1fcf3fd3ba21c0e319268add6337c66d /Software/Embedded_SW | |
| parent | 31238931d777301596aa50dd8ac5632ca887c689 (diff) | |
| download | Tango-c280718d3396dd8ebe6fc48e2a700eeaa206de5e.tar.gz Tango-c280718d3396dd8ebe6fc48e2a700eeaa206de5e.zip | |
uart order and improvements. thread winder log for prepare error. break sensor active!
Diffstat (limited to 'Software/Embedded_SW')
5 files changed, 83 insertions, 55 deletions
diff --git a/Software/Embedded_SW/Embedded/Communication/Connection.c b/Software/Embedded_SW/Embedded/Communication/Connection.c index c5bda84d2..ed7aa9dfc 100644 --- a/Software/Embedded_SW/Embedded/Communication/Connection.c +++ b/Software/Embedded_SW/Embedded/Communication/Connection.c @@ -65,7 +65,7 @@ void DisconnectionRequest(MessageContainer* requestContainer) DiagnosticsStop(); HeatingStopReporting(); JobStopReporting(); - UART_ResetBuffers(); + //UART_ResetBuffers(); //------------------------------------------------------------------------------------------- uint8_t* container_buffer = malloc(message_container__get_packed_size(&responseContainer)); size_t container_size = message_container__pack(&responseContainer, container_buffer); diff --git a/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/Uart.c b/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/Uart.c index 3a2fdeec1..bb762fdde 100644 --- a/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/Uart.c +++ b/Software/Embedded_SW/Embedded/Drivers/Uart_Comm/Uart.c @@ -63,9 +63,46 @@ /// #define U0_BAUDRATE 115200 +//***************************************************************************** +// +// The Global parameters +// +//***************************************************************************** +int U0_expected_message_size = 0; +int U0_current_message_size = 0; +int U0_size_bar = 0; + +/****************** Debug Data **********************************************/ +uint32_t Uart_tx_Counter = 0; +uint32_t Uart_rx_Counter = 0; +uint32_t Uart_rx_TotalCounter = 0; +bool UartResetProcess = false; +//uint32_t uart_INT_OECounter = 0; +//uint32_t uart_INT_BECounter = 0; +//uint32_t uart_INT_PECounter = 0; +//uint32_t uart_INT_FECounter = 0; +uint32_t uart_INT_RTCounter = 0; +uint32_t uart_INT_RXCounter = 0; + +//void UART0IntHandler(void) +//uint32_t uDataLength[50] = {0}; +//void * DataPointer[50]= {0}; +//byte uindex = 0; +uint32_t TxuDataLength[50] = {0}; +void * TxDataPointer[50]= {0}; +byte Txuindex = 0; +uint8_t oldsize[4]; +uint32_t udata[51]; +int dataindex=0; + void UARTIntHandler(UArg arg0); +//***************************************************************************** +// +// The UART Initialization. +// +//***************************************************************************** void Init_U0(void) { ROM_IntMasterDisable(); @@ -91,7 +128,7 @@ void Init_U0(void) // ROM_UARTIntEnable(UART0_BASE, /*UART_INT_TX |*/ UART_INT_RX ); ROM_UARTIntEnable(UART0_BASE, (UART_INT_RT | UART_INT_RX)); // ROM_UARTIntEnable(UART0_BASE, (UART_INT_OE | UART_INT_BE | UART_INT_PE | -// UART_INT_FE | UART_INT_RT | UART_INT_TX | UART_INT_RX)); +// UART_INT_FE | UART_INT_RT /*| UART_INT_TX */| UART_INT_RX)); ROM_UARTEnable(UART0_BASE); @@ -103,52 +140,34 @@ void Init_U0(void) ROM_IntMasterEnable(); } - - - - -int U0_expected_message_size = 0; -int U0_current_message_size = 0; -int U0_size_bar = 0; -uint32_t Uart_tx_Counter = 0; -uint32_t Uart_rx_Counter = 0; -uint32_t Uart_rx_TotalCounter = 0; -bool UartResetProcess = false; -//uint32_t uart_INT_OECounter = 0; -//uint32_t uart_INT_BECounter = 0; -//uint32_t uart_INT_PECounter = 0; -//uint32_t uart_INT_FECounter = 0; -uint32_t uart_INT_RTCounter = 0; -uint32_t uart_INT_RXCounter = 0; - //***************************************************************************** // -// The UART interrupt handler. +// The UART Buffers reset. // //***************************************************************************** -//void UART0IntHandler(void) -uint32_t uDataLength[50] = {0}; -void * DataPointer[50]= {0}; -byte uindex = 0; -uint8_t oldsize[4]; -uint32_t udata[51]; -int dataindex=0; void UART_ResetBuffers(void) { - ROM_UARTIntClear(UART0_BASE, ROM_UARTIntStatus(UART0_BASE, false)); - while (UARTCharsAvail(UART0_BASE)) //empty rx buffer - { - ; - } - ROM_UARTDisable(UART0_BASE); - UartResetProcess = true; - U0_expected_message_size = 0; - U0_current_message_size = 0; - U0_size_bar = 0; - SysCtlDelay(200000); - ROM_UARTEnable(UART0_BASE); - UartResetProcess = false; + ROM_UARTIntClear(UART0_BASE, ROM_UARTIntStatus(UART0_BASE, false)); + /* + UartResetProcess = true; + while (UARTCharsAvail(UART0_BASE)) //empty rx buffer + { + ; + } + ROM_UARTDisable(UART0_BASE); + U0_expected_message_size = 0; + U0_current_message_size = 0; + U0_size_bar = 0; + SysCtlDelay(200000); + ROM_UARTEnable(UART0_BASE); + UartResetProcess = false; + */ } +//***************************************************************************** +// +// The UART interrupt handler. +// +//***************************************************************************** void UARTIntHandler(UArg arg0) { uint32_t ui32Status; @@ -213,6 +232,11 @@ void UARTIntHandler(UArg arg0) } +//***************************************************************************** +// +// The UART Transmit handler. +// +//***************************************************************************** uint32_t Uart_Tx(char *buffer,size_t length) { @@ -244,10 +268,10 @@ uint32_t Uart_Tx(char *buffer,size_t length) } } - uDataLength[uindex] = length+4; - DataPointer[uindex] = buffer; - if (uindex++>=50) - uindex = 0; + TxuDataLength[Txuindex] = length+4; + TxDataPointer[Txuindex] = buffer; + if (Txuindex++>=50) + Txuindex = 0; // if (ret!=length) // return 1; diff --git a/Software/Embedded_SW/Embedded/Embedded.cfg b/Software/Embedded_SW/Embedded/Embedded.cfg index 5f59e3e14..1d2262bec 100644 --- a/Software/Embedded_SW/Embedded/Embedded.cfg +++ b/Software/Embedded_SW/Embedded/Embedded.cfg @@ -116,22 +116,22 @@ task2Params.priority = 10; task2Params.stackSize = 8192; Program.global.communication = Task.create("&communicationTask", task2Params); -var task10Params = new Task.Params(); -task10Params.instance.name = "communicationTx"; -task10Params.priority = 9; -Program.global.communicationTx = Task.create("&communicationTxTask", task10Params); - var task9Params = new Task.Params(); task9Params.instance.name = "HeatersControl"; -task9Params.priority = 8; +task9Params.priority = 9; Program.global.HeatersControl = Task.create("&HeatersControlTask", task9Params); var task5Params = new Task.Params(); task5Params.instance.name = "process"; task5Params.stackSize = 4096; -task5Params.priority = 7; +task5Params.priority = 8; Program.global.process = Task.create("&jobTask", task5Params); +var task10Params = new Task.Params(); +task10Params.instance.name = "communicationTx"; +task10Params.priority = 7; +Program.global.communicationTx = Task.create("&communicationTxTask", task10Params); + var task12Params = new Task.Params(); task12Params.instance.name = "AlarmHandling"; task12Params.priority = 6; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c index 0ec10a072..c8d2e6362 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_Winder.c @@ -73,7 +73,7 @@ uint32_t Winder_Prepare(void) //float process_speed = JobTicket->processparameters->dyeingspeed; double ScrewSpeed = 500;//(process_speed*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].pulleyradius); // we will use pulley radius of the screw for this purpose, as of now - + //REPORT_MSG(ScrewSpeed, "Winder_Prepare"); /* * 1. move home to the limit switch (check that the cart is clear from the limit switch, start moving, with acceleration to maximal speed. enable interrupt on the limit switch, upon interrupt stop. * 2. move back x steps - according to thehw specifications and bobine definitions in the job. move for a predefined number of steps. get a callback when done @@ -81,11 +81,13 @@ uint32_t Winder_Prepare(void) */ if (FPGA_Read_limit_Switches(GPI_LS_SCREW_RIGHT)==LIMIT) { + REPORT_MSG(LIMIT, "Winder_Prepare at limit"); Winder_PrepareStage2(0,0); } else { Winder_ScrewHoming = true; + //REPORT_MSG(MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, "Winder_Prepare move to limit"); status = MotorMovetoLimitSwitch (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize, ScrewSpeed, GPI_LS_SCREW_RIGHT, Winder_PrepareStage2); } return status; @@ -102,6 +104,7 @@ uint32_t Winder_PrepareStage2(uint32_t deviceID, uint32_t ReadValue) uint32_t numOfSteps = InternalWinderCfg.startoffsetpulses*MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].microstep; MotorSetMaxSpeed (HARDWARE_MOTOR_TYPE__MOTO_SCREW,MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].maxfrequency); + //REPORT_MSG(numOfSteps, "Winder_PrepareStage2"); status |= MotorMoveWithCallback(HARDWARE_MOTOR_TYPE__MOTO_SCREW, (1-MotorsCfg[HARDWARE_MOTOR_TYPE__MOTO_SCREW].directionthreadwize),numOfSteps, Winder_ScrewAtOffsetCallback); //set motor location 0 here @@ -119,6 +122,7 @@ uint32_t Winder_ScrewAtOffsetCallback(uint32_t deviceID, uint32_t BusyFlag) ScrewControlId = 0xFF; ScrewNumberOfSteps = 0; DirectionChangeCounter = 0; + //REPORT_MSG(BusyFlag, "Winder_ScrewAtOffsetCallback"); PrepareReady(Module_Winder, ModuleDone); return OK; diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c index 30badab9a..d19b447d9 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_print.c @@ -359,9 +359,9 @@ uint32_t ThreadControlCBFunction(uint32_t IfIndex, uint32_t ReadValue) { if (ReadBreakSensor()==ERROR) { - LOG_ERROR(index, "ReadBreakSensor Error"); + //LOG_ERROR(index, "ReadBreakSensor Error"); //SendJobProgress(0.0,0,false, "ReadBreakSensor Error"); - //EndState(CurrentJob,"ReadBreakSensor Error" ); + EndState(CurrentJob,"ReadBreakSensor Error" ); } } } |
