/* function to callibrate busysleep function */ void calibrate_busysleep(void) { RTIME sleeptime_ns; RTIME x; volatile RTIME loop_size=CALIBRATION_LOOP_SIZE; // loop with global CALIBRATION_LOOP_SIZE sleeptime_ns=loop(loop_size); rt_printk( sleeptime_ns=%lld\n ,sleeptime_ns); // // sleeptime_in_us = sleeptime_ns/1000 // count_need_for_one_us_busysleep=calibration_loop_size/sleeptime_in_us; // -> somma fattore di calibrazione : // sleeptime_in_us -> sleeptime_in_us * calibrationpercentage/100 // -> in definitiva // counterbusysleepns= calibration_loop_size*10*calibrationpercentage/sleeptime_ns x=CALIBRATION_LOOP_SIZE*10*CALIBRATION_PERCENTAGE*1000; do_div(x,sleeptime_ns); // fattore di calibrazione ttale count_need_for_one_ms_busysleep=x; }