Project

General

Profile

Revision 5

Code corrected

View differences:

lab2.c
52 52

  
53 53
int(timer_test_time_base)(uint8_t timer, uint32_t freq) {
54 54

  
55
  if(timer_set_frequency(timer, freq)==1){                      //tests for error
55
  if(timer<0|timer>2){                                  //tests for error in timer selection
56
    printf("Error selecting timer\n");
57
    return 1;
58
  }
59
  if(timer_set_frequency(timer, freq)==1){              //tests for error
56 60
    printf("Error testing time base\n");
57 61
    return 1;
58 62
  }
......
64 68
  uint8_t irq_set;
65 69
  message msg;
66 70

  
71
  if(timer_set_frequency(0, 60)==1){                    //tests for error
72
    printf("Error setting frequency\n");
73
    return 1;
74
  }
75

  
67 76
  if(timer_subscribe_int(&irq_set)==1){
68 77
    printf("Error subscribing int\n");
69 78
    return 1;
70 79
  }
71 80

  
72
  while(count/60.0<time){                                     //looping until counter reaches the same value as time
73
    if ((r = driver_receive(ANY, &msg, &ipc_status))!=0){ 
81
  while(count/sys_hz()<time){                                     //looping until counter reaches the same value as time
82
    if ((r = driver_receive(ANY, &msg, &ipc_status))==1){ 
74 83
      printf("driver_receive failed with: %d",r);
75 84
      continue;
76 85
    }
......
81 90
                  
82 91
                  timer_int_handler();
83 92

  
84
                  if((count%60)==0){
93
                  if((count%sys_hz())==0){
85 94
                    timer_print_elapsed_time();                 //prints message each second;
86 95
                  }
87 96
                }
......
91 100
        }
92 101
    } 
93 102
    else {                                                      //received a standard message, not a notification
94
                                                                //no standard messages expected: do nothing
103
      //no standard messages expected: do nothing
95 104
    }
96 105
  }
97 106
  

Also available in: Unified diff