X-Git-Url: https://rtime.felk.cvut.cz/gitweb/fpga/rpi-motor-control.git/blobdiff_plain/48407cad35d152771ac1a86652dae3eede6741a2..8f3fb13ef9c8da9ac312b3b3b0ea4239306b986f:/pmsm-control/test_sw/logs.c diff --git a/pmsm-control/test_sw/logs.c b/pmsm-control/test_sw/logs.c new file mode 100644 index 0000000..f6c2a5f --- /dev/null +++ b/pmsm-control/test_sw/logs.c @@ -0,0 +1,91 @@ + +#include +#include + +#include "logs.h" +#include "pmsm_state.h" +#include "rp_spi.h" + +/* + * \brief + * Free logs memory. + */ +void freeLogs(struct rpi_state* this){ + int r; + if (this->log_col_count){ + for (r=0;rlogs[r]); + } + } + this->log_col_count=0; + this->doLogs=0; +} + +/* + * \brief + * Makes log. + */ +void makeLog(struct rpi_state* this){ + int r; + if (this->log_col==MAX_LOGS-1){ + this->doLogs=0; + return; + } + this->logs[0][this->log_col]=(int)this->tf_count; + this->logs[1][this->log_col]=(int)this->spi_dat->pozice; + + this->logs[2][this->log_col]=(int)this->pwm1; + this->logs[3][this->log_col]=(int)this->pwm2; + this->logs[4][this->log_col]=(int)this->pwm3; + this->logs[5][this->log_col]=this->duty; + + this->logs[6][this->log_col]=this->desired_spd; + this->logs[7][this->log_col]=this->speed; + + this->logs[8][this->log_col]=(int)(this->spi_dat->ch1/this->spi_dat->adc_m_count); + this->logs[9][this->log_col]=(int)(this->spi_dat->ch2/this->spi_dat->adc_m_count); + this->logs[10][this->log_col]=(int)(this->spi_dat->ch0/this->spi_dat->adc_m_count); + + this->log_col++; + /* + if (rps.log_col==rps.log_col_count-1){ + rps.log_col_count*=2; + rps.log_col_count%=MAX_LOGS; + for (r=0;rlog_col-1;s++){ /*posledni sloupec je vevyplneny*/ + if (s==this->log_col-2){ + fprintf(f,"%d ",this->logs[r][s]); + }else{ + fprintf(f,"%d, ",this->logs[r][s]); + } + } + fprintf(f,"\r"); + } + fclose(f); + freeLogs(this); +}