/* INTERRUPT VECTORS: * 0: OS Timer Tick * 1: Not Used * 2: UART0 Interrupt * 3: UART1 Interrupt * 4: I2C0 Interrupt * 5-16: Not Used */ int main(void) { OSHANDLES SysHandles; // Should contain all OS Handles cpuSetupHardware(); // Setup PLL, enable MAM etc. watchdogDelayUs(1000 * 1000); // Some startup delay uart0Init(38400, 128); // 128 is size of UART0 Rx/Tx FIFO uart1Init(38400, 128); // 128 is size of UART1 Rx/Tx FIFO // Use polling version of uart0 to do printf/rprintf before starting FreeRTOS rprintf_devopen(uart0PutCharPolling); cpuPrintMemoryInfo(); // Open interrupt-driven version of UART0 Rx/Tx rprintf_devopen(uart0PutChar); watchdogDelayUs(1000 * 1000); /** Create timer needed for SD Card I/O */ Timer diskTimer(FatFsDiskTimer, 10, TimerPeriodic); diskTimer.start(); /** Create any Queues and Mutexes **/ SysHandles.lock.SPI = xSemaphoreCreateMutex(); // TODO 2. Create the "song name" Queue here SysHandles.queue.songname = xQueueCreate(1,16); //length, item size // Use the WATERMARK command to determine optimal Stack size of each task (set to high, then slowly decrease) // Priorities should be set according to response required if (pdPASS != xTaskCreate( uartUI, (signed char*)"Uart UI", STACK_BYTES(1024*6), &SysHandles, PRIORITY_HIGH, &SysHandles.task.userInterface ) || pdPASS!= xTaskCreate( mp3Task, (signed char*)"MP3", STACK_BYTES(1024*6), &SysHandles, PRIORITY_HIGH, &SysHandles.task.mp3 ) || pdPASS!= xTaskCreate( sd_card_detect, (signed char*)"sd_card_detect", STACK_BYTES(1024), &SysHandles, PRIORITY_LOW, &SysHandles.task.sd_card_detect ) || pdPASS!= xTaskCreate( mp3_controls, (signed char*)"mp3_controls", STACK_BYTES(1024*6), &SysHandles, PRIORITY_LOW, &SysHandles.task.mp3_controls )) { rprintf( "ERROR: OUT OF MEMORY: Check OS Stack Size or task stack size.\n"); } // Start FreeRTOS to begin servicing tasks created above, vTaskStartScheduler() will not "return" rprintf("\n-- Starting FreeRTOS --\n"); vTaskStartScheduler(); // In case OS is exited: rprintf_devopen(uart0PutCharPolling); rprintf("ERROR: Unexpected OS Exit!\n"); return 0; }
int main(void) { lowLevelInit(); wakeupInit(); exceptionHandlerInit(); int i = 0; init_Uart0(9600); init_Uart1(9600); int buff = 0; rprintf_devopen(uart0_putchar); //rprintf_devopen(uart1_putchar); delay_ms(2000); rprintf("-------------------------------------------------------------------------\n"); rprintf("-- System Boot complete... --\n"); rprintf("-------------------------------------------------------------------------\n"); printf("You can use printf but it will bloat your code!!!\n"); //printf("Only STDIO printf can print floating-point numbers: %f\n", 1.23f); delay_ms(1000); printf("Test Memory allocation of 1024 bytes: "); char *memPointer = malloc(1024); printf("Memory pointer = %p\n", memPointer); uart1_putchar('*'); while (1) { rprintf("-- Hello World %i --\n", ++i); uart1_putchar('*'); delay_ms(1000); //buff = uart1_getchar(); //uart1_putchar(buff); } return 0; }
void boot_up(void) { //Initialize the MCU clock PLL system_init(); IODIR0 |= (1 << 31); IOCLR0 |= (1 << 31); //Turn on USB LED //Init UART0 for debug PINSEL0 |= 0x00000005; //enable uart0 U0LCR = 0x83; // 8 bits, no Parity, 1 Stop bit, DLAB = 1 U0DLM = 0x00; U0DLL = 0x20; // 115200 Baud Rate @ 58982400 VPB Clock U0LCR = 0x03; // DLAB = 0 //Init rprintf rprintf_devopen(putc_serial0); rprintf("\n\n\nUSB Bootloader v1.1\n"); //IOSET0 |= (1 << 31); //Turn off USB LED }
int main (void) { char x, y, a; ioinit(); //Setup IO pins and defaults USART_Init( MYUBRR); rprintf_devopen(put_char); /* init rrprintf */ //reset the display delay_ms(1); PORTC |= (1<<RST); //initialize the display display_init(); clear_screen(); //Backlight on PORTB &= (~(1<<BL_EN)); while(1) { if(RX_in != RX_read) { x = RX_array[RX_read]; RX_read++; if(RX_read >= 256) RX_read = 0; //Backspace=================================================== if(x == 8) del_char(0); //Special commands else if (x == 124) { //make sure the next byte is there while(RX_in == RX_read); //0, clear screen====================================================== if(RX_array[RX_read] == 0) { clear_screen(); RX_read++; if(RX_read >= 256) RX_read = 0; } //Backlight on/off else if(RX_array[RX_read] == 2) { y = PINB; if (y & (1<<BL_EN)) PORTB &= (~(1<<BL_EN)); else PORTB |= (1<<BL_EN); RX_read++; } //demo mode else if(RX_array[RX_read] == 4) { RX_in = 0, RX_read = 0; demo(); clear_screen(); RX_in = 0; } else { //set x or y========================================================= if((RX_array[RX_read] == 24) | (RX_array[RX_read] == 25)) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte if (RX_array[RX_read-1] == 24) x_offset = RX_array[RX_read]; else if (RX_array[RX_read-1] == 25) y_offset = RX_array[RX_read]; RX_read++; if(RX_read >= 256) RX_read = 0; if (x_offset > 159) x_offset = 159; if (y_offset > 127) y_offset = 127; } //set pixel========================================================= if (RX_array[RX_read] == 16) { //need 3 bytes for (y = 0; y < 3; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } pixel(RX_array[RX_read], RX_array[RX_read-2], RX_array[RX_read-1]); RX_read++; if(RX_read >= 256) RX_read = 0; } //<ctrl>c, circle====================================================== if(RX_array[RX_read] == 3) { //need 4 bytes for (y = 0; y < 4; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } circle(RX_array[RX_read], RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read-1]); RX_read++; if(RX_read >= 256) RX_read = 0; } //<ctrl>e, erase block====================================================== if(RX_array[RX_read] == 5) { //need 4 bytes for (y = 0; y < 4; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } erase_block(RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read-1], RX_array[RX_read]); RX_read++; if(RX_read >= 256) RX_read = 0; } //<ctrl>o, box, running out of meaningful letters====================================================== if(RX_array[RX_read] == 15) { //need 4 bytes for (y = 0; y < 4; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } box(RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read-1], RX_array[RX_read]); RX_read++; if(RX_read >= 256) RX_read = 0; } //<ctrl>L, line======================================================== else if (RX_array[RX_read] == 12) { //need 5 bytes for (y = 0; y < 5; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } line(RX_array[RX_read], RX_array[RX_read-4], RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read+-1]); RX_read++; if(RX_read >= 256) RX_read = 0; } } } //print character to the screen=============================================== else { del_char(1); print_char(1, x); } } } }
// intialization functions void bootARM(void) { // had to steal some code from the original SparkFun code because I don't // understand it yet. rprintf_devopen(putc_serial0); // Init rprintf delay_ms(30); // wait for power to stabilize // bring up SD / FAT * if (! (sd_raw_init()) ) { rprintf("SD init error!\n"); } if ( openroot() ) { rprintf("openroot error!\n"); } // set up I/O pins * //Setup the MP3 I/O Lines IODIR0 |= MP3_XCS; IODIR0 &= ~MP3_DREQ; PINSEL1 |= 0x00000C00; // Set the MP3_DREQ Pin to be a capture pin IODIR1 |= MP3_XDCS | MP3_GPIO0 | MP3_XRES; //Setupt the FM Trans. Lines IODIR1 |= FM_LA; // FM trans outputs (Leave SPI pins IODIR1 |= FM_CS; // unconfigured for now) //Setup the SD Card I/O Lines IODIR0 |= SD_CS; // SD card outputs //Setup the Accelerometer I/O Lines IODIR0 |= (GS1 | GS2); // accelerometer outputs // ensure ADC pins have ADC Functions selected PINSEL0 |= (MMA_X_PINSEL | MMA_Y_PINSEL | MMA_Z_PINSEL); IOCLR0 = (GS1 | GS2); // initialize acceleration to 1.5 G mode //Setup the LCD I/O Lines IODIR0 |= (LCD_RES | LCD_CS); // LCD Outputs //Setup the LED Lines IODIR0 |= (LED_BLU | LED_RED | LED_GRN); ledBlueOff(); ledRedOff(); ledGrnOff(); //Setup the Buttons IODIR1 &= (~SW_UP & ~SW_DWN & ~SW_MID); //Button Inputs IODIR0 &= ~(1<<23); //Set the Vbus line as an input //Setupt the Interrupts VPBDIV = 1; // Set PCLK equal to the system clock VICIntSelect = ~0x30; // Timer 0 AND TIMER 1 interrupt is an IRQ interrupt VICIntEnable = 0x10; // Enable Timer 0 interrupts // (don't start sending song data with Timer 1) VICVectCntl0= 0x25; // Use slot 0 for timer 1 interrupt VICVectAddr0 = (unsigned int)timer1ISR; // Set the address of ISR for slot 1 VICVectCntl1 = 0x24; // Use slot 1 for timer 0 interrupt VICVectAddr1 = (unsigned int)timer0ISR; // Set the address of ISR for slot 1 //Configure Timer0 T0PR = 1500; // divide clock(60MHz) by 1500 for 40kHz PS T0TCR |=0X01; // enable the clock T0CTCR=0; // timer node T0MCR=0x0003; // interrupt and reset timer on match T0MR0=1000; // interrupt on 40Hz //Configure Timer1 T1PR = 200; // divide clock by 300 for 40kHz PS T1TCR |=0X01; // enable the clock T1CTCR=0; // timer mode T1CCR=0x0A00; // capture and interrupt on the // rising edge of DREQ //Setup the SPI Port S0SPCCR = 64; // SCK = 1 MHz, counter > 8 and even S0SPCR = 0x20; // Master, no interrupt enable, 8 bits // set up MP3 decoder vs1002Config(); // set up ARM <-> VS1002 communication vs1002Reset(); // hardware reset vs1002Init(); // initialization return; }
int main (void) { char temp; short b; ioinit(); //Setup IO pins and defaults USART_Init(10);//set up for 115200 rprintf_devopen(put_char); /* init rrprintf */ for (b = 0; b < 5; b++) { PORTB &= (~(1<<STAT));//stat on delay_ms(50); PORTB |= (1<<STAT);//stat off delay_ms(50); } asc = 0; auto_run = 0; //check for existing preset values============================================================== temp = EEPROM_read((unsigned int)FREQ_HIGH); if (temp == 255)//unwritten { cli();//Disable Interrupts EEPROM_write((unsigned int) FREQ_LOW, 100);//100Hz EEPROM_write((unsigned int) FREQ_HIGH, 0); EEPROM_write((unsigned int) SENSE_AR_MODE, 0);//1.5g, auto-run off, binary output EEPROM_write((unsigned int) ACT_CHAN, 0x3F);//all channels active sei();//Enable Interrupts freq = 100; asc = 0;//binary auto_run = 0;//auto run off //set for 1.5g sensitivity PORTB &= (~((1<<GS1) | (1<<GS2)));//GS1 low, GS2 low } //get presets else { b = EEPROM_read((unsigned int)FREQ_HIGH); b <<= 8; b |= EEPROM_read((unsigned int)FREQ_LOW); freq = (float)b; active_channels = EEPROM_read((unsigned int)ACT_CHAN); temp = EEPROM_read((unsigned int)SENSE_AR_MODE); if (temp & 0x08) PORTB |= (1<<GS2);//GS2 High if (temp & 0x04) PORTB |= (1<<GS1);//GS2 High if (temp & 0x02) auto_run = 1; if (temp & 0x01) asc = 1; } //main loop================================================================== while(1) { if (auto_run == 1) { while(1) { //This is the sampling loop. It runs in get_adc() until somebody stops it. get_adc(); //If it dumps out of the sampling loop, go to the config menu. config_menu(); //Bail out if auto run is off. if (auto_run == 0) break; } } if (UCSR0A & (1<<RXC0))//if something comes in... { temp = UDR0; if (temp == 35) //# to run { asc = 0; get_adc(); } else if (temp == 37) //% to set range to 1.5g { //set for 1.5g sensitivity PORTB &= (~((1<<GS1) | (1<<GS2)));//GS1 low, GS2 low } else if (temp == 38) //& to set range to 2g { PORTB |= (1<<GS1);//GS1 High PORTB &= (~(1<<GS2));//GS2 low } else if (temp == 39) //' to set range to 4g { PORTB &= (~(1<<GS1));//GS1 low PORTB |= (1<<GS2);//GS2 High } else if (temp == 40) //( to set range to 6g { PORTB |= ((1<<GS1) | (1<<GS2));//GS1, GS2 high } else if (temp == 41) freq = 50; //) to run at 50Hz else if (temp == 42) freq = 100;// to run at 100Hz else if (temp == 43) freq = 150;//+ to run at 150Hz else if (temp == 44) freq = 200;//, to run at 200Hz else if (temp == 45) freq = 250;//- to run at 250Hz else if (temp == 32) // { while(1) { config_menu(); if (auto_run == 0) break; get_adc(); } } temp = 0; } } while(1); }
int main (void) { char x, y, temp, q; ioinit(); //Setup IO pins and defaults //USART_Init( MYUBRR); set_baud(6);//115200 rprintf_devopen(put_char); /* init rrprintf */ //check for existing preset values============================================================== temp = EEPROM_read((unsigned int)BPS); if ((temp < 1) | (temp > 6))//BPS will only be 1-6 { cli();//Disable Interrupts EEPROM_write((unsigned int) BPS, 6); EEPROM_write((unsigned int) BACKLIGHT, 100); EEPROM_write((unsigned int) SPLASH, 1); EEPROM_write((unsigned int) REV, 0); sei();//Enable Interrupts BL_dutycycle = 100; baud_rate = 6; splash_screen = 1; reverse = 0; } else { baud_rate = temp; BL_dutycycle = EEPROM_read((unsigned int)BACKLIGHT); splash_screen = EEPROM_read((unsigned int)SPLASH); reverse = EEPROM_read((unsigned int)REV); } //Reset the display PORTC &= ~(1 << RESET); delay_ms(50); PORTC |= (1 << RESET); //delay_ms(500); clear_screen(); set_page(0); set_x(0); display_on(); //set display start line to 0 //set control lines PORTC &= ~((1 << EN) | (1 << R_W) | (1 << RS));//down set_data(0xC0); //set_data(0xFF); delay(); PORTC |= (1 << EN);//up delay(); PORTC &= ~(1 << EN);//down delay(); PORTC |= ((1 << EN) | (1 << R_W) | (1 << RS));//all high delay(); x_offset = 0; set_page(0); DDRB |= (1<<BL_EN);//set PB2 as output set_backlight(BL_dutycycle); //Logo========================================================== if (splash_screen == 1) { y = 40; for (q = 0; q < 30; q++) { temp = logo[q]; for (x = 56; x < 64; x++) { if (temp & 0x80) pixel(1,x,y); temp <<= 1; } q++; temp = logo[q]; for (x = 64; x < 72; x++) { if (temp & 0x80) pixel(1,x,y); temp <<= 1; } y--; } } pixel(0,0,0);//cheat RX_in = 0; delay_ms(1000); clear_screen(); if (RX_in > 0)//revert to 115200 { print_char(1,'1'); print_char(1,'1'); print_char(1,'5'); print_char(1,'2'); print_char(1,'0'); print_char(1,'0'); baud_rate = 6; set_baud(6);//115200 cli(); EEPROM_write((unsigned int) BPS, 6); sei();//Enable Interrupts } else (set_baud(baud_rate)); delay_ms(1000); clear_screen(); //main loop=================================================== while(1) { if(RX_in != RX_read) { x = RX_array[RX_read]; RX_read++; if(RX_read >= 416) RX_read = 0; //Backspace=================================================== if(x == 8) del_char(0); //Special commands else if (x == 124) { //make sure the next byte is there while(RX_in == RX_read); //0, clear screen====================================================== if(RX_array[RX_read] == 0)//^@ { clear_screen(); RX_read++; if(RX_read >= 416) RX_read = 0; } //demo mode else if(RX_array[RX_read] == 4)//^d { RX_in = 0, RX_read = 0; demo(); clear_screen(); RX_in = 0; } //reverse mode else if(RX_array[RX_read] == 18)//^r { reverse ^= 1; clear_screen(); RX_read++; if(RX_read >= 416) RX_read = 0; cli(); EEPROM_write((unsigned int) REV, reverse); sei(); } //toggle spasl screen else if(RX_array[RX_read] == 19)//^s { splash_screen ^= 1; //clear_screen(); RX_read++; if(RX_read >= 416) RX_read = 0; cli(); EEPROM_write((unsigned int) SPLASH, splash_screen); sei(); } else { //set backlight (0 to 100)========================================================= if(RX_array[RX_read] == 2)//^b { RX_read++; if(RX_read >= 416) RX_read = 0; while(RX_in == RX_read);//wait for byte BL_dutycycle = RX_array[RX_read]; RX_read++; if(RX_read >= 416) RX_read = 0; set_backlight(BL_dutycycle); cli(); EEPROM_write((unsigned int) BACKLIGHT, BL_dutycycle); sei(); } //change baud rate========================================================= if(RX_array[RX_read] == 7)//^g { RX_read++; if(RX_read >= 416) RX_read = 0; while(RX_in == RX_read);//wait for byte //if (RX_array[RX_read] == '1') USART_Init( 1000000/2400-1);//4800 //else if (RX_array[RX_read] == '2') USART_Init( 1000000/4800-1);//9600 //else if (RX_array[RX_read] == '3') USART_Init( 1000000/9600-1);//19200 //else if (RX_array[RX_read] == '4') USART_Init( 1000000/19200-1);//38400 //else if (RX_array[RX_read] == '5') USART_Init( 1000000/28800-1);//57600 //else if (RX_array[RX_read] == '6') USART_Init( 1000000/57600-1);//115200 if ((RX_array[RX_read] > '0') * (RX_array[RX_read] < '7')) baud_rate = (RX_array[RX_read]) - 48; set_baud(baud_rate); cli(); EEPROM_write((unsigned int) BPS, baud_rate); sei(); RX_read++; if(RX_read >= 416) RX_read = 0; } //set x or y========================================================= if((RX_array[RX_read] == 24) | (RX_array[RX_read] == 25))//^x or ^y { RX_read++; if(RX_read >= 416) RX_read = 0; while(RX_in == RX_read);//wait for byte if (RX_array[RX_read-1] == 24) x_offset = RX_array[RX_read]; else if (RX_array[RX_read-1] == 25) y_offset = RX_array[RX_read]; RX_read++; if(RX_read >= 416) RX_read = 0; if (x_offset > 159) x_offset = 159; if (y_offset > 127) y_offset = 127; } //set pixel========================================================= if (RX_array[RX_read] == 16)//^p { //need 3 bytes for (y = 0; y < 3; y++) { RX_read++; if(RX_read >= 416) RX_read = 0; while(RX_in == RX_read);//wait for byte } pixel(RX_array[RX_read], RX_array[RX_read-2], RX_array[RX_read-1]); RX_read++; if(RX_read >= 416) RX_read = 0; } //<ctrl>c, circle====================================================== if(RX_array[RX_read] == 3)//^c { //need 4 bytes for (y = 0; y < 4; y++) { RX_read++; if(RX_read >= 416) RX_read = 0; while(RX_in == RX_read);//wait for byte } circle(RX_array[RX_read], RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read-1]); RX_read++; if(RX_read >= 416) RX_read = 0; } //<ctrl>e, erase block====================================================== if(RX_array[RX_read] == 5)//^e { //need 4 bytes for (y = 0; y < 4; y++) { RX_read++; if(RX_read >= 416) RX_read = 0; while(RX_in == RX_read);//wait for byte } erase_block(RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read-1], RX_array[RX_read]); RX_read++; if(RX_read >= 416) RX_read = 0; } //box====================================================== if(RX_array[RX_read] == 15)//^o { //need 4 bytes for (y = 0; y < 4; y++) { RX_read++; if(RX_read >= 416) RX_read = 0; while(RX_in == RX_read);//wait for byte } box(RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read-1], RX_array[RX_read]); RX_read++; if(RX_read >= 416) RX_read = 0; } //line======================================================== else if (RX_array[RX_read] == 12)//^l { //need 5 bytes for (y = 0; y < 5; y++) { RX_read++; if(RX_read >= 416) RX_read = 0; while(RX_in == RX_read);//wait for byte } line(RX_array[RX_read], RX_array[RX_read-4], RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read+-1]); RX_read++; if(RX_read >= 416) RX_read = 0; } } } //print character to the screen=============================================== else { del_char(1); print_char(1, x); } } } //demo(); }
int main (void) { char x, y; //char a = 0; ioinit(); //Setup IO pins and defaults USART_Init( MYUBRR); rprintf_devopen(put_char); /* init rrprintf */ //set_data(0x55); //PORTC |= ((1 << RESET) | (1 << EN) | (1 << R_W) | (1 << CS1) | (1 << CS2) | (1 << RS));//all high //while(1); /* while(1) { PORTC &= ~((1 << EN) | (1 << R_W) | (1 << CS1) | (1 << CS2));//down delay_ms(500); //PORTC |= ((1 << EN) | (1 << R_W) | (1 << CS1) | (1 << CS2));//all high PORTC |= ((1 << RESET) | (1 << EN) | (1 << R_W) | (1 << CS1) | (1 << CS2) | (1 << RS));//all high delay_ms(500); } */ /* DDRC = 0b00000001; while(1) { PORTC |= 0b00000001; delay_1uS(); PORTC &= 0b11111110; delay_1uS(); } */ //Reset the display //PORTC = 0b11110111; PORTC &= ~(1 << RESET); delay_ms(50); PORTC |= (1 << RESET); delay_ms(500); clear_screen(); set_page(0); set_x(0); display_on(); //set display start line to 0 //set control lines PORTC &= ~((1 << EN) | (1 << R_W) | (1 << RS));//down set_port_out(); //set_data(0xC0); set_data(0xC0); delay_us(4); PORTC |= (1 << EN);//up delay_us(4); PORTC &= ~(1 << EN);//down delay_us(4); PORTC |= ((1 << EN) | (1 << R_W) | (1 << RS));//all high set_port_in(); delay_us(4); x_offset = 0; set_page(0); //Backlight on PORTB &= (~(1<<BL_EN)); //demo(); //put_char('X'); while(1) { if(RX_in != RX_read) { x = RX_array[RX_read]; RX_read++; if(RX_read >= 256) RX_read = 0; //Backspace=================================================== if(x == 8) del_char(0); //Special commands else if (x == 124) { //make sure the next byte is there while(RX_in == RX_read); //0, clear screen====================================================== if(RX_array[RX_read] == 0) { clear_screen(); RX_read++; if(RX_read >= 256) RX_read = 0; } //Backlight on/off else if(RX_array[RX_read] == 2) { y = PINB; if (y & (1<<BL_EN)) PORTB &= (~(1<<BL_EN)); else PORTB |= (1<<BL_EN); RX_read++; } //demo mode else if(RX_array[RX_read] == 4) { RX_in = 0, RX_read = 0; demo(); clear_screen(); RX_in = 0; } else { //set x or y========================================================= if((RX_array[RX_read] == 24) | (RX_array[RX_read] == 25)) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte if (RX_array[RX_read-1] == 24) x_offset = RX_array[RX_read]; else if (RX_array[RX_read-1] == 25) y_offset = RX_array[RX_read]; RX_read++; if(RX_read >= 256) RX_read = 0; if (x_offset > 127) x_offset = 127; if (y_offset > 63) y_offset = 63; } //set pixel========================================================= if (RX_array[RX_read] == 16) { //need 3 bytes for (y = 0; y < 3; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } pixel(RX_array[RX_read], RX_array[RX_read-2], RX_array[RX_read-1]); RX_read++; if(RX_read >= 256) RX_read = 0; } //<ctrl>c, circle====================================================== if(RX_array[RX_read] == 3) { //need 4 bytes for (y = 0; y < 4; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } circle(RX_array[RX_read], RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read-1]); RX_read++; if(RX_read >= 256) RX_read = 0; } //<ctrl>e, erase block====================================================== if(RX_array[RX_read] == 5) { //need 4 bytes for (y = 0; y < 4; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } erase_block(RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read-1], RX_array[RX_read]); RX_read++; if(RX_read >= 256) RX_read = 0; } //<ctrl>o, box, running out of meaningful letters====================================================== if(RX_array[RX_read] == 15) { //need 4 bytes for (y = 0; y < 4; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } box(RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read-1], RX_array[RX_read]); RX_read++; if(RX_read >= 256) RX_read = 0; } //<ctrl>L, line======================================================== else if (RX_array[RX_read] == 12) { //need 5 bytes for (y = 0; y < 5; y++) { RX_read++; if(RX_read >= 256) RX_read = 0; while(RX_in == RX_read);//wait for byte } line(RX_array[RX_read], RX_array[RX_read-4], RX_array[RX_read-3], RX_array[RX_read-2], RX_array[RX_read+-1]); RX_read++; if(RX_read >= 256) RX_read = 0; } } } //print character to the screen=============================================== else { del_char(1); //put_char('L'); print_char(1, x); } //set_data(0xFF); //set_port_in(); //display_on(); //y = PINB; //PORTB = y; } } }
int main(void) { static unsigned char buffer[BUFFER_SIZE]; unsigned short i; unsigned char timeout = 3; RTCTime local_time; SystemInit(); // IODIR0 |= (P0_15|P0_16|P0_17); // some outputs for debugging and measures //P0_16 ReadSector() in mmc_spi.c //P0_17 enc28j60 write packet //P0_15 general purpose, BE AWARE ! // uart1Init(B38400, UART_8N1, UART_FIFO_8); // setup the UART uart1Init(B115200, UART_8N1, UART_FIFO_8); // setup the UART rprintf_devopen( uart1_sendchar ); /* init rprintf */ VICIntEnClear = 0xFFFFFFFF; VICIntSelect = 0x00000000; RTCInit(); /* current date 05.08.2007 20:45:00*/ local_time.RTC_Sec = 0; local_time.RTC_Min = 45; local_time.RTC_Hour = 20; local_time.RTC_Mday = 5; local_time.RTC_Wday = 3; // My monday has 0 local_time.RTC_Yday = 1; local_time.RTC_Mon = 8; local_time.RTC_Year = 2007; RTCSetTime( local_time ); /* Set local time */ // RTCStart(); init_timer(); enableIRQ(); printf("Holgi's ARM7 LPC213x MultiFAT Speed Test\n\r"); MMC_IO_Init(); enc28j60_io_init(); // You don't need this ! It's for my board only. while (GetDriveInformation() != F_OK && timeout--) { printf ("MMC/SD-Card not found !\n\r"); HaltCPU(); } ShowDOSConfig(); // show selected DOS details from dosdefs.h /* // test time measurement StartTimer(); timer_value = SetDelay10ms(1000); // delay 10 seconds while(CheckDelay10ms(timer_value)==0); StopTimer(); // stop measure and show results // result is 2MB in 10s -> 200kB/s // end test time measurement */ printf("\nTest directory functions\n"); Chdir("dir1"); Remove("dir4"); Chdir("/"); // Back to root Remove("dir1"); Mkdir("dir1"); Chdir("dir1"); Mkdir("dir2"); Mkdir("dir3"); Rename("dir3","dir4"); Remove("dir2"); // You should have now: // dir1/dir4 Chdir("/"); // Back to root printf("\nDeleting files\n"); Remove("01.bin"); //Remove last data Remove("02.bin"); Remove("04.bin"); Remove("08.bin"); Remove("16.bin"); Remove("32.bin"); Remove("64.bin"); Remove("77.bin"); Remove("128.bin"); Remove("MAX.bin"); //Fill the test buffer for(i=0; i<BUFFER_SIZE; i++) buffer[i]=(unsigned char)(i); printf("\nStart writing files\n"); WriteTestFile("01.bin",buffer,1); WriteTestFile("02.bin",buffer,2); WriteTestFile("04.bin",buffer,4); WriteTestFile("08.bin",buffer,8); WriteTestFile("16.bin",buffer,16); WriteTestFile("32.bin",buffer,32); WriteTestFile("64.bin",buffer,64); WriteTestFile("77.bin",buffer,77); WriteTestFile("128.bin",buffer,128); WriteTestFile("MAX.bin",buffer,BUFFER_SIZE); printf("\nStart reading files\n"); ReadTestFile("01.bin",buffer,1); ReadTestFile("02.bin",buffer,2); ReadTestFile("04.bin",buffer,4); ReadTestFile("08.bin",buffer,8); ReadTestFile("16.bin",buffer,16); ReadTestFile("32.bin",buffer,32); ReadTestFile("64.bin",buffer,64); ReadTestFile("77.bin",buffer,77); ReadTestFile("128.bin",buffer,128); ReadTestFile("MAX.bin",buffer,BUFFER_SIZE); printf("\nVerifying files\n"); VerifyTestFile("32.bin",buffer,32); VerifyTestFile("64.bin",buffer,64); VerifyTestFile("77.bin",buffer,77); VerifyTestFile("128.bin",buffer,128); VerifyTestFile("MAX.bin",buffer,BUFFER_SIZE); printf("Test done.\n"); // test if RTC is running local_time=RTCGetTime(); printf("%02u:%02u:%02u %02u.%02u.%04u\n\r",local_time.RTC_Hour,local_time.RTC_Min,local_time.RTC_Sec ,local_time.RTC_Mday,local_time.RTC_Mon,local_time.RTC_Year ); while(1) { /* if(CheckDelay10ms(timer_value)) { timer_value = SetDelay10ms(1000); // delay 10 seconds // test if RTC is running local_time=RTCGetTime(); printf("%02u:%02u:%02u %02u.%02u.%04u\n\r",local_time.RTC_Hour,local_time.RTC_Min,local_time.RTC_Sec ,local_time.RTC_Mday,local_time.RTC_Mon,local_time.RTC_Year ); } */ } return(0); }
int main (void) { char x, y; //char a = 0; ioinit(); //Setup IO pins and defaults USART_Init( MYUBRR); rprintf_devopen(put_char); /* init rrprintf */ //set_data(0x55); //PORTC |= ((1 << RESET) | (1 << EN) | (1 << R_W) | (1 << CS1) | (1 << CS2) | (1 << RS));//all high //while(1); /* while(1) { PORTC &= ~((1 << EN) | (1 << R_W) | (1 << CS1) | (1 << CS2));//down delay_ms(500); //PORTC |= ((1 << EN) | (1 << R_W) | (1 << CS1) | (1 << CS2));//all high PORTC |= ((1 << RESET) | (1 << EN) | (1 << R_W) | (1 << CS1) | (1 << CS2) | (1 << RS));//all high delay_ms(500); } */ /* DDRC = 0b00000001; while(1) { PORTC |= 0b00000001; delay_1uS(); PORTC &= 0b11111110; delay_1uS(); } */ //Reset the display //PORTC = 0b11110111; PORTC &= ~(1 << RESET); delay_ms(50); //PORTC = 0b11111111; PORTC |= (1 << RESET); delay_ms(500); clear_screen(); set_page(0); set_x(0); display_on(); //set display start line to 0 //set control lines PORTC &= ~((1 << EN) | (1 << R_W) | (1 << RS));//down set_data(0xC0); //set_data(0xFF); delay(); PORTC |= (1 << EN);//up delay(); PORTC &= ~(1 << EN);//down delay(); PORTC |= ((1 << EN) | (1 << R_W) | (1 << RS));//all high delay(); x_offset = 0; set_page(0); /* set_x(0); write_byte(0X55, 1); set_x(1); write_byte(0X55, 1); //set_x(0); x = read_byte(1,1); set_x(2); write_byte(x, 1); set_x(3); write_byte(x, 1); */ //set_x(63);//??? //x = read_byte(1); //set_x(3); //rite_byte(x, 1); //set_x(0); //write_byte(x, 1); //while(1); while(1) { line(0, 0, 63, 63); line(0, 10, 63, 52); line(0, 21, 63, 42); line(0, 32, 63, 32); line(0, 42, 63, 21); line(0, 52, 63, 10); line(0, 63, 63, 0); line(64, 0, 127, 63); line(64, 10, 127, 52); line(64, 21, 127, 42); line(64, 32, 127, 32); line(64, 42, 127, 21); line(64, 52, 127, 10); line(64, 63, 127, 0); //set_x(20); x_offset = 20; set_page(0); print_char('C'); print_char('O'); print_char('C'); print_char('K'); x_offset = 82; print_char('B'); print_char('L'); print_char('O'); print_char('C'); print_char('K'); x_offset = 14; set_page(7); print_char('M'); print_char('O'); print_char('T'); print_char('H'); print_char('E'); print_char('R'); x_offset = 79; print_char('F'); print_char('U'); print_char('C'); print_char('K'); print_char('E'); print_char('R'); delay_ms(1000); clear_screen(); } //line(0, 20, 127, 63); //line(20, 0, 127, 63); //line(0, 63, 127, 0); //pixel(127,63); //pixel(0,0); while(1); while(1) { for (y = 0; y < 64; y++) { //set_x(0); //pixel(0,y); //display_on(); //delay_ms(500); for(x = 0; x < 128; x++) { pixel(x,y); //delay_ms(10); display_on(); } } delay_ms(1000); clear_screen(); } /* while(1); */ /* for (a = 0; a < 64; a++) { set_x(a); write_byte(a,2); delay_ms(500); } */ /* set_x(63); write_byte(0xFF,1); set_x(0); write_byte(0x55,1); while(1); */ /* while(1) { for (a = 32; a < 128; a++) { print_char(a); display_on(); delay_ms(50); } } */ }