Commit 605e8ed3 by vielex

Final version

parent 3ca637f2
Showing with 5 additions and 4 deletions
......@@ -90,7 +90,8 @@ int main(void){ unsigned long i,last,now;
last = NVIC_ST_CURRENT_R;
EnableInterrupts(); // enable interrupts for the grader
while(1){
if(!(GPIO_PORTF_DATA_R&0x01) || !(GPIO_PORTF_DATA_R&0x10)){ // PF0 or PF4
//either PF4 or PF0 is 0
if(!(GPIO_PORTF_DATA_R&0x01) || !(GPIO_PORTF_DATA_R&0x10)){
Led = GPIO_PORTF_DATA_R; // read previous
Led = Led^0x02; // toggle red LED
GPIO_PORTF_DATA_R = Led; // output
......@@ -100,11 +101,11 @@ int main(void){ unsigned long i,last,now;
//disable LED if nothing is pressed
GPIO_PORTF_DATA_R &=~0x02;
}
if(i<50){
if(i<50 && changed){
changed = false;
now = NVIC_ST_CURRENT_R;
Time[i] = (last-now)&0x00FFFFFF; // 24-bit time difference
Data[i] = GPIO_PORTF_DATA_R&0x02; // record PF1
Data[i] = GPIO_PORTF_DATA_R&0x13; // record PF4,1,0
last = now;
i++;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment