void main(void) { /* USER CODE BEGIN (3) */ /* Initialize sci for communication over USB */ sciInit(); sciSend(scilinREG,19,(unsigned char *)"CAN code start...\r\n"); printf("Code start...\r\n"); /* enable irq interrupt in Cortex R4 */ _enable_interrupt_(); /** - writing a random data in RAM - to transmit */ //dumpSomeData(); /** - configuring CAN1 MB1,Msg ID-1 to transmit and CAN2 MB1 to receive */ canInit(); /** - enabling error interrupts */ canEnableErrorNotification(canREG1); canEnableErrorNotification(canREG2); //while(1){}; /* wait forever after tx-rx complete. */ //ADC stuff adcInit(); adcData_t adc_data[16]; adcData_t *ptr = &adc_data[0]; int j; uint8 tx_data[D_COUNT][8]; uint8 *tx_ptr = &tx_data[0][0]; while(1) { for(j=0U;j<15000;j++){ adc_convert_all_channels(ptr); int i; for(i=0;i<sizeof(adc_data)/sizeof(adc_data[0]);i++) { can_transmit_recieve(canREG1, canMESSAGE_BOX1, &adc_data[i]); } } //for(i=0;i<sizeof(tx_data)/sizeof(tx_data[0]);i++) { // can_transmit_recieve(canREG1, canMESSAGE_BOX1, &tx_data[i]); //} } //exit(0); /* USER CODE END */ }
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 */ }