Exemplo n.º 1
0
void main(void)
{
/* USER CODE BEGIN (3) */

	// Some declarations
	unsigned int vol_num, num_trigs, trig_time, m, n;
	FILE *TMS_data_file;

	// Initialize some variables used in ISRs and initialize hardware state.
	irq_count = 0;
	train_count = 0;
	trig_in_train_count = 0;
	TMS_trig_in_progress = 0;

	// Read data from a file containing all the TMS delivery information.
    TMS_data_file = fopen("C:\\Users\\BIC\\workspace_v6_0\\Blinky\\TMS_trig_files\\TMS_trig_data","r");
    if(TMS_data_file == NULL){
      printf("\n Can't open TMS_trig_data \n");
      fflush(stdout);
      exit (1);
    }

    m = 0;
    while(fscanf(TMS_data_file, "%u %u", &vol_num, &num_trigs) != EOF){
      // Read the volume number for trigger train and the number of triggers in the train.
      TMS[m].trig_image_vol = vol_num;
      TMS[m].num_trigs_in_train = num_trigs;
      for(n=0; n<num_trigs; n++){
        fscanf(TMS_data_file, "%u", &trig_time);
        TMS[m].trig_time[n] = trig_time - TRIG_TO_TMS_PULSE_DELAY;  // Account for TMS unit delays. See TMS_scanner_synch.h
                                                                    // for more detail about this delay.

      }
      m = m + 1;
    }
    fclose(TMS_data_file);
    printf ("Ready to send triggers to TMS unit. \n");
    fflush(stdout);

	// Initialize rti, gio and associated hardware interrupts.
	rtiInit();
	gioInit();
	gioSetDirection(hetPORT1, 0xFFFFFFFF);

	/* The following line sets pins A0 and A2 of GIO PORTA to output and pin A7 of
    GIO PORTA to input. A0 is used for output to the TMS unit. A7 is used for input
	from the MRI TTL pulse. A2 controls an LED, used for testing, on the board. */
	gioSetDirection(gioPORTA, 0x00000005);

	rtiEnableNotification(rtiNOTIFICATION_COMPARE0);
	_enable_interrupt_();
	_enable_IRQ();

	// Start the rti counter.
	rtiStartCounter(rtiCOUNTER_BLOCK0);  // !!!!! Wont need this since I will be starting the counter in the gioNotification ISR
	                                     // and since the counter must be stopped before the reset done in the gioNotification ISR.

	// Initialize hardware state.
	gioSetPort(hetPORT1, 0x00000000); // Set output to D11 LED initially to low.

	// Initialize prescaler so that time units will be microseconds. Using 99 sets
	// the base frequency to 100th of the 100MHz operating frequency. See above
	// lines which set pulse_length and scanner_irq_to_gio_out_delay times.
	rtiREG1->CNT[0U].CPUCx = 99;
	//printf ("RTICPUC0: %d \n", rtiREG1->CNT[0U].CPUCx);

	while(1);

/* USER CODE END */
}
Exemplo n.º 2
0
void main(void)
{
/* USER CODE BEGIN (3) */
#if 1
    /** - Initialize LIN/SCI2 Routines to receive Command and transmit data */
    sciInit();

    UARTprintf("--> ITS SDCARD H/W Test V3.0<--\r\n ");
    UARTprintf("Type \'help\' for help.\r\n");
    UARTprintf("TI project modified for ITS. (Pradeepa) \r\n");

    /* Initialize RTI driver */
    rtiInit();
    /* Enable RTI Compare 3 interrupt notification */
    rtiEnableNotification(rtiNOTIFICATION_COMPARE3);
    /* Enable IRQ - Clear I flag in CPS register */
    _enable_IRQ();
    /* Start RTI Counter Block 1 */
    rtiStartCounter(rtiCOUNTER_BLOCK1);

    mmcSelectSpi(mibspiPORT5, mibspiREG5);  // SD card is on the SPI5

	safeti_SRAM_ECC_ERROR_FORCING_1BIT();
	safeti_SRAM_ECC_ERROR_FORCING_2BIT();
	safeti_FEE_ECC_DATA_CORR_MODE();
	safeti_FEE_ECC_TEST_MODE_1BIT();
	safeti_FEE_ECC_TEST_MODE_2BIT();
	safeti_FEE_ECC_SYN_REPORT_MODE();
	safeti_FEE_ECC_MALFUNCTION_MODE1();
	safeti_FEE_ECC_MALFUNCTION_MODE2();
	safeti_FLASH_ECC_ADDR_TAG_REG_MODE();
	safeti_FLASH_ECC_TEST_MODE_1BIT();
	safeti_FLASH_ECC_TEST_MODE_2BIT();
	safeti_PSCON_SELF_TEST();
	safeti_PSCON_ERROR_FORCING();
	safeti_PSCON_SELF_TEST_ERROR_FORCING();
	safeti_PSCON_PMA_TEST();
	safeti_EFUSE_SELF_TEST_STUCK_AT_ZERO();
	safeti_EFUSE_SELF_TEST_ECC();
	safeti_SRAM_RADECODE_DIAGNOSTICS();
	safeti_SRAM_PAR_ADDR_CTRL_SELF_TEST();
	safeti_SRAM_ECC_ERROR_PROFILING();
	safeti_FLASH_ADDRESS_PARITY_SELF_TEST();
	safeti_CCMR4F_SELF_TEST();
	safeti_CCMR4F_ERROR_FORCING_TEST();
	safeti_CCMR4F_SELF_TEST_ERROR_FORCING();

    SD_Test();

#endif

#if 0
uint16_t tx_buf = 5;
uint16_t rx_buf;



mibspiInit();
//while(!(mibspiIsTransferComplete(mibspiREG5, 0)));

mibspiPORT5-> DCLR = 0x00;
//mibspiEnableLoopback(mibspiREG5, Digital_Lbk);
mibspiSetData(mibspiREG5, 0, &tx_buf);

mibspiTransfer(mibspiREG5, 0);

while(!(mibspiIsTransferComplete(mibspiREG5, 0)));

mibspiGetData(mibspiREG5,0,&rx_buf);

mibspiPORT5-> DCLR = 0x01;
//mibspiEnableLoopback(mibspiREG5, Digital_Lbk);
mibspiSetData(mibspiREG5, 0, &tx_buf);

mibspiTransfer(mibspiREG5, 0);

while(!(mibspiIsTransferComplete(mibspiREG5, 0)));

mibspiGetData(mibspiREG5,0,&rx_buf);
#endif
    while(1);

/* USER CODE END */
}
// Delay for half a clock cycle (0.001ms)
void ckDelay(void)
{
	rtiStartCounter(rtiCOUNTER_BLOCK0);
	while(!rtiBreak);
	rtiBreak = false;
}