/**************************************************
* Function name		: void main(void)
*
* Created by		: Luca Lucci
* Date created		: 07/10/12
* Description		: Main program entry point
* Notes				: -
**************************************************/
void main(void)
{
  initialize_system();

    // initialize usart
  uart_init();
  uart2_open();

  // initialize interrupt
  INTCON2bits.INTEDG0 = 0;	// falling edge int0 interrupt
  INTCONbits.INT0IE = 1;	// enable int0 interrupt
  INTCONbits.INT0IF = 0;
  INTCONbits.PEIE = 1;		// enable peripheral interrupts
  INTCONbits.GIE = 1;		// enable global interrupt
  

  while(1) 
  {
    ClrWdt();
    
    // if the buffer isn't empty will send back the data
    if(uart2_buffer_read(temp))
      uart2_buffer_tx_load(temp);

    // ProcessIO
  }
}//main()
Beispiel #2
0
/*
 * Perform a memory test on external main memory.
 */
void
verify_external_mem(int loops, unsigned int addr_bus_size, unsigned int size)
{
    void initialize_system();
    int i;
    int databus_errors = 0;
    int addrbus_errors = 0;
    int memory_errors = 0;

    initialize_system();

    for (i = 1; i <= loops; i++) {
        printf("\nTesting external memory: iteration %d of %d\n",
               i, loops);
        if (test_data_bus(EXTERNAL_MEM_BASE) < 0)
            databus_errors++;

        if (test_addr_bus(EXTERNAL_MEM_BASE, addr_bus_size) < 0)
            addrbus_errors++;

        if (test_memory(EXTERNAL_MEM_BASE, size) < 0)
            memory_errors++;
    }
    printf("Data Bus Errors = %d\n", databus_errors);
    printf("Address Bus Errors = %d\n", addrbus_errors);
    printf("Memory Errors = %d\n", memory_errors);
}
Beispiel #3
0
int main(int argc, char** argv)
{
    initialize_system();

    run_unit_tests();

    run_functional_tests();

    return (EXIT_SUCCESS);
}
Beispiel #4
0
int main(void)
{
  initialize_system();

  while(1)
  {
    // read in the dict file till done
    // check to see if we've received data from UI board
    // if true, process the single byte
    if(usart_keypad_data_ready)
    {
      /* one of two types:
       * [U][I][msglen][msg_number][msg_type][payload][CRC1][CRC2]
       * [M][C][msglen][msg_number][msg_type][payload][CRC1][CRC2]
       * msg_type:
       *  A: contains braille dot at this location in the UI
       *  B: contains braille character at this location in the UI
       *  C: payload contains an error message
       *  D: payload contains a control button input from UI
       *  E: miscellaneous */
      usart_keypad_receive_action();
    }

    // check to see if we've received data from a connected PC 
    // if true, process the single byte
    if(usart_pc_data_ready)
    {
      usart_pc_receive_action();
    }

    if(timer_interrupt)
    {
      timer_interrupt = false;
      //  timer_routine();
    }

    if(usart_pc_message_ready) //If a message ready from the PC, process it
    {
      pc_parse_message();
    }

    if(usart_ui_message_ready) //If a message ready from the user interface, process it
    {
      ui_parse_message(playing_sound);
    }

    ui_run_main_of_current_mode();

    if (playlist_empty == false) {
      play_next_mp3();
    }
  }
  return 1;
}
Beispiel #5
0
//------------------------------------------------------------------------------
// MAIN FUNCTION 
//------------------------------------------------------------------------------
void main (void)
{
	unsigned int eeprom_address;

	initialize_system();					// Initialize RS-232 and rest of system

	printf("\n\rKeil Software, Inc.\n\r");	// Display starup message
	printf("LPC764 MCU I2C Example Test Program\n\r");
	printf("Version 1.0.0\n\r");
	printf("Copyright 2000 - Keil Software, Inc.\n\r");
	printf("All rights reserved.\n\n\r");

	P1M1  = 0x0C;							// Set Port 1 Open Drain
	P1M2  = 0x0C;

	I2CFG = 0x22;							// Config byte: 0 MAS CLRT1 T1, 00 CC  (page 16)
											// In our case the config byte is:
										 	// Slave bit 	(7): 0 (we are not a slave)
										 	// Master bit 	(6): 0 (we are a master)
										 	// Clear T1 	(5): 1 (Clear TI) 
										 	// TI Run 		(4): 0 (set TI to run)
										 	// Not used		(3): 0 		
											// Not used		(2): 0 
										 	// CT 1			(1): 1 (Set for highest CPU clock rate)
											// CT 0			(0): 0 



	printf("Writing data to EEPROM....");
	for (eeprom_address = 0; eeprom_address < 75; eeprom_address++)
		write_byte((unsigned char)eeprom_address + 0x30, eeprom_address);

	printf("Done!\n\r");
	printf("Reading from EEPROM...ASCII table!\n\r");


	while (TRUE)							// Infinite loop, never exits
	{
		for (eeprom_address = 0; eeprom_address < 75; eeprom_address++)
		{
			delay_time(DELAY_BLINK);		// Blink LED with delay
			LED = ON;
			delay_time(DELAY_BLINK);
			LED = OFF;

			printf("Address: %3u	Character: %c\n\r", eeprom_address, read_byte(eeprom_address));
		}
	}
}
Beispiel #6
0
void
verify_internal_mem(int loops)
{
    void initialize_system();
    int i;

    initialize_system();

    for (i = 1; i <= loops; i++) {
        printf("\nTesting internal memory: iteration %d of %d\n",
               i, loops);
        test_data_bus(DPRAM_BASE);
        test_addr_bus(DPRAM_BASE, DPRAM_SIZE);
        test_memory(DPRAM_BASE, DPRAM_SIZE);
    }

}
Beispiel #7
0
int main(void) {
    char c;
    initialize_system();

    svc_myFputs("InterruptSerialIO project starting\r\n", STDOUT);

    do {
        svc_myFputs("Enter character: ", STDOUT);
        c = svc_myFgetc(STDIN);
        svc_myFputs("\r\n", STDOUT);
    } while(c != 'x');

    svc_myFputs("InterruptSerialIO project completed\r\n", STDOUT);

    flushBuffer();

    return 0;
}
Beispiel #8
0
/**
 * main entry point of program.
 * initialize all hardware.  enter infinite loop that busy-checks
 * for button presses and responds appropriately.
 */
