]> rtime.felk.cvut.cz Git - fpga/rpi-motor-control.git/blob - pmsm-control/test_sw/misc.c
Current measurment bits transferring via SPI from FPGA to RPi extended from 12 to...
[fpga/rpi-motor-control.git] / pmsm-control / test_sw / misc.c
1 /**
2  * \brief Implementace pomocnych funkci.
3  * \file misc.c
4  * \date Feb 1, 2015
5  * \author Martin Prudek
6  *
7  *      Implementace pomocnych funkci.
8  *      Vetsinou pro komunikaci mezi vlakny, jejich sychronizaci a predavani priorit.
9  */
10
11 #include "misc.h"
12 #include <sched.h>
13
14 /**
15  * nastavi prioritu a scheduler podle parametru
16  * funkce na konci vrati semafor, aby mohlo dojit k opetovne zmene parametru
17  * \param pointer na struct thread_sched_param
18  */
19 void set_priority(void * param){
20         struct sched_param sp;
21         struct thread_param *tp = ((struct thread_param*) param);
22
23         sp.sched_priority = tp->sch_prior; /*vysoka priorita*/
24         if(sched_setscheduler(0, tp->sch_policy, &sp) == -1) {
25                 perror("pid sched_setscheduler failed");
26         }
27         sem_post(&thd_par_sem);
28 }