-
Notifications
You must be signed in to change notification settings - Fork 0
/
mipslabmain.c
84 lines (71 loc) · 2.59 KB
/
mipslabmain.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* mipslabmain.c
This file written 2015 by Axel Isaksson,
modified 2015 by F Lundevall
Latest update 2015-08-28 by F Lundevall
For copyright and licensing, see file COPYING */
#include <stdint.h> /* Declarations of uint_32 and the like */
#include <pic32mx.h> /* Declarations of system-specific addresses etc */
#include "mipslab.h" /* Declatations for these labs */
volatile int disco[8][32] ={
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,1,1,1,0,0,1,0,1,1,1,1,0,1,1,1,0,1,1,1,1,0,0,0,0,0,0,0},
{0,0,0,0,0,1,0,0,1,0,1,0,1,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0},{0,0,0,0,0,1,0,0,1,0,1,0,1,1,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0},{0,0,0,0,0,1,0,0,1,0,1,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0},{0,0,0,0,0,1,0,0,1,0,1,0,0,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0},{0,0,0,0,0,1,1,1,0,0,1,0,1,1,1,1,0,1,1,1,0,1,1,1,1,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
};
volatile int tetris[8][32] ={
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,0,1,1,1,0,1,0,1,1,1,1,0,0,0,0},
{0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0,0,0},{0,0,0,0,1,0,0,0,1,1,0,0,0,0,1,0,0,0,1,1,1,0,1,0,1,1,1,1,0,0,0,0},{0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,1,0,0,1,0,0,0,0,1,0,0,0,0},{0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,0,1,0,0,0,0},{0,0,0,0,1,0,0,0,1,1,1,0,0,0,1,0,0,0,1,0,1,0,1,0,1,1,1,1,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
};
int main(void) {
/* Set up peripheral bus clock */
/* OSCCONbits.PBDIV = 1; */
OSCCONCLR = 0x100000; /* clear PBDIV bit 1 */
OSCCONSET = 0x080000; /* set PBDIV bit 0 */
/* Set up output pins */
AD1PCFG = 0xFFFF;
ODCE = 0x0;
TRISECLR = 0xFF;
PORTE = 0x0;
/* Output pins for display signals */
PORTF = 0xFFFF;
PORTG = (1 << 9);
ODCF = 0x0;
ODCG = 0x0;
TRISFCLR = 0x70;
TRISGCLR = 0x200;
/* Set up input pins */
TRISDSET = (1 << 8);
TRISFSET = (1 << 1);
/* Set up SPI as master */
SPI2CON = 0;
SPI2BRG = 4;
/* SPI2STAT bit SPIROV = 0; */
SPI2STATCLR = 0x40;
/* SPI2CON bit CKP = 1; */
SPI2CONSET = 0x40;
/* SPI2CON bit MSTEN = 1; */
SPI2CONSET = 0x20;
/* SPI2CON bit ON = 1; */
SPI2CONSET = 0x8000;
int i,c,k;
display_init();
display_update();
for(i = 0;i<3;i++){
display_frommatrix(disco);
for(c = 0;c<1000;c++){
quicksleep(10000);
}
display_frommatrixinv(tetris);
for(k = 0;k<1000;k++){
quicksleep(10000);
}
}
labinit(); /* Do any lab-specific initialization */
while(1)
{
labwork(); /* Do lab-specific things again and again */
}
return 0;
}