]> rtime.felk.cvut.cz Git - fpga/rpi-motor-control.git/blobdiff - pmsm-control/test_sw/pmsm_state.c
Correct typo in rpi-mc-1 mapping to Ti AM437x based RICO board.
[fpga/rpi-motor-control.git] / pmsm-control / test_sw / pmsm_state.c
index 972149047da598c47fcf58ee2cafca7458667f0b..acfd34732e4b967d40d3940fdad5615d2a447f29 100644 (file)
@@ -1,10 +1,11 @@
 #include "pmsm_state.h"
 #include "commutators.h"
+#include "controllers.h"
 
 /**
  * Index Lost.
  */
-void setIndexLost(struct rpi_state* this){
+inline void setIndexLost(struct rpi_state* this){
        this->index_ok=0;
        this->main_commutator=simple_hall_commutator;
 }
@@ -12,7 +13,7 @@ void setIndexLost(struct rpi_state* this){
 /**
  * Index OK.
  */
-void setIndexOK(struct rpi_state* this){
+inline void setIndexOK(struct rpi_state* this){
        this->index_ok=1;
        this->main_commutator=inv_trans_comm_2;
 }
@@ -20,7 +21,7 @@ void setIndexOK(struct rpi_state* this){
 /**
  * Turn commutation on.
  */
-void setCommutationOn(struct rpi_state* this){
+inline void setCommutationOn(struct rpi_state* this){
        this->commutate=1;
        if (this->index_ok){
                this->main_commutator=inv_trans_comm_2;
@@ -32,7 +33,36 @@ void setCommutationOn(struct rpi_state* this){
 /**
  * Turn commutation off.
  */
-void setCommutationOff(struct rpi_state* this){
+inline void setCommutationOff(struct rpi_state* this){
        this->commutate=0;
        this->main_commutator=zero_commutator;
 }
+
+/**
+ * Turn on speed regulation.
+ */
+inline void setRegulationSpeed(struct rpi_state* this){
+       this->spd_reg_ena=1;
+       this->pos_reg_ena=0;
+       this->main_controller=spd_pid;
+}
+
+/**
+ * \brief Turn on position regulation
+ */
+inline void setRegulationPos(struct rpi_state* this){
+       this->spd_reg_ena=0;
+       this->pos_reg_ena=1;
+       this->main_controller=pos_pid;
+}
+
+/**
+ * \brief Turn off regulation.
+ */
+inline void setRegulationOff(struct rpi_state* this){
+       this->spd_reg_ena=0;
+       this->pos_reg_ena=0;
+       this->main_controller=zero_controller;
+
+
+}