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; }
void displayInit(){ OLED_COMMAND; quicksleep(10); OLED_VBAT_DISABLE; OLED_VDD_ENABLE; quicksleep(1000000); OLED_send(0xAE); OLED_RESET_ENABLE; quicksleep(10); OLED_RESET_DISABLE; quicksleep(10); OLED_send(0x8D); OLED_send(0x14); OLED_send(0xD9); OLED_send(0xF1); OLED_send(0xA7); OLED_VBAT_ENABLE; quicksleep(10000000); OLED_send(0xA0); OLED_send(0xC8); OLED_send(0xDA); OLED_send(0x20); OLED_send(0xAF); OLED_send(0xA4); OLED_send(0x20); OLED_send(0x1); OLED_send(0x21); OLED_send(0x0); OLED_send(127); OLED_send(0x22); OLED_send(0x0); OLED_send(3); OLED_DATA; int i; // for(i = 0; i < (4*128);i++) OLED_send(0x00); }