static void printHelp(){
doPrint=0;
puts("start - Pripravi rizeni, zapne enable bity pwm.");
- puts("stop - Vypne pwm a rizeni. Enable bity na nulu.");
- puts("0 - Vypne pwm a rizeni. Enable bity na nulu.");
+ puts("stop - Vypne komutaci, pwm a rizeni.");
+ puts("0 - Vypne komutaci, pwm a rizeni.");
puts("ga:[hodnota] - Zapne rizeni na zvolenou absolutni pozici.");
puts("print - Zapne nebo vypne pravidelne vypisovani hodnot.");
+ puts("duty:[hodnota] - Nastavi pevnou sirku plneni.");
+
puts("help - Vypne vypisovani hodnot a zobrazi tuto napovedu.");
puts("exit - Bezpecne ukonci program.");
}
static void start(struct rpi_state* state){
sem_wait(&state->thd_par_sem);
state->test=0x70; /*konfiguracni byte*/
- state->commutate=1;
sem_post(&state->thd_par_sem);
}
*/
static void stop(struct rpi_state* state){
sem_wait(&state->thd_par_sem);
- state->test=0; /*konfiguracni byte*/
state->commutate=0;
state->pwm1=0;
state->pwm2=0;
* Nastavi pevnou sirku plneni
*/
static void dutySet(struct rpi_state* state, int duty){
-
+ sem_wait(&state->thd_par_sem);
+ if (duty>512) duty=512;
+ if (duty<-512) duty=-512;/*paranoia*/
+ state->duty=duty;
+ state->commutate=1;
+ state->pos_reg_ena=0;
+ sem_post(&state->thd_par_sem);
}
/*
*/
static void goAbsolute(struct rpi_state* state, int pos){
sem_wait(&state->thd_par_sem);
+ state->pos_reg_ena=1;
+ state->commutate=1;
state->desired_pos=pos;
sem_post(&state->thd_par_sem);
}
printf("%.2X ", data_p.debug_rx[i]);
}
puts("");
- printf("\npozice=%d\n",(int32_t)data_p.pozice);
+ printf("\npozice=%ld\n",data_p.pozice);
+ printf("rychlost=%d\n",s.speed);
printf("chtena pozice=%d\n",s.desired_pos);
printf("transfer count=%u\n",s.tf_count);
printf("raw_pozice=%u\n",data_p.pozice_raw);