예제 #1
0
void vLedTask(void *pvParameters)
{
	unsigned led    = 0;
	unsigned count  = 0;
	unsigned colour = 0;

	/* Initalise the IO ports that drive the LEDs */
	gioSetDirection(hetPORT, 0xFFFFFFFF);
	/* switch all leds off */
	gioSetPort(hetPORT, 0x08110034);

	for(;;)
	{
		/* toggle on/off */
		led ^= 1;
		/* switch TOP row */
		gioSetBit(hetPORT, 25, led);
		gioSetBit(hetPORT, 18, led);
		gioSetBit(hetPORT, 29, led);
		/* switch BOTTOM row */
		gioSetBit(hetPORT, 17, led ^ 1);
		gioSetBit(hetPORT, 31, led ^ 1);
		gioSetBit(hetPORT,  0, led ^ 1);
		vTaskDelay(500);

		if (++count > 5)
		{
			count = 0;
			/* both leds to off */
			gioSetBit(hetPORT, 2, 1);  gioSetBit(hetPORT,  5, 1);  gioSetBit(hetPORT, 20, 1);
			gioSetBit(hetPORT, 4, 1);  gioSetBit(hetPORT, 27, 1);  gioSetBit(hetPORT, 16, 1);
			switch(colour)
			{
			case 0:
				gioSetBit(hetPORT, 2, 0);  /* red */
				gioSetBit(hetPORT, 4, 0);
				colour++;
				continue;
			case 1:
				gioSetBit(hetPORT,  5, 0);  /* blue */
				gioSetBit(hetPORT, 27, 0);
				colour++;
				continue;
			case 2:
				gioSetBit(hetPORT, 20, 0);  /* green */
				gioSetBit(hetPORT, 16, 0);
				colour++;
				continue;
			}
			colour = 0;
		}
	}
}
예제 #2
0
void rtiNotification(uint32 notification)
{

    // Service the hardware interrupt according to whether the trigger (3.3V and 10 us) to the TMS has been initiated already or not.
	if(TMS_trig_in_progress == 0){

	   // Set the next timer hardware interupt to occur pulse_length (10 us) later (see case 2).
	   rtiREG1->CMP[0U].COMPx = rtiREG1->CNT[0U].CAFRCx + PULSE_LENGTH + TMS[train_count].trig_time[trig_in_train_count];

	   // Set 08 pin of NHET port to high. Turns D11 LED on. This is for trouble shooting only.
	   gioSetPort(hetPORT1, 0x00000100);

	   // Sets A0 pin of GIO PORTA to high. This is the pin for the trigger to the TMS unit.
	   gioSetPort(gioPORTA, 0x00000001);

	   // Set control flags
	   TMS_trig_in_progress = 1;

	} else {

	   // Set pin 08 of the NHET port to low to turn the Hercules board D11 LED off. For trouble shooting only.
	   gioSetPort(hetPORT1, 0x00000000);

	   // Set pin A0 of the GIO PORTA to low. This is the pin for the trigger to the TMS unit.
	   gioSetPort(gioPORTA, 0x00000000);

	   // Set the next timer hardware interupt to occur beginning the next trigger pulse to the TMS unit.
	   trig_in_train_count = trig_in_train_count + 1;
	   if(trig_in_train_count < TMS[train_count].num_trigs_in_train){
	     rtiREG1->CMP[0U].COMPx = rtiREG1->CNT[0U].CAFRCx + TMS[train_count].trig_time[trig_in_train_count];
	   } else {
		   train_count = train_count + 1;   // This counter is used as an index to step through the arrays
		   	                                // irq_to_trig_delay_array and trig_array.
		   trig_in_train_count = 0;
	   }

	   // Set control flag.
	   TMS_trig_in_progress = 0;
	}
}
예제 #3
0
void esmHighLevelInterrupt(void)
{
    /* too indicate we are in the ESM interrupt light up the BLUE leds */

    /* Initalise the IO ports that drive the LEDs */
    gioSetDirection(hetPORT, 0xFFFFFFFF);
    /* switch all leds off */
    gioSetPort(hetPORT, 0x08110034);
    /* switch on blue leds */
    gioSetBit(hetPORT,  5, 0);
    gioSetBit(hetPORT, 27, 0);

    for(;;);
}
예제 #4
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 */
}