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
1 #include "pmsm_state.h"
2 #include "commutators.h"
3 #include "controllers.h"
4
5 /**
6  * Index Lost.
7  */
8 inline void setIndexLost(struct rpi_state* this){
9         this->index_ok=0;
10         this->main_commutator=simple_hall_commutator;
11 }
12
13 /**
14  * Index OK.
15  */
16 inline void setIndexOK(struct rpi_state* this){
17         this->index_ok=1;
18         this->main_commutator=inv_trans_comm_2;
19 }
20
21 /**
22  * Turn commutation on.
23  */
24 inline void setCommutationOn(struct rpi_state* this){
25         this->commutate=1;
26         if (this->index_ok){
27                 this->main_commutator=inv_trans_comm_2;
28         }else{
29                 this->main_commutator=simple_hall_commutator;
30         }
31 }
32
33 /**
34  * Turn commutation off.
35  */
36 inline void setCommutationOff(struct rpi_state* this){
37         this->commutate=0;
38         this->main_commutator=zero_commutator;
39 }
40
41 /**
42  * Turn on speed regulation.
43  */
44 inline void setRegulationSpeed(struct rpi_state* this){
45         this->spd_reg_ena=1;
46         this->pos_reg_ena=0;
47         this->main_controller=spd_pid;
48 }
49
50 /**
51  * \brief Turn on position regulation
52  */
53 inline void setRegulationPos(struct rpi_state* this){
54         this->spd_reg_ena=0;
55         this->pos_reg_ena=1;
56         this->main_controller=pos_pid;
57 }
58
59 /**
60  * \brief Turn off regulation.
61  */
62 inline void setRegulationOff(struct rpi_state* this){
63         this->spd_reg_ena=0;
64         this->pos_reg_ena=0;
65         this->main_controller=zero_controller;
66
67
68 }