diff options
| author | Avi Levkovich <avi@twine-s.com> | 2018-05-13 12:03:21 +0300 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2018-05-13 12:03:21 +0300 |
| commit | e74f4da5899eea9abea143771fa2a950a50da963 (patch) | |
| tree | 72be008fda9e7ef36ab501c375bd7f1834afe0b4 /Software/Embedded_SW/Embedded/Modules | |
| parent | 93b67561169bb5d2cc5696e3f723aa98ad0523c0 (diff) | |
| download | Tango-e74f4da5899eea9abea143771fa2a950a50da963.tar.gz Tango-e74f4da5899eea9abea143771fa2a950a50da963.zip | |
Use only motor hardware enum + stop using the AMT_OF_Words in the spi communication
Diffstat (limited to 'Software/Embedded_SW/Embedded/Modules')
| -rw-r--r-- | Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c | 81 | ||||
| -rw-r--r-- | Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c | 10 |
2 files changed, 50 insertions, 41 deletions
diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c index fef551748..e6c47597a 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c @@ -48,11 +48,13 @@ #include "Modules/thread/thread.h" #include "Drivers/Motors/Motor.h" +#include "drivers/FPGA/FPGA_SPI_Comm.h" + extern unsigned long Run_Value ; extern unsigned long Pos_Value ; extern bool Direction ; -unsigned char Stop_Command = 0 ; +STOP_TYPE_ENUM Stop_Command; int Global_EVB_Motor_Id; @@ -71,30 +73,51 @@ void Stub_MotorInitRequest(MessageContainer* requestContainer) init_BUSY_Pin(); //while(SSIBusy(SSI2_BASE)){}; //init_BUSY_Pin(); -/* - * typedef struct -{ - uint32_t ACC; //set - uint32_t DEC; //set - uint32_t MaxSpeed; //set - bool HasMicroStep; - uint32_t Microstep; //set - bool HasConfigWord; - uint16_t ConfigWord; //set -}MotorDriverConfigStruc; - * */ + +#else + + MotorsInit(); + SysCtlDelay(20000); + //MotorConfig(request->motor_id, &MotorConfig); + +#endif + // MotorsConfigMessage already calls setup!!!!!!!!! MotorDriverConfigStruc MotorDriverConfig; - MotorDriverConfig.ACC = request->acc; - MotorDriverConfig.DEC = request->dec; - MotorDriverConfig.MaxSpeed = request->max_speed; - MotorDriverConfig.HasMicroStep = request->has_micro_steps; - MotorDriverConfig.HasConfigWord = false; - if ( MotorDriverConfig.HasMicroStep) - MotorDriverConfig.Microstep = request->micro_steps; + MotorDriverConfig.maxchangeslope = request->acc; + MotorDriverConfig.maxchangeslope = request->dec; + MotorDriverConfig.maxfrequency = request->max_speed; + MotorDriverConfig.has_setmicrostep = request->has_micro_steps; + + if ( MotorDriverConfig.has_setmicrostep) + MotorDriverConfig.microstep = request->micro_steps; // else // MotorDriverConfig.Microstep = 2; + //MotorDriverConfig.HasConfigWord = false; + + + MotorDriverConfig.has_configword = request->has_config; + MotorDriverConfig.configword = request->config; + MotorDriverConfig.has_lowspeedoptimization = request->has_min_speed_lspd_opt; + MotorDriverConfig.lowspeedoptimization = request->has_min_speed_lspd_opt; + MotorDriverConfig.kvalhold = request->kval_hold; + MotorDriverConfig.kvalrun = request->kval_run; + MotorDriverConfig.kvalacc = request->kval_acc; + MotorDriverConfig.kvaldec = request->kval_dec; + MotorDriverConfig.stslp = request->st_slp; + MotorDriverConfig.intspd = request->int_spd; + MotorDriverConfig.fnslpacc = request->fn_slp_acc; + MotorDriverConfig.fnslpdec = request->fn_slp_dec; + + +#ifdef EVALUATION_BOARD + Global_EVB_Motor_Id = request->motor_id; setup(&MotorDriverConfig); +#else + TimerMotors_t MotorId =(TimerMotors_t) request->motor_id; + + //MotorConfig(MotorId, &MotorDriverConfig); ------------------------------ to open !!!!!!!!!!!!!!!!!!!!!!1 +#endif //setup(); @@ -116,19 +139,10 @@ void Stub_MotorInitRequest(MessageContainer* requestContainer) //SPI_Control(); //temp_init_spi2(); -#endif - - -#ifndef EVALUATION_BOARD - -MotorsInit(); -SysCtlDelay(20000); -//MotorConfig(request->motor_id, &MotorConfig); - -#endif +/* HardwareMotor MotorConfig; HardwareMotorType Motor_Id = (HardwareMotorType)request->motor_id; @@ -137,8 +151,8 @@ SysCtlDelay(20000); MotorConfig.maxfrequency = request->max_speed; MotorConfig.microstep = request->micro_steps; MotorsConfigMessage(&MotorConfig); +*/ - Global_EVB_Motor_Id = request->motor_id; @@ -197,6 +211,9 @@ void Stub_MotorRunRequest(MessageContainer* requestContainer) //status = FPGA_ReadVersion((unsigned char)request->fpgaid, &Version, &Year, &Month, &Day); #else TimerMotors_t Motor_Id = (TimerMotors_t)request->motor_id; //to remove warning + + FPGA_GetBusy(); + MotorSetDirection(Motor_Id,Direction); MotorSetSpeed(Motor_Id, Run_Value, 1); #endif @@ -270,7 +287,7 @@ void Stub_MotorStopRequest(MessageContainer* requestContainer) StubMotorStopRequest* request = stub_motor_stop_request__unpack(NULL, requestContainer->data.len, requestContainer->data.data); - Stop_Command = request->stop_cmd; + Stop_Command = (STOP_TYPE_ENUM)request->stop_cmd; #ifdef EVALUATION_BOARD diff --git a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c index 5a8c3df76..0e276fe92 100644 --- a/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c +++ b/Software/Embedded_SW/Embedded/Modules/Thread/Thread_init.c @@ -51,7 +51,6 @@ uint32_t MotorsConfigMessage(HardwareMotor * request) { uint32_t status = PASSED; TimerMotors_t Motor_i; - MotorDriverConfigStruc MotorDriverConfig; Motor_i = request->hardwaremotortype; /*for (i=0;i<MAX_THREAD_MOTORS_NUM;i++) { @@ -69,15 +68,8 @@ uint32_t MotorsConfigMessage(HardwareMotor * request) //if (Motor_i< MAX_THREAD_MOTORS_NUM) //{ memcpy (&MotorsCfg[Motor_i],request,sizeof(HardwareMotor)); - MotorDriverConfig.ACC = MotorsCfg[Motor_i].maxchangeslope; - MotorDriverConfig.DEC = MotorsCfg[Motor_i].maxchangeslope; - MotorDriverConfig.MaxSpeed = MotorsCfg[Motor_i].maxfrequency; - MotorDriverConfig.HasMicroStep = MotorsCfg[Motor_i].has_microstep; - MotorDriverConfig.Microstep = MotorsCfg[Motor_i].microstep; - MotorDriverConfig.HasConfigWord = MotorsCfg[Motor_i].has_configword; - MotorDriverConfig.ConfigWord = MotorsCfg[Motor_i].configword; - status = MotorConfig( Motor_i, &MotorDriverConfig); + status = MotorConfig( Motor_i, &MotorsCfg[Motor_i]); // if (Motor_i == MOTOR_RDRIVING) // ThreadInitialTestStub(request); |
