int main() { dio_init(); //spi_init(); while(1) { dio_writeChannel(BLACK_LED , STD_HIGH); dio_writeChannel(CYAN_LED , STD_LOW); dio_writeChannel(MAGENTA_LED , STD_HIGH); dio_writeChannel(YELLOW_LED , STD_LOW); dio_writeChannel(WORKING_LED , STD_HIGH); dio_writeChannel(FINISHED_LED, STD_LOW); _delay_ms(100); dio_writeChannel(BLACK_LED , STD_LOW); dio_writeChannel(CYAN_LED , STD_HIGH); dio_writeChannel(MAGENTA_LED , STD_LOW); dio_writeChannel(YELLOW_LED , STD_HIGH); dio_writeChannel(WORKING_LED , STD_LOW); dio_writeChannel(FINISHED_LED, STD_HIGH); _delay_ms(400); } return 0; }
void maintenanceTask() { System_printf("Main Task started\n"); System_flush(); #if 1 /* Enable radio SPI */ spicom_init(); #endif #if 1 /* Enable Trace */ trace_init(); #endif #if 1 /* Digital io */ dio_init(); #endif #ifdef RN_ACTIVE rn_sysbios_init(); rn_module_init(); ap_sim_module_init(); //rn_sysbios_start(); rn_module_start(1); ap_sim_module_start(1); rn_module_start(2); ap_sim_module_start(2); #endif maintenanceMainTask(); /* Should never return but in case*/ Task_exit(); }
/* * Ok, the machine is now initialized. None of the devices * have been touched yet, but the CPU subsystem is up and * running, and memory and process management works. * * Now we can finally start doing some real work.. */ static void __init do_basic_setup(void) { /* * Tell the world that we're going to be the grim * reaper of innocent orphaned children. * * We don't want people to have to make incorrect * assumptions about where in the task array this * can be found. */ child_reaper = current; #if defined(CONFIG_MTRR) /* Do this after SMP initialization */ /* * We should probably create some architecture-dependent "fixup after * everything is up" style function where this would belong better * than in init/main.c.. */ mtrr_init(); #endif #ifdef CONFIG_SYSCTL sysctl_init(); #endif /* * Ok, at this point all CPU's should be initialized, so * we can start looking into devices.. */ #if defined(CONFIG_ARCH_S390) s390_init_machine_check(); #endif #ifdef CONFIG_ACPI_INTERPRETER acpi_init(); #endif #ifdef CONFIG_PCI pci_init(); #endif #ifdef CONFIG_SBUS sbus_init(); #endif #if defined(CONFIG_PPC) ppc_init(); #endif #ifdef CONFIG_MCA mca_init(); #endif #ifdef CONFIG_ARCH_ACORN ecard_init(); #endif #ifdef CONFIG_ZORRO zorro_init(); #endif #ifdef CONFIG_DIO dio_init(); #endif #ifdef CONFIG_NUBUS nubus_init(); #endif #ifdef CONFIG_ISAPNP isapnp_init(); #endif #ifdef CONFIG_TC tc_init(); #endif /* Networking initialization needs a process context */ sock_init(); start_context_thread(); do_initcalls(); #ifdef CONFIG_IRDA irda_proto_init(); irda_device_init(); /* Must be done after protocol initialization */ #endif #ifdef CONFIG_PCMCIA init_pcmcia_ds(); /* Do this last */ #endif }
/* * Ok, the machine is now initialized. None of the devices * have been touched yet, but the CPU subsystem is up and * running, and memory and process management works. * * Now we can finally start doing some real work.. */ static void __init do_basic_setup(void) { #ifdef CONFIG_BLK_DEV_INITRD int real_root_mountflags; #endif /* * Tell the world that we're going to be the grim * reaper of innocent orphaned children. * * We don't want people to have to make incorrect * assumptions about where in the task array this * can be found. */ child_reaper = current; #if defined(CONFIG_MTRR) /* Do this after SMP initialization */ /* * We should probably create some architecture-dependent "fixup after * everything is up" style function where this would belong better * than in init/main.c.. */ mtrr_init(); #endif #ifdef CONFIG_SYSCTL sysctl_init(); #endif /* * Ok, at this point all CPU's should be initialized, so * we can start looking into devices.. */ #ifdef CONFIG_PCI pci_init(); #endif #ifdef CONFIG_SBUS sbus_init(); #endif #if defined(CONFIG_PPC) powermac_init(); #endif #ifdef CONFIG_MCA mca_init(); #endif #ifdef CONFIG_ARCH_ACORN ecard_init(); #endif #ifdef CONFIG_ZORRO zorro_init(); #endif #ifdef CONFIG_DIO dio_init(); #endif #ifdef CONFIG_TC tc_init(); #endif #ifdef CONFIG_PS2 ps2_dev_init(); /* PlayStation 2 devices */ #endif /* Networking initialization needs a process context */ sock_init(); /* Launch bdflush from here, instead of the old syscall way. */ kernel_thread(bdflush, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND); /* Start the background pageout daemon. */ kswapd_setup(); kernel_thread(kswapd, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND); #if CONFIG_AP1000 /* Start the async paging daemon. */ { extern int asyncd(void *); kernel_thread(asyncd, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND); } #endif #ifdef CONFIG_BLK_DEV_INITRD real_root_dev = ROOT_DEV; real_root_mountflags = root_mountflags; if (initrd_start && mount_initrd) root_mountflags &= ~MS_RDONLY; else mount_initrd =0; #endif /* Set up devices .. */ device_setup(); /* .. executable formats .. */ binfmt_setup(); /* .. filesystems .. */ filesystem_setup(); /* Mount the root filesystem.. */ mount_root(); #ifdef CONFIG_UMSDOS_FS { /* When mounting a umsdos fs as root, we detect the pseudo_root (/linux) and initialise it here. pseudo_root is defined in fs/umsdos/inode.c */ extern struct inode *pseudo_root; if (pseudo_root != NULL){ current->fs->root = pseudo_root->i_sb->s_root; current->fs->pwd = pseudo_root->i_sb->s_root; } } #endif #ifdef CONFIG_BLK_DEV_INITRD root_mountflags = real_root_mountflags; if (mount_initrd && ROOT_DEV != real_root_dev && MAJOR(ROOT_DEV) == RAMDISK_MAJOR && MINOR(ROOT_DEV) == 0) { int error; int i, pid; pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD); if (pid>0) while (pid != wait(&i)); if (MAJOR(real_root_dev) != RAMDISK_MAJOR || MINOR(real_root_dev) != 0) { error = change_root(real_root_dev,"/initrd"); if (error) printk(KERN_ERR "Change root to /initrd: " "error %d\n",error); } } #endif }
sint32 main (sint32 * argc, uint8 * argv[]) { dio_init (); tft_init (&tft_initialConfigTft_s); tft_selectBacklight (); tft_clearScreen (BLACK); #if BENCHMARK == TRUE struct timeval start, stop; double start_mil; double stop_mil; double time_diff; uint16 cmp = 0; gettimeofday (&start, NULL); while (cmp < CYCLES) { cmp++; tft_clearScreen (cmp); } gettimeofday (&stop, NULL); start_mil = (start.tv_sec) * 1000 + (start.tv_usec) / 1000; // convert tv_sec & tv_usec to millisecond stop_mil = (stop.tv_sec) * 1000 + (stop.tv_usec) / 1000; // convert tv_sec & tv_usec to millisecond time_diff = stop_mil - start_mil; printf ("Finished in about %f seconds. \n", time_diff); printf ("%d Frames sent in %f seconds. -> FPS: %f\n", cmp, time_diff, (cmp / (time_diff / 1000))); #endif #if BENCHMARK == FALSE /* Use MAIN 1 for fullscreen updates! */ #if MAIN == 1 uint16 buf_display[TFT_WIDTH_UI16 * TFT_HEIGHT_UI16 * 2]; // the current display content uint16 buf_source[TFT_WIDTH_UI16 * TFT_HEIGHT_UI16 * 2]; // the source framebuffer content FILE *fb; int i, j; fb = fopen (argv[1], "rb"); // run forever... while (1) { fseek (fb, 0, SEEK_SET); // rewind source framebuffer fread (buf_source, 1, TFT_WIDTH_UI16 * TFT_HEIGHT_UI16 * 2, fb); // read complete source framebuffer tft_setWindow (0, 0, TFT_WIDTH_UI16 - 1, TFT_HEIGHT_UI16 - 1); tft_drawStart (); // re-transmit the unchanged pixels of current row up to here for (j = 0; j < TFT_WIDTH_UI16 * TFT_HEIGHT_UI16; j++) { tft_sendPixelData (buf_source[j]); } usleep (5000L); // sleep for 5ms } // actually we never get here fclose (fb); #endif /* Use MAIN 2 for line based update */ #if MAIN == 2 int y, x, j, i; // open the source framebuffer deviarm-linux-gnueabihf-gcc srce FILE *fb = fopen (argv[1], "rb"); // allocate two buffers for tracking the source framebuffer changes uint16 buf_display[TFT_WIDTH_UI16 * TFT_HEIGHT_UI16 * 2]; // the current display content uint16 buf_source[TFT_WIDTH_UI16 * TFT_HEIGHT_UI16 * 2]; // the source framebuffer content // run forever... while (TRUE) { fseek (fb, 0, SEEK_SET); // rewind source framebuffer fread (buf_source, 1, TFT_WIDTH_UI16 * TFT_HEIGHT_UI16 * 2, fb); // read complete source framebuffer // statistics uint32 changed = 0; // how many pixels have changed since last refresh uint32 drawed = 0; // how many pixel actualy where transmitted since last refresh // state for merging adjacent changes into one transmission uint32 i = 0; // current pixel index boolean drawing = FALSE; // if pixels are currently transmitted uint32 lastChange = 0; // index of first pixel of this transmission // for all pixels on screen... for (y = 0; y < TFT_HEIGHT_UI16; y++) { for (x = 0; x < TFT_WIDTH_UI16; x++) { uint16 color = buf_source[i]; // get this pixels source color if (color != buf_display[i]) { // the pixel has changed changed++; lastChange = i; // store last change index if (!drawing) { // whe are not drawing, so start a run here. // we only draw full rows: // set display area to the rest of the screen, including this row tft_setWindow (0, y, TFT_WIDTH_UI16 - 1, TFT_HEIGHT_UI16 - 1); tft_drawStart (); // re-transmit the unchanged pixels of current row up to here for (j = 0; j < x; j++) tft_sendPixelData (buf_display [y * TFT_WIDTH_UI16 + j]); drawing = TRUE; } } if (drawing) { // where in a transmission run. tft_sendPixelData (color); // send pixel buf_display[i] = color; // store change drawed++; // end transmission, if the was no change for some time if (i > lastChange + 400) { // stop drawing, lcd actually gets updated. tft_drawStop (); drawing = FALSE; } } i++; } } // if(changed>0) printf("Pixels changed: %i, drawed: %i\n",changed,drawed); usleep (10000L); // sleep for 10ms } // actually we never get here fclose (fb); #endif /* this routine sends every pixel by itself */ #if MAIN == 3 int y, x, j, i; // open the source framebuffer device FILE *fb = fopen (argv[1], "rb"); // allocate two buffers for tracking the source framebuffer changes uint16 buf_display[TFT_WIDTH_UI16 * TFT_HEIGHT_UI16 * 2]; // the current display content uint16 buf_source[TFT_WIDTH_UI16 * TFT_HEIGHT_UI16 * 2]; // the source framebuffer content // run forever... while (TRUE) { fseek (fb, 0, SEEK_SET); // rewind source framebuffer fread (buf_source, 1, TFT_WIDTH_UI16 * TFT_HEIGHT_UI16 * 2, fb); // read complete source framebuffer // statistics uint32 changed = 0; // how many pixels have changed since last refresh uint32 drawed = 0; //for(n = 0; n < f_size; n++) // { // printf("old_buffer[%d]: %c \t new_buffer[%d]: %c\n", n, old_buffer[n], n, new_buffer[n]); // }/ how many pixel actualy where transmitted since last refresh // state for merging adjacent changes into one transmission uint32 i = 0; // current pixel index boolean drawing = FALSE; // if pixels are currently transmitted uint32 lastChange = 0; // index of first pixel of this transmission uint16 color = 0; // for all pixels on screen... for (y = 0; y < TFT_HEIGHT_UI16; y++) { for (x = 0; x < TFT_WIDTH_UI16; x++) { color = buf_source[i]; if (color != buf_display[i]) { buf_display[i] = color; changed++; tft_drawPixel (x, y, color); } i++; } } //printf("pixel changed: %d\n", changed); // if(changed>0) printf("Pixels changed: %i, drawed: %i\n",changed,drawed); usleep (10000L); // sleep for 10ms } // actually we never get here fclose (fb); #endif /* This Routine sends a group of pixels after one has altered */ #if MAIN == 5 #define PIXELGROUPLEN 40 int y, x, j, i, xend; // open the source framebuffer device FILE *fb = fopen (argv[1], "rb"); // allocate two buffers for tracking the source framebuffer changes uint16 buf_display[TFT_HEIGHT_UI16][TFT_WIDTH_UI16]; // the current display content uint16 buf_source[TFT_HEIGHT_UI16][TFT_WIDTH_UI16]; // the source framebuffer content for (i = 0; i < TFT_HEIGHT_UI16; i++) { for (j = 0; j < TFT_WIDTH_UI16; j++) { buf_display[i][j] = 0; } } // run forever... while (TRUE) { /* This can be speed up a little by using DMA or memcopy */ fseek (fb, 0, SEEK_SET); // rewind source framebuffer for (i = 0; i < TFT_HEIGHT_UI16 * 2; i++) //fread(buf_source[i], 2, TFT_WIDTH_UI16, fb); // read complete source framebuffer fread (buf_source[i], 1, TFT_WIDTH_UI16 * 2, fb); // read complete source framebuffer for (y = 0; y < TFT_HEIGHT_UI16; y++) { uint32 changed = 0; // how many pixels have changed since last refresh uint32 drawed = 0; // how many pixel actualy where transmitted since last refresh xend = 0; for (x = 0; x < TFT_WIDTH_UI16; x++) { //x = i ;//% TFT_WIDTH_UI16; //y = lines; if (buf_source[y][x] != buf_display[y][x]) { //printf("buf_source[%d] = %d \t | \t buf_display[%d]: %d\n",i, buf_source[i], i, buf_display[i]); changed++; if ((x + PIXELGROUPLEN) > TFT_WIDTH_UI16) { xend = TFT_WIDTH_UI16 - 1; //printf("x: %d\n", x); } else { xend = x + PIXELGROUPLEN; } tft_setWindow (x, y, xend, y); tft_drawStart (); //for(j = tmpx; j < tmpx+xend; j++) for (j = x; j <= xend; j++) { tft_sendPixelData (buf_source[y][j]); buf_display[y][j] = buf_source[y][j]; drawed++; // x++; } x = xend; } } } usleep (15000L); // sleep for 15ms } fclose (fb); #endif /* This Routine analyzes the screen alteration and switches to the best method for the screen update */ #if MAIN == 6 int y, x, j, i, cnt; // open the source framebuffer device FILE *fb = fopen (argv[1], "rb"); // allocate two buffers for tracking the source framebuffer changes uint16 buf_display[TFT_WIDTH_UI16 * TFT_HEIGHT_UI16 * 2]; // the current display content uint16 buf_source[TFT_WIDTH_UI16 * TFT_HEIGHT_UI16 * 2]; // the source framebuffer content // run forever... while (TRUE) { fseek (fb, 0, SEEK_SET); // rewind source framebuffer fread (buf_source, 1, TFT_WIDTH_UI16 * TFT_HEIGHT_UI16 * 2, fb); // read complete source framebuffer // statistics uint32 changed = 0; // how many pixels have changed since last refresh uint32 drawed = 0; // how many pixel actualy where transmitted since last refresh // state for merging adjacent changes into one transmission uint32 i = 0; // current pixel index boolean drawing = FALSE; // if pixels are currently transmitted uint32 lastChange = 0; // index of first pixel of this transmission cnt = 0; // for all pixels on screen... for (y = 0; y < TFT_HEIGHT_UI16; y++) { for (x = 0; x < TFT_WIDTH_UI16; x++) { cnt++; if (buf_display[cnt] != buf_source[cnt]) changed++; } } if (changed < 1000) { // open the source framebuffer device //FILE* fb=fopen(argv[1],"rb"); // allocate two buffers for tracking the source framebuffer changes uint16 buf_display[TFT_WIDTH_UI16 * TFT_HEIGHT_UI16 * 2]; // the current display content uint16 buf_source[TFT_WIDTH_UI16 * TFT_HEIGHT_UI16 * 2]; // the source framebuffer content fseek (fb, 0, SEEK_SET); // rewind source framebuffer fread (buf_source, 1, TFT_WIDTH_UI16 * TFT_HEIGHT_UI16 * 2, fb); // read complete source framebuffer // statistics // uint32 changed=0; // how many pixels have changed since last refresh //for(n = 0; n < f_size; n++) // { // printf("old_buffer[%d]: %c \t new_buffer[%d]: %c\n", n, old_buffer[n], n, new_buffer[n]); // }/ how many pixel actualy where transmitted since last refresh // state for merging adjacent changes into one transmission uint32 i = 0; // current pixel index boolean drawing = FALSE; // if pixels are currently transmitted uint32 lastChange = 0; // index of first pixel of this transmission uint16 color = 0; // for all pixels on screen... for (y = 0; y < TFT_HEIGHT_UI16; y++) { for (x = 0; x < TFT_WIDTH_UI16; x++) { color = buf_source[i]; if (color != buf_display[i]) { buf_display[i] = color; drawed++; tft_drawPixel (x, y, color); } i++; } } //printf("pixel changed: %d\n", changed); // if(changed>0) printf("Pixels changed: %i, drawed: %i\n",changed,drawed); usleep (15000L); // sleep for 15ms } else { #define PIXELGROUPLEN 40 int y, x, j, i, xend, lines, tmpx; // open the source framebuffer device // allocate two buffers for tracking the source framebuffer changes uint16 buf_display[TFT_HEIGHT_UI16][TFT_WIDTH_UI16]; // the current display content uint16 buf_source[TFT_HEIGHT_UI16][TFT_WIDTH_UI16]; // the source framebuffer content for (i = 0; i < TFT_HEIGHT_UI16; i++) for (j = 0; j < TFT_WIDTH_UI16; j++) buf_display[i][j] = 0; // run forever... fseek (fb, 0, SEEK_SET); // rewind source framebuffer for (i = 0; i < TFT_HEIGHT_UI16 * 2; i++) //fread(buf_source[i], 2, TFT_WIDTH_UI16, fb); // read complete source framebuffer fread (buf_source[i], 1, TFT_WIDTH_UI16 * 2, fb); // read complete source framebuffer i = 0; tmpx = 0; for (y = 0; y < TFT_HEIGHT_UI16; y++) { //uint32 changed=0; // how many pixels have changed since last refresh //uint32 drawed=0; // how many pixel actualy where transmitted since last refresh xend = 0; for (x = 0; x < TFT_WIDTH_UI16; x++) { //x = i ;//% TFT_WIDTH_UI16; //y = lines; tmpx = x; if (buf_source[y][x] != buf_display[y][x]) { //printf("buf_source[%d] = %d \t | \t buf_display[%d]: %d\n",i, buf_source[i], i, buf_display[i]); //changed++; if ((x + PIXELGROUPLEN) > TFT_WIDTH_UI16) { xend = TFT_WIDTH_UI16 - 1; //printf("x: %d\n", x); //system("sleep 2"); } else xend = x + PIXELGROUPLEN; tft_setWindow (x, y, xend, y); tft_drawStart (); //for(j = tmpx; j < tmpx+xend; j++) for (j = x; j <= xend; j++) { tft_sendPixelData (buf_source[y][j]); buf_display[y][j] = buf_source[y][j]; drawed++; // x++; } x = xend; } } } usleep (15000L); // sleep for 15ms } //printf("Pixels changed: %i, drawed: %i\n",changed,drawed); } // actually we never get here fclose (fb); #endif #endif return 0; }