]> rtime.felk.cvut.cz Git - fpga/rpi-motor-control.git/blobdiff - pmsm-control/test_sw/pmsm_state.c
Commutation function now implemented with use of polymorphism.
[fpga/rpi-motor-control.git] / pmsm-control / test_sw / pmsm_state.c
diff --git a/pmsm-control/test_sw/pmsm_state.c b/pmsm-control/test_sw/pmsm_state.c
new file mode 100644 (file)
index 0000000..9721490
--- /dev/null
@@ -0,0 +1,38 @@
+#include "pmsm_state.h"
+#include "commutators.h"
+
+/**
+ * Index Lost.
+ */
+void setIndexLost(struct rpi_state* this){
+       this->index_ok=0;
+       this->main_commutator=simple_hall_commutator;
+}
+
+/**
+ * Index OK.
+ */
+void setIndexOK(struct rpi_state* this){
+       this->index_ok=1;
+       this->main_commutator=inv_trans_comm_2;
+}
+
+/**
+ * Turn commutation on.
+ */
+void setCommutationOn(struct rpi_state* this){
+       this->commutate=1;
+       if (this->index_ok){
+               this->main_commutator=inv_trans_comm_2;
+       }else{
+               this->main_commutator=simple_hall_commutator;
+       }
+}
+
+/**
+ * Turn commutation off.
+ */
+void setCommutationOff(struct rpi_state* this){
+       this->commutate=0;
+       this->main_commutator=zero_commutator;
+}