Renamed variables.
authorMartin Prudek <prudemar@fel.cvut.cz>
Sun, 10 May 2015 10:46:18 +0000 (12:46 +0200)
committerMartin Prudek <prudemar@fel.cvut.cz>
Sun, 10 May 2015 10:46:18 +0000 (12:46 +0200)
pmsm-control/test_sw/main_pmsm.c

index f666358..12f236d 100644 (file)
@@ -409,31 +409,36 @@ inline void simple_hall_commutator(int duty){
  *             signalu indexu
  */
 void comIndDist(){
-       uint16_t pos_12 = 0x0FFF & data.pozice_raw;
-       if (data.index_position<2048){
-               if (pos_12<data.index_position){
+       uint16_t pos = 0x0FFF & data.pozice_raw;
+       uint16_t dist;
+       uint16_t index = data.index_position;
+
+       if (index<2048){
+               if (pos<index){
                        /*proti smeru h.r. od indexu*/
-                       rps.index_dist=pos_12+2000-data.index_position;
-               }else if (pos_12<=data.index_position+2048){
+                       dist=pos+2000-index;
+               }else if (pos<=index+2048){
                        /*po smeru h.r. od indexu*/
-                       rps.index_dist=pos_12-data.index_position;
+                       dist=pos-index;
                }else{
                        /*proti smeru h.r. od indexu - podtecena pozice*/
-                       rps.index_dist=pos_12-data.index_position-2096;
+                       dist=pos-index-2096;
                }
        }else{
-               if (pos_12<data.index_position-2048){
+               if (pos<index-2048){
                        /*po smeru h.r. od indexu - pretecena pozice*/
-                       rps.index_dist=4096+pos_12-data.index_position;
-               }else if (pos_12<data.index_position){
+                       dist=4096+pos-index;
+               }else if (pos<index){
                        /*proti smeru h.r. od indexu*/
-                       rps.index_dist=pos_12+2000-data.index_position;
+                       dist=pos+2000-index;
                }else{
                        /*po smeru h.r. od indexu*/
-                       rps.index_dist=pos_12-data.index_position;
+                       dist=pos-index;
                }
 
        }
+       rps.index_dist = dist;
+       return;
 }
 /*
  * \brief