Advertisement
jakubs11

Untitled

Nov 4th, 2013
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 KB | None | 0 0
  1. //----------------------------//adresy elementow systemowych
  2. #define  SW0 0x00000001
  3. //----------------------------//biblioteki
  4. #include <stdio.h>
  5. #include <io.h>
  6. #include <system.h>
  7. #include "altera_up_avalon_parallel_port.h"
  8. #include "altera_up_avalon_character_lcd.h"
  9. #include "sys/alt_irq.h"
  10. #include "alt_types.h"
  11.  
  12. #include "sys/alt_timestamp.h"
  13. #include "sys/alt_alarm.h"
  14.  
  15. int swstate;
  16. int flaga_alarm;
  17. int i=0;
  18. alt_alarm alarm;
  19. alt_u32 alarm_proc(void *context){
  20.     i=i+1;
  21.     printf("\n ALARM %d", i);
  22.     //alt_alarm_stop(&alarm);
  23.     return 0;
  24. }
  25.  
  26. int main(){
  27.     flaga_alarm=1;
  28.     swstate = IORD(PARALLEL_PORT_0_BASE, 0);
  29.     while(1){
  30.         switch(swstate&SW0){
  31.             case 0:
  32.                 if(flaga_alarm==0){
  33.                     flaga_alarm=1;
  34.                     alt_alarm_start(&alarm,3*alt_ticks_per_second(),alarm_proc,NULL);
  35.                     printf("\n po alarmie");
  36.                 }
  37.  
  38.                 //printf(" 0 ");
  39.                 break;
  40.             case 1:
  41.                 //alt_alarm_stop(&alarm);
  42.                 flaga_alarm=0;
  43.                 printf(" 1 ");
  44.                 break;
  45.         }
  46.     }
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement