/*****************************************************************************
 * Main function.
 * 
 * Initializes hardware and software. Then enters the endless foreground loop.
 * 
 *****************************************************************************/
int main(void) 
{
    // Disable interrupts
    cli();

	// Set port B as an output and turn off all LEDs
	DDRB = 0xFF;
	PORTB = 0xFF;

    /* Initialize the Timer 0 */
    ISR_InitTimer0();
#if !defined (SLOW_SINE)
	ISR_InitTimer1();
#endif

	// Initialize serial I/O
	SCIInitialize();

   	// Initialize SPI port
	InitDtoA();

	// Initialize the sine wave
	initSine();
	
    /* Enable interrupts. Do as last initialization, so interrupts are
     * not initiated until all of initialization is complete. */
   sei();

   for (; ; )		/* Foreground loops forever */
   {   // Do slow tasks here
      
   }   /* end of endless loop */

   return 0;
}
Esempio n. 2
0
// TODO : faire ça un peu mieux.. notamment desallouer correctement les ressources en cas d'erreur (voir bouquin sur les drivers pour faire ça bien)
int sci_init(void) {
  sci_query_adapter_t query;
  sci_error_t retval;
  
  // initialize the SCI environment 
  SCIInitialize(NO_FLAGS, &retval);
  if (retval != SCI_ERR_OK) {
    log_message("erreur SCIInitialize\n");
    log_message("%s\n",Sci_error(retval));
    return ERROR;
  }

  // détermine le node_id SCI du PC sur lequel s'exécute ce démon
  query.localAdapterNo = 0;
  query.subcommand = SCI_Q_ADAPTER_NODEID;
  query.data = &smdsv.THIS_NODE_ID;
  SCIQuery(SCI_Q_ADAPTER,&query,NO_FLAGS,&retval);
  if (retval != SCI_ERR_OK) {
    log_message("erreur SCIQuery\n");
    log_message("%s\n",Sci_error(retval));
    return ERROR;
  }  

  log_message("n° SCI du noeud local (THIS_NODE) = %d\n", smdsv.THIS_NODE_ID);
  
    
  return SUCCESS;
}
bool  
SCI_Transporter::initSCI() { 
  DBUG_ENTER("SCI_Transporter::initSCI");
  if(!init){ 
    sci_error_t error; 
    // Initialize SISCI library 
    SCIInitialize(0, &error); 
    if(error != SCI_ERR_OK)  { 
      DBUG_PRINT("error", ("Cannot initialize SISCI library."));
      DBUG_PRINT("error",
      ("Inconsistency between SISCI library and SISCI driver. Error code 0x%x",
      error)); 
      DBUG_RETURN(false);
    } 
    init = true; 
  } 
  DBUG_RETURN(true);
} 
Esempio n. 4
0
int main(int argc,char *argv[])
{

    int counter; 

    printf("\n %s compiled %s : %s\n\n",argv[0],__DATE__,__TIME__);
    
    if (argc<3) {
        Usage();
        exit(-1);
    }


    /* Get the parameters */
    for (counter=1; counter<argc; counter++) {

        if (!strcmp("-rn",argv[counter])) {
	  //            remoteNodeId = strtol(argv[counter+1],(char **) NULL,10);
            continue;
        } 

        if (!strcmp("-size",argv[counter])) {
            segmentSize = strtol(argv[counter+1],(char **) NULL,10);
            continue;
        } 

        if (!strcmp("-adapterno",argv[counter])) {
            localAdapterNo = strtol(argv[counter+1],(char **) NULL,10);
            continue;
        }

        if (!strcmp("-client",argv[counter])) {
            client = 1;
            continue;
        }

        if (!strcmp("-server",argv[counter])) {
            server = 1;
            continue;
        }

        if (!strcmp("-help",argv[counter])) {
            Usage();
            exit(0);
        }
    }

    //    if (remoteNodeId == 0) {
    //   fprintf(stderr,"Remote node-id is not specified. Use -rn <remote node-id>\n");
    //  exit(-1);
    //}

    if (server == 0 && client == 0) {
        fprintf(stderr,"You must specify a client node or a server node\n");
        exit(-1);
    }

    if (server == 1 && client == 1) {
        fprintf(stderr,"Both server node and client node is selected.\n"); 
        fprintf(stderr,"You must specify either a client or a server node\n");
        exit(-1);
    }


    /* Initialize the SISCI library */
    SCIInitialize(NO_FLAGS, &error);
    if (error != SCI_ERR_OK) {
        fprintf(stderr,"SCIInitialize failed - Error code: 0x%x\n",error);
        exit(error);
    }


    /* Open a file descriptor */
    SCIOpen(&sdOne,NO_FLAGS,&error);
    if (error != SCI_ERR_OK) {
        if (error == SCI_ERR_INCONSISTENT_VERSIONS) {
            fprintf(stderr,"Version mismatch between SISCI user library and SISCI driver\n");
        }
        fprintf(stderr,"SCIOpen failed - Error code 0x%x\n",error);
        exit(error); 
    }

    /* Open a file descriptor */
    SCIOpen(&sdTwo,NO_FLAGS,&error);
    if (error != SCI_ERR_OK) {
        if (error == SCI_ERR_INCONSISTENT_VERSIONS) {
            fprintf(stderr,"Version mismatch between SISCI user library and SISCI driver\n");
        }
        fprintf(stderr,"SCIOpen failed - Error code 0x%x\n",error);
        exit(error); 
    }


    /* Get local node-id */
    error = GetLocalNodeId(localAdapterNo, &localNodeId1);
    error = GetLocalNodeId(standbyAdapterNo, &localNodeId2);
    if (error != SCI_ERR_OK) {
      fprintf(stderr,"Could not find the local adapter %d\n", localAdapterNo);
      SCIClose(sdOne,NO_FLAGS,&error);
      SCIClose(sdTwo,NO_FLAGS,&error);
      exit(-1);
    }
    

    /* Print parameters */
    PrintParameters();

    if (client) {
      remoteNodeId1=324;
      remoteNodeId2=328;
        ShmemClientNode();
    } else {
         remoteNodeId1=452;
	 remoteNodeId2=456;
        ShmemServerNode();
    }

    /* Close the file descriptor */
    SCIClose(sdOne,NO_FLAGS,&error);
    SCIClose(sdTwo,NO_FLAGS,&error);
    if (error != SCI_ERR_OK) {
        fprintf(stderr,"SCIClose failed - Error code: 0x%x\n",error);
    }


    /* Free allocated resources */
    SCITerminate();

    return SCI_ERR_OK;
}