]> rtime.felk.cvut.cz Git - fpga/rpi-motor-control.git/blobdiff - pmsm-control/test_sw/cmd_proc.c
Function Init_logs moved to right place.
[fpga/rpi-motor-control.git] / pmsm-control / test_sw / cmd_proc.c
index cc92a0b29a13c0c5ec73bdd3b0d609f9c9484ef2..6846df594e5a57eb4ed02931d4565dcb72e8b2cb 100644 (file)
@@ -3,12 +3,13 @@
 #include <string.h>
 
 #include "cmd_proc.h"
+#include "logs.h"
 
 #define PRUM_PROUD     2061
 #define PRUM_SOUC      6183
 
 static char doPrint = 1;
-static char error = 0;
+
 
 /*
  * \brief
@@ -60,7 +61,7 @@ static void start(struct rpi_state* state){
  */
 static void stop(struct rpi_state* state){
        sem_wait(&state->thd_par_sem);
-       state->commutate=0;
+       setCommutationOff(state);
        state->pos_reg_ena=0;
        state->spd_reg_ena=0;
        state->duty=0;
@@ -81,7 +82,7 @@ static void dutySet(struct rpi_state* state, int duty){
        state->duty=duty;
        state->pos_reg_ena=0;
        state->spd_reg_ena=0;
-       state->commutate=1;
+       setCommutationOn(state);
        sem_post(&state->thd_par_sem);
 }
 
@@ -93,7 +94,7 @@ static void goAbsolute(struct rpi_state* state, int pos){
        sem_wait(&state->thd_par_sem);
        state->spd_reg_ena=0;
        state->pos_reg_ena=1;
-       state->commutate=1;
+       setCommutationOn(state);
        state->desired_pos=pos;
        sem_post(&state->thd_par_sem);
 }
@@ -125,7 +126,7 @@ static void setSpeed(struct rpi_state* state, int speed){
        sem_wait(&state->thd_par_sem);
        state->pos_reg_ena=0;
        state->spd_reg_ena=1;
-       state->commutate=1;
+       setCommutationOn(state);
        state->desired_spd=speed;
        sem_post(&state->thd_par_sem);
 }
@@ -142,53 +143,6 @@ static void setAlphaOff(struct rpi_state* state, int offset){
        sem_post(&state->thd_par_sem);
 }
 
-/*
- * \brief
- * Initialize logs
- */
-static void logInit(struct rpi_state* state){
-       int r;
-       state->log_col=0;
-       state->log_col_count=LOG_DEF_COL;
-       for (r=0;r<LOG_ROWS;r++){
-               state->logs[r]=malloc(state->log_col_count*sizeof(int));
-               if (state->logs[r]==NULL){
-                       error=1;
-                       state->log_col_count=-1;
-                       return;
-               }
-       }
-       state->doLogs=1;
-}
-
-/*
- * \brief
- * Save logs
- */
-static void saveLogs(struct rpi_state* state){
-       FILE *f;
-       int r,s;
-
-       f = fopen("logs.log", "w");
-       if (f == NULL){
-               printf("Error opening file!\n");
-               return;
-       }
-
-       for (r=0;r<LOG_ROWS;r++){
-               for(s=0;s<state->log_col-1;s++){        /*posledni sloupec je vevyplneny*/
-                       if (s==state->log_col-2){
-                               fprintf(f,"%d ",state->logs[r][s]);
-                       }else{
-                               fprintf(f,"%d, ",state->logs[r][s]);
-                       }
-               }
-               fprintf(f,"\r");
-       }
-       fclose(f);
-       freeLogs();
-}
-
 /**
  * \brief
  * SetLog
@@ -316,6 +270,6 @@ void printData(struct rpi_state* state){
        if (s.index_ok) printf("index ok\n");
        if (s.commutate) printf("commutation in progress\n");
        if (s.doLogs) printf("logujeme\n");
-       if (error) printf("error pri maloc logs!! \n");
+       if (s.error) printf("error pri maloc logs!! \n");
 
 }