int main(void) {
    initialize_system();
    svc_myFputs("Starting InterruptPDBOneShotTest project\r\n", STDOUT);

    /* 46875 is 1 second */
    svc_myFputs("Scheduling interrupt in 46875/46875 seconds\r\n", STDOUT);
    svc_setTimer(46875);
    /* delay long enough to let the timer go off */
    delay(30000000);

    svc_myFputs("Scheduling interrupt in 4687/46875 seconds\r\n", STDOUT);
    svc_setTimer(4687);
    /* delay long enough to let the timer go off */
    delay(15000000);

    svc_myFputs("Ending InterruptPDBOneShotTest project\r\n", STDOUT);
    svc_flushOutput();
    return 0;
}
/**************************************************
* Function name		: void main(void)
*
* Created by		: Luca Lucci
* Date created		: 07/10/12
* Description		: Main program entry point
* Notes				: -
**************************************************/
void main(void)
{
  initialize_system();

  can_uart_initialize();

  OpenTimer0(TIMER_INT_ON & T0_16BIT & T0_SOURCE_INT & T0_PS_1_256);
  
  // initialize interrupt 
  INTCONbits.PEIE = 1;		// enable peripheral interrupts
  INTCONbits.GIE = 1;		// enable global interrupt

  T0CONbits.TMR0ON = 1;

  while(1) 
  {
    can_uart_loop();
  }

}//main()
Beispiel #10
0
int main(int argc, char ** argv){
  // ./a.out Nx
  FILE * fid1, * fid2;
  fid1 = fopen("initial.dat", "w");
  double T = 0.25; double t = 0; double tn; 
  double L = 1.;   int Nx = atoi(argv[1]); double dx = L/(double)Nx;int NT = Nx + 2;
  double **U; double rho[Nx+2]; double P[Nx+2];double V[Nx+2];
  initnxN(&U, Nx+2, 3);
  initialize_system(U, rho, P, V, Nx);
  write(U, fid1, NT, dx);
  while(t<T){
    tn = advance_system(U, dx, t, NT, P); t = tn; //printf("t=%f\n", t);
    //printf("i 21 column %f  %f  %f", U[0][21], U[1][21], U[2][21]);
    //break;
    //printf("E = %f\n", U[2][1]);
     }
  getRow(U, NT, rho, 0);
  fid2 = fopen("final.dat", "w");
  write(U, fid2, NT, dx);
}
//------------------------------------------------------------------------------
// MAIN FUNCTION 
//------------------------------------------------------------------------------
void main (void)
{
	unsigned char index, voltage_out;

	initialize_system();

	printf("\n\rKeil Software, Inc.\n\r");	// Display starup message
	printf("MCB517 MCU I²C Example Test Program\n\r");
	printf("Version 1.0.0\n\r");
	printf("Copyright 2000 - Keil Software, Inc.\n\r");
	printf("All rights reserved.\n\n\r");

	printf("P8591 Test Program....Reading from ADC channel 0, Writing to DAC!\n\r");

	while (TRUE)
	{
		for (voltage_out = 0; voltage_out < 0xFF; voltage_out++)
		{

			write_dac(voltage_out);			// Write voltage value to DAC

											// Blink LEDs in sequence
			for (index = 0x01; index < 0x80; index <<=1)
			{
				P4 = index;
				delay_time(DELAY_BLINK);
			}
	  		for (index = 0x80; index > 0x01; index >>=1)
			{
				P4 = index;
				delay_time(DELAY_BLINK);
		   	}

											// Read voltage (ADC 0) and display results
   			printf("DAC output: %3bu     ADC Channel 0: %3bu\n\r", voltage_out, read_adc_channel(0x00));
		}
	}
}
Beispiel #12
0
int main(int argc, char ** argv){
  // ./a.out Nx
  FILE * fid1, * fid2, * fid3;
  fid1 = fopen("initial2.dat", "w");
  fid3 = fopen("entropy.dat", "w");
  double T = atof(argv[1]); double t = 0; 
  double L = 1.;   int Nx = 5000; double dx = L/(double)Nx;int NT = Nx + 2;
  double **U; double rho[Nx+2]; double P[Nx+2];double V[Nx+2];
  initnxN(&U, Nx+2, 3);
  initialize_system(U, rho, P, V, NT);
  //printf("i write=%f\n", U[0][NT-2]);
  double dense[Nx]; getRow(U, NT, dense, 0);
  write(dense, fid1, NT, dx);


  //advance_system( U , dx , t , NT , P );
  //printf("t=%f\n", t); 
  //sleep(1);
  
  while(t<T){
    double tn = advance_system(U, dx, t, NT, P); 
    double sumv, sump;
    Entropy(U, NT, dx, &sumv, &sump);
    fprintf(fid3, "%e   %e   %e\n", t, sumv, sump);
    //printf("t=%f\n", tn); 
    //sleep(1);
    t = tn;
    //printf("i 21 column %f  %f  %f", U[0][21], U[1][21], U[2][21]);
    //break;

    }
  fid2 = fopen("final2.dat", "w");
  getRow(U, NT, dense, 0);
  write(dense, fid2, NT, dx);
  
  return(0);
}
Beispiel #13
0
void
execute(int memory_type, int loops)
{
    void initialize_system(void);

    unsigned char wbuf[MAX_CODE_LEN];
    unsigned char rbuf[MAX_CODE_LEN];
    unsigned long pc, csr;
    unsigned long address;
    int status;
    int code_len;
    int i, b, loop = 0;
    int verify_error = 0;

    const char *code =
        "46FC 2700"
        "2E7C 0E00 0000"
        "207C A0A0 A0A0"
        "227C A1A1 A1A1"
        "247C A2A2 A2A2"
        "267C A3A3 A3A3"
        "287C A4A4 A4A4"
        "2A7C A5A5 A5A5"
        "2C7C A6A6 A6A6"
        "2E7C A7A7 A7A7"
        "203C D0D0 D0D0"
        "223C D1D1 D1D1"
        "243C D2D2 D2D2"
        "263C D3D3 D3D3"
        "283C D4D4 D4D4"
        "2A3C D5D5 D5D5"
        "2C3C D6D6 D6D6"
        "2E3C D7D7 D7D7"
        "4E71"
        "6000 FFFC";

    printf("\nCPU32 %s code execution test: iteration %d of %d\n",
           memory_type == INTERNAL_RAM ? "internal": "external",
           loop, loops);

    /*
     * Convert the code to binary to load. The code is
     * like this as it is easy to cut and paste in.
     */
    code_len = strlen(code);

    if (code_len >= MAX_CODE_LEN) {
        printf("Too much code for the buffer.\n");
        clean_exit(1);
    }

    b = 0;

    for (i = 0; i < code_len; i++) {
        if (code[i] > ' ') {
            if (code[i] >= '0' && code[i] <= '9')
                wbuf[b] = code[i] - '0';
            else if (code[i] >= 'a' && code[i] <= 'f')
                wbuf[b] = code[i] - 'a' + 10;

            i++;

            if (code[i] >= '0' && code[i] <= '9')
                wbuf[b] = (wbuf[b] << 4) | (code[i] - '0');
            else if (code[i] >= 'a' && code[i] <= 'f')
                wbuf[b] = (wbuf[b] << 4) | (code[i] - 'a' + 10);

            b++;
        }
    }

    initialize_system();

    if (memory_type == INTERNAL_RAM) {
        address = DPRAM_BASE;
        printf("Loading code into DPRAM, base address: 0x%.8lX\n", address);
    }
    else {
        address = 0x0;
        printf("Loading code into external RAM, base address: 0x%.8lX\n",
               address);
    }

    if (bdmWriteMemory(address, wbuf, b) < 0)
        show_error("Writing buffer to RAM");

    if (bdmReadMemory(address, rbuf, b) < 0)
        show_error("Reading buffer from RAM");

    for (i = 0; i < b; i++) {
        if (wbuf[i] != rbuf[i]) {
            printf("Read buffer and write buffer do not agree!\n");
            verify_error = 1;

            if (stop_on_error)
                clean_exit(1);
        }
    }

    if (!verify_error)
        printf("Code readback successful\n");

    if (bdmWriteSystemRegister(BDM_REG_RPC, address) < 0)
        show_error("Writing PC");

    printf("Stepping code.\n");

    for (i = 0; i < 20; i++) {
        if (bdmReadSystemRegister(BDM_REG_CSR, &csr) < 0)
            show_error("Reading CSR");
        if (bdmReadSystemRegister(BDM_REG_RPC, &pc) < 0)
            show_error("Reading PC");

        printf("Stepping, pc: 0x%08lx", pc);

        if ((pc & 0xfffff000) != address) {
            printf("  WARNING: PC is not in correct address range\n");
        }
        else {
            printf("\n");
        }

        if (bdmStep() < 0)
            show_error("Step");
    }

    show_registers();

    printf("Letting target run...\n");

    if (bdmGo() < 0)
        show_error("Go");

    sleep(1);

    status = bdmStatus();
    printf("Target status: 0x%x -- %s, %s, %s, %s, %s.\n", status,
           status & BDM_TARGETRESET   ? "RESET" : "NOT RESET",
           status & BDM_TARGETHALT    ? "HALTED" : "NOT HALTED",
           status & BDM_TARGETSTOPPED ? "STOPPED" : "NOT STOPPED",
           status & BDM_TARGETPOWER   ? "POWER OFF" : "POWER ON",
           status & BDM_TARGETNC      ? "NOT CONNECTED" : "CONNECTED");

    printf("Stopping target...\n");

    if (bdmStop() < 0) {
        show_error("Stopping target");
    }
    else {
        status = bdmStatus();
        printf("Target status: 0x%x -- %s, %s, %s, %s, %s.\n", status,
               status & BDM_TARGETRESET   ? "RESET" : "NOT RESET",
               status & BDM_TARGETHALT    ? "HALTED" : "NOT HALTED",
               status & BDM_TARGETSTOPPED ? "STOPPED" : "NOT STOPPED",
               status & BDM_TARGETPOWER   ? "POWER OFF" : "POWER ON",
               status & BDM_TARGETNC      ? "NOT CONNECTED" : "CONNECTED");

        show_registers();
    }
}
void main ()
{
  initialize_system ();
  process_command ();
}
int main(int argc, char **argv)
{
	/* create a simple definite positive symetric matrix example
	 *
	 *	Hilbert matrix : h(i,j) = 1/(i+j+1)
	 * */

	parse_args(argc, argv);

	float *mat = NULL;
	int ret = initialize_system(&mat, size, pinned);
	if (ret) return ret;

#ifndef STARPU_SIMGRID
	unsigned i,j;
	for (i = 0; i < size; i++)
	{
		for (j = 0; j < size; j++)
		{
			mat[j +i*size] = (1.0f/(1.0f+i+j)) + ((i == j)?1.0f*size:0.0f);
			/* mat[j +i*size] = ((i == j)?1.0f*size:0.0f); */
		}
	}
#endif


#ifdef CHECK_OUTPUT
	FPRINTF(stdout, "Input :\n");

	for (j = 0; j < size; j++)
	{
		for (i = 0; i < size; i++)
		{
			if (i <= j)
			{
				FPRINTF(stdout, "%2.2f\t", mat[j +i*size]);
			}
			else
			{
				FPRINTF(stdout, ".\t");
			}
		}
		FPRINTF(stdout, "\n");
	}
#endif


	cholesky(mat, size, size, nblocks);

#ifdef CHECK_OUTPUT
	FPRINTF(stdout, "Results :\n");

	for (j = 0; j < size; j++)
	{
		for (i = 0; i < size; i++)
		{
			if (i <= j)
			{
				FPRINTF(stdout, "%2.2f\t", mat[j +i*size]);
			}
			else
			{
				FPRINTF(stdout, ".\t");
				mat[j+i*size] = 0.0f; /* debug */
			}
		}
		FPRINTF(stdout, "\n");
	}

	FPRINTF(stderr, "compute explicit LLt ...\n");
	float *test_mat = malloc(size*size*sizeof(float));
	STARPU_ASSERT(test_mat);

	STARPU_SSYRK("L", "N", size, size, 1.0f,
				mat, size, 0.0f, test_mat, size);

	FPRINTF(stderr, "comparing results ...\n");
	for (j = 0; j < size; j++)
	{
		for (i = 0; i < size; i++)
		{
			if (i <= j)
			{
				FPRINTF(stdout, "%2.2f\t", test_mat[j +i*size]);
			}
			else
			{
				FPRINTF(stdout, ".\t");
			}
		}
		FPRINTF(stdout, "\n");
	}
	free(test_mat);
#endif

	shutdown_system(&mat, pinned);
	return 0;
}
Beispiel #16
0
int main(int argc, char **argv) {
    initialize_system();
    cmd_process_demo(0, NULL);
    init_process();
    return 0;
}
Beispiel #17
0
void
verify_internal_ram(int loops)
{
#define SRAM_BYTE_SIZE (256)
#define SRAM_BUF_SIZE  (SRAM_BYTE_SIZE / sizeof(unsigned long))

    void initialize_system(void);

    unsigned long buf[SRAM_BUF_SIZE];
    unsigned int  test;
    unsigned int  i;
    int           sram_ok;
    int           loop = 0;

    printf("Internal DPAM Test, %d loops\n", loops);
    initialize_system();

    while (loop < loops) {
        loop++;
        printf(" %5i : ", loop);
        for (test = 0; test < sizeof(test_pattern)/sizeof(test_pattern[0]);
                test++) {
            for (i = 0; i < SRAM_BUF_SIZE; i++) {
                buf[i] = test_pattern[test];
            }

            sram_ok = 1;

            if (bdmWriteMemory(DPRAM_BASE, (unsigned char*) buf, SRAM_BYTE_SIZE) < 0) {
                if (stop_quiet)
                    printf("W");
                else
                    show_error("Writing SRAM buffer");
            }

            if (bdmReadMemory(DPRAM_BASE, (unsigned char*) buf, SRAM_BYTE_SIZE) < 0) {
                if(stop_quiet)
                    printf("R");
                else
                    show_error("Reading SRAM buffer");
            }

            for (i = 0; i < SRAM_BUF_SIZE; i++) {
                if (buf[i] != test_pattern[test]) {
                    sram_ok = 0;
                    if(stop_quiet)
                        printf("R");
                    else {
                        printf("  addr=%08lx,  write/read %08lx %08lx\n",
                               DPRAM_BASE + (i * sizeof(unsigned long)),
                               test_pattern[test], buf[i]);
                        show_error("Verifing SRAM");
                    }
                }
            }

            if(sram_ok)
                printf(".");

            fflush(stdout);
        }
        printf("\n");
    }
}
Beispiel #18
0
void
check_alignment(int loops)
{
    unsigned long addr;
    int           loop_failed = 0;
    int           failed = 0;
    int           loop = 0;
    unsigned char buf[ALIGN_MEM_SIZE];

    void initialize_system(void);

    printf("\nAlignment Test, %d loop%s\n", loops, loops == 1 ? "" : "s");

    initialize_system();

    for (addr = 0; addr < 256; addr++)
        buf[addr] = addr;

    while (loop < loops) {
        loop++;
        loop_failed = 0;

        /*
         * Fill the memory with a byte count.
         */
        printf("Byte write alignment verify, %4d of %4d : \n", loop, loops);
        for (addr = 0; addr < 256; addr++) {
            if (bdmWriteByte(addr + DPRAM_BASE, addr) < 0) {
                failed = loop_failed = 1;
                if(stop_quiet)
                    printf("B");
                else {
                    printf("\n");
                    printf("Write byte 0x%02x to 0x%08lx\n",
                           (unsigned char)addr, addr + DPRAM_BASE);
                    show_error("Write byte pattern");
                }
                continue;
            }
            else {
                if ((addr % 32) == 0)
                    printf("\n");
                printf(".");
            }
        }
        printf("\n");
        if (verify_alignment() < 0) {
            failed = loop_failed = 1;
            if(!stop_quiet) {
                printf("\n");
                show_error("Verify byte write");
            }
        }

        /*
         * Fill the memory with a byte count.
         */
        printf("\nWord write alignment verify, %4d of %4d : \n",
               loop, loops);
        for (addr = 0; addr < 256; addr += 2) {
            if (bdmWriteWord(addr + DPRAM_BASE, (addr << 8) | (addr + 1)) < 0) {
                failed = loop_failed = 1;
                if(stop_quiet)
                    printf("W");
                else {
                    printf("\n");
                    printf("Write word 0x%04x to 0x%08lx\n",
                           (unsigned short) addr, addr + DPRAM_BASE);
                    show_error("Write word pattern");
                }
                continue;
            }
            else {
                if ((addr % 32) == 0)
                    printf("\n");
                printf(".");
            }
        }
        printf("\n");
        if (verify_alignment() < 0) {
            failed = loop_failed = 1;
            if(!stop_quiet) {
                printf("\n");
                show_error("Verify word write");
            }
        }

        /*
         * Fill the memory with a byte count.
         */
        printf("\nLong word write alignment verify, %4d of %4d : \n",
               loop, loops);
        for (addr = 0; addr < 256; addr += 4) {
            if (bdmWriteLongWord(addr + DPRAM_BASE,
                                 ((addr << 24) | ((addr + 1) << 16) |
                                  ((addr + 2) << 8) | (addr + 3)))) {
                failed = loop_failed = 1;
                if(stop_quiet)
                    printf("L");
                else {
                    printf("\n");
                    printf("Write long word 0x%08lx to 0x%08lx\n",
                           addr, addr + DPRAM_BASE);
                    show_error("Write long word pattern");
                }
                continue;
            }
            else {
                if ((addr % 32) == 0)
                    printf("\n");
                printf(".");
            }
        }
        printf("\n");
        if (verify_alignment() < 0) {
            failed = loop_failed = 1;
            if(!stop_quiet) {
                printf("\n");
                show_error("Verify long word write");
            }
        }
        printf("\nBlock write alignment verify, %4d of %4d : \n", loop, loops);
        if (bdmWriteMemory(DPRAM_BASE, (unsigned char*) buf, ALIGN_MEM_SIZE) < 0) {
            if(stop_quiet)
                printf("K\n");
            else
                show_error("Writing block buffer");
        }
        if (verify_alignment() < 0) {
            failed = loop_failed = 1;
            if(!stop_quiet) {
                printf("\n");
                show_error("Verify long word write");
            }
        }
    }

    if (failed) {
        show_error("Alignment check");
    }
    printf("\n");
}