Commit 9114076126b5ba4eb2faabb7fa5461ad689b76e4

Authored by dmakow
1 parent 4fdf0b0a

Final version for sw lab

Showing 1 changed file with 9 additions and 76 deletions
virtual_lab/main.c
1 1 #include <stdint.h>
2 2 #include <stdbool.h>
3 3  
4   -#define PB_PER (*((volatile uint32_t*)0xFFFFF400))
5   -#define PB_OER (*((volatile uint32_t*)0xFFFFF410))
6   -#define PB_SODR (*((volatile uint32_t*)0xFFFFF430))
7   -#define PB_CODR (*((volatile uint32_t*)0xFFFFF434))
8   -#define PB_PDSR (*((volatile uint32_t*)0xFFFFF43C))
9   -
10   -#define PC_PER (*((volatile uint32_t*)0xFFFFF600))
11   -#define PC_ODR (*((volatile uint32_t*)0xFFFFF614))
12   -#define PC_OER (*((volatile uint32_t*)0xFFFFF610))
13   -#define PC_SODR (*((volatile uint32_t*)0xFFFFF630))
14   -#define PC_CODR (*((volatile uint32_t*)0xFFFFF634))
15   -#define PC_PDSR (*((volatile uint32_t*)0xFFFFF63C))
16   -#define PC_PUER (*((volatile uint32_t*)0xFFFFF664))
17   -
18   -#define PMC_PCER (*((volatile uint32_t*)0xFFFFFC10))
19   -
20   -#define CLK_PIO_CDE 4
21   -
22   -#define DS1 (1 << 8) //PB8
23   -#define DS2 (1 << 29) //PC29
24   -
25   -#define BT2 (1 << 4) //PC4
26   -#define BT1 (1 << 5) //PC5
  4 +{
  5 +// add registers here
  6 +}
27 7  
28 8 void delay_ms (int delay)
29 9 {
30   - volatile uint64_t DelayStep;
31   - for(DelayStep = 0; DelayStep < 100000*delay; DelayStep++);
  10 +// add code here
32 11 }
33 12  
34 13 void ConfigureLEDs (void)
35 14 {
36   - PB_PER = DS1;
37   - PC_PER = DS2;
38   - PB_OER = DS1;
39   - PC_OER = DS2;
40   - PB_SODR = DS1;
41   - PC_SODR = DS2;
  15 +// add code here
42 16 }
43 17  
44   -
45 18 void ConfigureButtons (void)
46 19 {
47   - PMC_PCER = 1 << CLK_PIO_CDE;
48   - PC_PER = BT1 | BT2;
49   - PC_ODR = BT1 | BT2;
50   - PC_PUER = BT1 | BT2;
  20 +// add code here
51 21 }
52 22  
53   -int main(void)
54   -{
55   - int Decimator=0;
56   - ConfigureLEDs();
57   - ConfigureButtons();
58   -#if 0
59   - PMC_PCER = 1 << PER_ID_PBIOC_TO_PIOE;
60   - PB_PER = DS1; //PIO enable register
61   -// PB_PDR = 0xffffffff; //PIO disable register
62   -
63   - PB_OER = DS1; //PIO controller output enable register
64   - PC_PER = DS2 | BT1 | BT2; //PIO enable register
65   - PC_OER = DS2; //PIO controller output enable register
66   - PC_ODR = BT1 | BT2;
67   - PC_PUER = BT1 | BT2;
68   -#endif
69   -
70   - while(true)
71   - {
72   - for (Decimator=0; Decimator<100; Decimator++)
73   - {
74   - if((PC_PDSR & BT1) == 0)
75   - PB_SODR = DS1;
76 23  
77   - if((PC_PDSR & BT2) == 0)
78   - PB_CODR = DS1;
79   - delay_ms(10);
80   - }
81   -
82   - PC_CODR = DS2;
83 24  
84   - for (Decimator=0; Decimator<100; Decimator++)
85   - {
86   - if((PC_PDSR & BT1) == 0)
87   - PB_SODR = DS1;
88   -
89   - if((PC_PDSR & BT2) == 0)
90   - PB_CODR = DS1;
91   - delay_ms(10);
92   - }
  25 +int main(void)
  26 +{
  27 +// add code here
93 28  
94   - PC_SODR = DS2;
95   - }
96 29 }
... ...