Exemple #1
0
/*
 *  ======== idl0Fxn ========
 */
Void idl0Fxn()
{
    if (finishFlag) {
        System_printf("Calling BIOS_exit from idl0Fxn\n");   
        BIOS_exit(0);
    }
}
Exemple #2
0
/*
 *  ======== tsk0Fxn =======
 */
Void tsk0Fxn(UArg arg0, UArg arg1)
{
    UInt key;

    /* wait for swis to be posted from Clock function */
    Semaphore_pend(sem0, BIOS_WAIT_FOREVER);

    System_printf("Running tsk0Fxn\n");
         
    key = Swi_disable();        /* swis are disabled */
    Swi_inc(swi0);              /* swi0 trigger = 1 */
    Swi_inc(swi0);              /* swi0 trigger = 2 */
    Swi_restore(key);           /* swi0 runs */

    Swi_or(swi1, 0x100);        /* swi1 runs with trigger = 0x111 */

    Swi_andn(swi1, 0x1);        /* swi1 trigger = 0x10 */
    Swi_andn(swi1, 0x2);        /* swi1 runs with trigger = 0x00 */
        
    Swi_dec(swi1);              /* swi1 trigger = 2 */     
    Swi_dec(swi1);              /* swi1 trigger = 1 */
    Swi_dec(swi1);              /* swi1 runs with trigger = 0 */
        
    System_printf("Calling BIOS_exit\n");
    BIOS_exit(0);
}
Void myTaskFxn (UArg arg0, UArg arg1)
{
    AT45DB_Handle at45dbHandle;
    AT45DB_Transaction at45dbTransaction;

    /* Open AT45DB */
    at45dbHandle = AT45DB_open(0);
    if (at45dbHandle == NULL) {
        System_abort("Error opening AT45DB161D");
    }

    /* Initialize at45dbTransaction */
    at45dbTransaction.address.page = 0;
    at45dbTransaction.address.byte = 0;
    at45dbTransaction.data_size = PAGE_SIZE;
    at45dbTransaction.data = textarray;

    if(!AT45DB_pageWriteThroughBuffer(at45dbHandle, &at45dbTransaction) ) {
       System_printf("Page write unsuccessful");
    }
    /* set transaction data to read buffer */
    at45dbTransaction.data = readBuf;

    if(AT45DB_readMainMemoryPage(at45dbHandle, &at45dbTransaction) ) {
        /* Print contents of read buffer */
        System_printf("%s", readBuf);
    }
    else {
        System_printf("Page read unsuccessful");
    }
    /* Close At45DB */
    AT45DB_close(at45dbHandle);

    BIOS_exit(0);
}
Exemple #4
0
/*
 *  ======== tsk0_func ========
 *  Wait to be released then send an interrupt to the ARM processor
 */
Void tsk0_func(UArg arg0, UArg arg1)
{
    Int status;

    while (seq < NUMLOOPS) {
        /* Wait to be released by callback function */
        Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);

        System_printf("Received request #%d from ARM (lineId = 0)\n",
                      seq);

        status = Notify_sendEvent(armProcId, LINE_1, EVENTID, seq, TRUE);
        if (status < 0) {
            System_abort("sendEvent failed\n");
        }

        System_printf("Sent request #%d to ARM (lineId = 1)\n", seq);

        /* Wait to be released by the cbFxn posting the semaphore */
        Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
        
        System_printf("Received request #%d from ARM (lineId = 1)\n");

        /* Send an event to the ARM */
        status = Notify_sendEvent(armProcId, LINE_0, EVENTID, seq, TRUE);
        if (status < 0) {
            System_abort("sendEvent failed\n");
        }

        System_printf("Sent request #%d to ARM (lineId = 0)\n", seq);
    }

    System_printf("Test completed\n");
    BIOS_exit(0);
}
/*
 *  ======== exitApp ========
 *  Cleans up the SSL context and exits the application
 */
void exitApp(WOLFSSL_CTX* ctx) {
	if (ctx != NULL) {
		wolfSSL_CTX_free(ctx);
		wolfSSL_Cleanup();
	}

	BIOS_exit(-1);
}
Exemple #6
0
/*
 *  ======== exitApp ========
 *  Cleans up the SSL context and exits the application
 */
void exitApp(CYASSL_CTX* ctx) {
	if (ctx != NULL) {
		CyaSSL_CTX_free(ctx);
		CyaSSL_Cleanup();
	}

	BIOS_exit(-1);
}
Exemple #7
0
/*
 *  ======== testwolfcrypt ========
 *  Run the wolfcrypt test
 */
void testwolfcrypt(UArg arg0, UArg arg1)
{
    System_printf("Running wolfcrypt tests...\n");
    System_flush();
    wolfcrypt_test((void *)arg0);
    System_printf("Tests completed.\n");

    BIOS_exit(0);
}
Exemple #8
0
/*
 *  ======== clk1Fxn =======
 */
Void clk1Fxn(UArg arg0)
{
    UInt32 time;
    
    time = Clock_getTicks();
    System_printf("System time in clk1Fxn = %lu\n", (ULong)time);
    System_printf("Calling BIOS_exit() from clk1Fxn\n");
    BIOS_exit(0);
}       
Exemple #9
0
/*
 *  ======== idl0Fxn ========
 */
Void idl0Fxn()
{
    Log_info0("Entering idl0Fxn.");

    Semaphore_post(sem0);

    Log_info0("Exiting idl0Fxn.");

    BIOS_exit(0);
}
Exemple #10
0
/*
 *  ======== tsk0_func ========
 *  Sends an event to the remote processor then pends on a semaphore.
 *  The semaphore is posted by the callback function.
 */
Void tsk0_func(UArg arg0, UArg arg1)
{
    Int i = 1;
    Int status;
    
    if (MultiProc_self() == 0) {
        while (i <= NUMLOOPS) {
            /* Send an event to the remote processor */
            status = Notify_sendEvent(dstProc, INTERRUPT_LINE, EVENTID, i, 
                    TRUE);

            /* Continue until remote side is up */
            if (status < 0) {
                continue;
            }

            System_printf("tsk1_func: Sent request #%d to %s\n", seq,
                MultiProc_getName(dstProc));

            /* Wait to be released by the cbFxn posting the semaphore */
            Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);

            System_printf("tsk1_func: Received request #%d from %s\n", seq,
                MultiProc_getName(recvProcId));

            /* increment for remote iteration */
            i++;
        }
    }
    else {
        while (seq < NUMLOOPS) {
            /* wait forever on a semaphore, semaphore is posted in callback */
            Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);

            System_printf("tsk1_func: Received request #%d from %s\n", seq,
                MultiProc_getName(recvProcId));

            /* Send an event to the remote processor */
            status = Notify_sendEvent(dstProc, INTERRUPT_LINE, EVENTID, seq, 
                    TRUE);
            if (status < 0) {
                System_abort("sendEvent failed\n");
            }

            System_printf("tsk1_func: Sent request #%d to %s\n", seq,
                MultiProc_getName(dstProc));
        }
    }

    System_printf("Test completed\n");
    
    BIOS_exit(0);
}
/*
 *  ======== runBenchmarks ========
 *  Run the CyaSSL benchmark application
 */
void runBenchmarks(UArg arg0, UArg arg1)
{
    void *args = NULL;
    msTimer_init();

    System_printf("Running benchmarks...\n");
    System_flush();
    benchmark_test(args);
    System_printf("Benchmarks completed.\n");

    BIOS_exit(0);
}
/*
 *  ======== Task_processVitalTasks ========
 *  Call BIOS_exit() when last vitalTask exits or is
 *  deleted.
 */
Void Task_processVitalTaskFlag(Task_Object *tsk)
{
    UInt hwiKey;
    if (tsk->vitalTaskFlag == TRUE) {
        hwiKey = Hwi_disable();
        if (--Task_module->vitalTasks == 0) {
            Hwi_restore(hwiKey);
            BIOS_exit(0);
        }
        Hwi_restore(hwiKey);
    }
}
/*
 *  ======== main ========
 */
Int main()
{ 
    Task_Handle task;
    Error_Block eb;

    System_printf("enter main()\n");

    Error_init(&eb);
    task = Task_create(taskMstr, NULL, &eb);
    if (task == NULL) {
        System_printf("Task_create() failed!\n");
        BIOS_exit(0);
    }

    BIOS_start();    /* does not return */
    return(0);
}
/*
 *  ======== reader ========
 */
Void reader(UArg arg0, UArg arg1)
{
    MsgObj msg;
    UInt posted;

    for (;;) {
        /* wait for (Event_Id_00 & Event_Id_01) | Event_Id_02 */
        posted = Event_pend(evt, 
            Event_Id_00 + Event_Id_01,  /* andMask */
            Event_Id_02,                /* orMask */
            TIMEOUT);

        if (posted == 0) { 
            System_printf("Timeout expired for Event_pend()\n");
            break;
        }
       
        if ((posted & Event_Id_00) && (posted & Event_Id_01)) {
            if (Semaphore_pend(sem, BIOS_NO_WAIT)) {
                System_printf("Explicit posting of Event_Id_00 and Implicit posting of Event_Id_01\n");
            }
            else {
                System_printf("Semaphore not available. Test failed!\n");
            }
            break;
        }
        else if (posted & Event_Id_02) {
            System_printf("Implicit posting of Event_Id_02\n");
            if (Mailbox_pend(mbx, &msg, BIOS_NO_WAIT)) {
                /* print value */
                System_printf("read id = %d and val = '%c'.\n",msg.id, msg.val);
            }
            else {
                System_printf("Mailbox not available. Test failed!\n");
            }
        }
        else {
            System_printf("Unknown Event\n");
            break;
        }
    }
    BIOS_exit(0);
}
Exemple #15
0
/*
 *  ======== tsk0_func ========
 *  Send an interrupt to the DSP processor and wait on semaphore.
 */
Void tsk0_func(UArg arg0, UArg arg1)
{   
    Int   i = 1;
    Int status;    
    Int16 remoteProcId = MultiProc_getId("DSP");
    
    while (i <= NUMLOOPS) {
        /* Send an event to the DSP */
        status = Notify_sendEvent(dspProcId, LINE_0, EVENTID, i, TRUE);
        
        /* Continue until remote side is up */      
        if (status < 0) {
            continue;
        }
        
        System_printf("Sent request #%d to DSP (lineId = 0)\n", i);

        /* Wait to be released by the cbFxn posting the semaphore */
        Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
        
        System_printf("Received request #%d from DSP (lineId = 1)\n", seq);        
        
        /* Send an event to the DSP */
        status = Notify_sendEvent(dspProcId, LINE_1, EVENTID, i, TRUE);
        
        /* Continue until remote side is up */      
        if (status < 0) {
            continue;
        }

        System_printf("Sent request #%d to DSP (lineId = 1)\n", i);
        
        /* Wait to be released by the cbFxn posting the semaphore */
        Semaphore_pend(semHandle, BIOS_WAIT_FOREVER);
        System_printf("Received request #%d from DSP (lineId = 0)\n", seq);        
        
        /* increment for next iteration */
        i++;
    }
    System_printf("Test completed\n");
    BIOS_exit(0);
}
/*
 *  ======== main ========
 */
Int main()
{ 
    Task_Params taskParams;
    Error_Block eb;
    Memory_Stats stats;

    Error_init(&eb);
        
    /* Picking a stackSize such that the second Task_create() will fail */
    Memory_getStats(Memory_defaultHeapInstance, &stats);

    Task_Params_init(&taskParams);
    taskParams.priority = 1;
    taskParams.stackSize = (stats.totalFreeSize/2) + 64;

    /* 
     * Create two tasks, The first one succeeds and the second one fails
     * We catch the second failure in the Error_Block
     */
    tsk1 = Task_create(task1, &taskParams, &eb);
    
    if (Error_check(&eb)) {
        /* Should not get here */
        System_printf("First Task_create() failed\n");
        BIOS_exit(0);
    }
     
    Error_init(&eb);
    
    tsk2 = Task_create(task2, &taskParams, &eb);

    if (Error_check(&eb)) {
        /* Should get here */
        System_printf("Second Task_create() failed\n");
    }
   
    BIOS_start();    /* does not return */
    return(0);
}
Exemple #17
0
/*
 *  ======== tsk0_func ========
 *  Allocates a message and ping-pongs the message around the processors.
 *  A local message queue is created and a remote message queue is opened.
 *  Messages are sent to the remote message queue and retrieved from the
 *  local MessageQ.
 */
Void tsk0_func(UArg arg0, UArg arg1)
{
    MessageQ_Msg     msg;    
    MessageQ_Handle  messageQ;
    MessageQ_QueueId remoteQueueId;    
    Int              status;
    UInt16           msgId = 0;
    Ptr              buf;
    HeapBuf_Handle   heapHandle;
    HeapBuf_Params   hbparams;
    SizeT            blockSize;
    UInt             numBlocks;

    /* Compute the blockSize & numBlocks for the HeapBuf */
    numBlocks = 2;
    blockSize = sizeof(MessageQ_MsgHeader);

    /* Alloc a buffer from the default heap */
    buf = Memory_alloc(0, numBlocks * blockSize, 0, NULL);
    
    /* 
     *  Create the heap that is used for allocating MessageQ messages.
     */     
    HeapBuf_Params_init(&hbparams);
    hbparams.align          = 0;
    hbparams.numBlocks      = numBlocks;
    hbparams.blockSize      = blockSize;
    hbparams.bufSize        = numBlocks * blockSize;
    hbparams.buf            = buf;
    heapHandle = HeapBuf_create(&hbparams, NULL);
    if (heapHandle == NULL) {
        System_abort("HeapBuf_create failed\n" );
    }
        
    /* Register default system heap with MessageQ */
    MessageQ_registerHeap((IHeap_Handle)(heapHandle), HEAPID);

    /* Create the local message queue */
    messageQ = MessageQ_create(localQueueName, NULL);    
    if (messageQ == NULL) {
        System_abort("MessageQ_create failed\n" );
    }
    
    /* Open the remote message queue. Spin until it is ready. */
    do {
        status = MessageQ_open(remoteQueueName, &remoteQueueId); 
        /* 
         *  Sleep for 1 clock tick to avoid inundating remote processor
         *  with interrupts if open failed
         */
        if (status < 0) { 
            Task_sleep(1);
        }
    } while (status < 0);
    
    if (MultiProc_self() == 0) {
        /* Allocate a message to be ping-ponged around the processors */
        msg = MessageQ_alloc(HEAPID, sizeof(MessageQ_MsgHeader));
        if (msg == NULL) {
           System_abort("MessageQ_alloc failed\n" );
        }
        
        /* 
         *  Send the message to the remote processor and wait for a message
         *  from the previous processor.
         */
        System_printf("Start the main loop\n");
        while (msgId < NUMLOOPS) {
            /* Increment...the remote side will check this */
            msgId++;
            MessageQ_setMsgId(msg, msgId);
            
            System_printf("Sending a message #%d to %s\n", msgId, remoteQueueName);
            
            /* send the message to the remote processor */
            status = MessageQ_put(remoteQueueId, msg);
            if (status < 0) {
               System_abort("MessageQ_put had a failure/error\n");        
            }
            
            /* Get a message */
            status = MessageQ_get(messageQ, &msg, MessageQ_FOREVER);
            if (status < 0) {
               System_abort("This should not happen since timeout is forever\n");
            }
        }
    }
    else {
        /*
         *  Wait for a message from the previous processor and
         *  send it to the remote processor
         */
        System_printf("Start the main loop\n");
        while (TRUE) {
            /* Get a message */
            status = MessageQ_get(messageQ, &msg, MessageQ_FOREVER);
            if (status < 0) {
               System_abort("This should not happen since timeout is forever\n");
            }

            System_printf("Sending a message #%d to %s\n", MessageQ_getMsgId(msg),
                remoteQueueName);

            /* Get the message id */
            msgId = MessageQ_getMsgId(msg);

            /* send the message to the remote processor */
            status = MessageQ_put(remoteQueueId, msg);
            if (status < 0) {
               System_abort("MessageQ_put had a failure/error\n");
            }
            
            /* test done */
            if (msgId >= NUMLOOPS) {
                break;
            }
        }
    }
    
    System_printf("The test is complete\n");

    BIOS_exit(0);
}
Exemple #18
0
/*
 *  ======== tsk1_func ========
 *  A local message queue is created and two remote message queues are opened.
 *  Messages are sent to the remote message queues and retrieved from the
 *  local message queue.
 */
Void tsk1_func(UArg arg0, UArg arg1)
{
    MessageQ_Msg     msg;    
    MessageQ_Handle  messageQ;
    MessageQ_QueueId core1QueueId, dspQueueId;    
    Int              status;
    UInt16           msgId = 0;

    /* Create a message queue */
    messageQ = MessageQ_create(CORE0_MESSAGEQNAME, NULL); 
    if (messageQ == NULL) {
        System_abort("MessageQ_create failed\n" );
    }    
    
    /* Open the DSP message queue. Spin until it is ready. */
    do {
        status = MessageQ_open(DSP_MESSAGEQNAME, &dspQueueId);
        /* 
         *  Sleep for 1 clock tick to avoid inundating remote processor
         *  with interrupts if open failed
         */
        if (status < 0) {
            Task_sleep(1);
        }
    } while (status < 0);
    
    /* Open the CORE1 message queue. Spin until it is ready. */
    do {
        status = MessageQ_open(CORE1_MESSAGEQNAME, &core1QueueId);
        /* 
         *  Sleep for 1 clock tick to avoid inundating remote processor
         *  with interrupts if open failed
         */
        if (status < 0) {
            Task_sleep(1);
        }
    } while (status < 0);
    
    /* Allocate a message to be ping-ponged around the processors */
    msg = MessageQ_alloc(HEAPID, HEAP_MSGSIZE);
    if (msg == NULL) {
       System_abort("MessageQ_alloc failed\n" );
    }
    
    /* Send the message to the DSP and wait for a response */
    System_printf("Start the main loop\n");
    while (msgId < NUMLOOPS) {     
        /* Increment...the remote side will check this */
        msgId++;
        MessageQ_setMsgId(msg, msgId);
        
        System_printf("Sending a message #%d to CORE1\n", msgId);
        
        /* send the message to the remote processor */
        status = MessageQ_put(core1QueueId, msg);
        if (status < 0) {
            System_abort("MessageQ_put had an error\n");           
        }        
        
        /* Get a message */
        status = MessageQ_get(messageQ, &msg, MessageQ_FOREVER);
        if (status < 0) {
           System_abort("This should not happen since timeout is forever\n");           
        }
        
        System_printf("Sending a message #%d to DSP\n", msgId);

        status = MessageQ_put(dspQueueId, msg);
        if (status < 0) {
            System_abort("MessageQ_put had an error\n");    
        }   

        /* Get another message */
        status = MessageQ_get(messageQ, &msg, MessageQ_FOREVER);
        if (status < 0) {
           System_abort("This should not happen since timeout is forever\n");
        }
    }

    System_printf("The test is complete\n");
    BIOS_exit(0);
}
/*
 *  ======== taskFxn ========
 *  Task to perform a file copy
 *
 *  Task tries to open an existing file inputfile[]. If the file doesn't
 *  exist, create one and write some known content into it.
 *  The contents of the inputfile[] are then copied to an output file
 *  outputfile[]. Once completed, the contents of the output file are
 *  printed onto the system console (stdout).
 *
 *  Task for this function is created statically. See the project's .cfg file.
 */
Void taskFxn(UArg arg0, UArg arg1)
{
    SDSPI_Handle sdspiHandle;
    SDSPI_Params sdspiParams;
    USBMSCHFatFs_Handle usbmschfatfsHandle;
    USBMSCHFatFs_Params usbmschfatfsParams;

    /* Variables for the CIO functions */
    FILE *src, *dst;

    /* Variables to keep track of the file copy progress */
    unsigned int bytesRead = 0;
    unsigned int bytesWritten = 0;
    unsigned int filesize;
    unsigned int totalBytesCopied = 0;

    /* Mount and register the USB Drive */
    SDSPI_Params_init(&sdspiParams);
    sdspiHandle = SDSPI_open(Board_SDSPI0, SD_DRIVE_NUM, &sdspiParams);
    if (sdspiHandle == NULL) {
        System_abort("Error starting the SD card\n");
    }
    else {
        System_printf("Drive %u is mounted\n", SD_DRIVE_NUM);
    }

    /* Mount and register the USB Drive */
    USBMSCHFatFs_Params_init(&usbmschfatfsParams);
    usbmschfatfsParams.serviceTaskStackPtr = usbServiceTaskStack;
    usbmschfatfsParams.serviceTaskStackSize = sizeof(usbServiceTaskStack);
    usbmschfatfsHandle = USBMSCHFatFs_open(Board_USBMSCHFatFs0,
                                           USB_DRIVE_NUM,
                                          &usbmschfatfsParams);
    if (usbmschfatfsHandle == NULL) {
        System_abort("Error starting the USB Drive\n");
    }
    else {
        System_printf("Drive %u is mounted\n", USB_DRIVE_NUM);
    }

    /* Need to block until a USB Drive has been enumerated */
    if (!USBMSCHFatFs_waitForConnect(usbmschfatfsHandle, 10000)) {
        System_abort("No USB drive present, aborting...\n");
    }

    /* Try to open the source file */
    src = fopen(inputfilesd, "r");
    if (!src) {
        System_printf("Creating a new file \"%s\"...", inputfilesd);

        /* Open file for both reading and writing */
        src = fopen(inputfilesd, "w+");
        if ( !src ) {
            System_printf("Error: \"%s\" could not be created.\n"
                          "Please check the Getting Started Guide "
                          "if additional jumpers are necessary.\n",
                          inputfilesd);
            System_abort("Aborting...\n");
        }

        fwrite(textarray, 1, strlen(textarray), src);
        fflush(src);

        /* Reset the internal file pointer */
        rewind(src);

        System_printf("done\n");
    }
    else {
        System_printf("Using existing copy of \"%s\"\n", inputfilesd);
    }

    /* Create a new file object for the file copy */
    dst = fopen(outputfileusb, "w");
    if (!dst) {
        System_printf("Error opening \"%s\"\n", outputfileusb);
        System_abort("Aborting...\n");
    }
    else {
        System_printf("Starting file copy\n");
    }

    /*  Copy the contents from the src to the dst */
    while (true) {
        /*  Read from source file */
        bytesRead = fread(cpy_buff, 1, CPY_BUFF_SIZE, src);
        if (bytesRead == 0) {
            break; /* Error or EOF */
        }

        /*  Write to dst file */
        bytesWritten = fwrite(cpy_buff, 1, bytesRead, dst);
        if (bytesWritten < bytesRead) {
            System_printf("Disk Full\n");
            break; /* Error or Disk Full */
        }

        /*  Update the total number of bytes copied */
        totalBytesCopied += bytesWritten;
    }

    fflush(dst);

    /* Get the filesize of the source file */
    fseek(src, 0, SEEK_END);
    filesize = ftell(src);
    rewind(src);

    /* Close both inputfile[] and outputfile[] */
    fclose(src);
    fclose(dst);

    System_printf("File \"%s\" (%u B) copied to \"%s\" (Wrote %u B)\n",
                  inputfilesd, filesize, outputfileusb, totalBytesCopied);

    /* Now output the outputfile[] contents onto the console */
    dst = fopen(outputfileusb, "r");
    if (!dst) {
        System_printf("Error opening \"%s\"\n", outputfileusb);
        System_abort("Aborting...\n");
    }

    /* Print file contents */
    while (true) {
        /* Read from output file */
        bytesRead = fread(cpy_buff, 1, CPY_BUFF_SIZE, dst);
        if (bytesRead == 0) {
            break; /* Error or EOF */
        }
        /* Write output */
        System_printf("%s", cpy_buff);
    }

    /* Close the file */
    fclose(dst);

    /* Stopping the SDCard */
    SDSPI_close(sdspiHandle);
    System_printf("Drive %u unmounted\n", SD_DRIVE_NUM);

    /* Stopping the USB Drive */
    USBMSCHFatFs_close(usbmschfatfsHandle);
    System_printf("Drive %u unmounted\n", USB_DRIVE_NUM);

    BIOS_exit(0);
}
Exemple #20
0
/*
 *  ======== tsk0_func ========
 *  Allocates a message and ping-pongs the message around the processors.
 *  A local message queue is created and a remote message queue is opened.
 *  Messages are sent to the remote message queue and retrieved from the
 *  local MessageQ.
 */
Void tsk0_func(UArg arg0, UArg arg1)
{
    MessageQ_Msg     msg;    
    MessageQ_Handle  messageQ;
    MessageQ_QueueId remoteQueueId;    
    Int              status;
    UInt16           msgId = 0;
    HeapBufMP_Handle              heapHandle;
    HeapBufMP_Params              heapBufParams;

    if (MultiProc_self() == 0) {
        /* 
         *  Create the heap that will be used to allocate messages.
         */     
        HeapBufMP_Params_init(&heapBufParams);
        heapBufParams.regionId       = 0;
        heapBufParams.name           = HEAP_NAME;
        heapBufParams.numBlocks      = 1;
        heapBufParams.blockSize      = sizeof(MessageQ_MsgHeader);
        heapHandle = HeapBufMP_create(&heapBufParams);
        if (heapHandle == NULL) {
            System_abort("HeapBufMP_create failed\n" );
        }
    }
    else {
        /* Open the heap created by the other processor. Loop until opened. */
        do {
            status = HeapBufMP_open(HEAP_NAME, &heapHandle);
            /* 
             *  Sleep for 1 clock tick to avoid inundating remote processor
             *  with interrupts if open failed
             */
            if (status < 0) { 
                Task_sleep(1);
            }
        } while (status < 0);
    }
    
    /* Register this heap with MessageQ */
    MessageQ_registerHeap((IHeap_Handle)heapHandle, HEAPID);

    /* Create the local message queue */
    messageQ = MessageQ_create(localQueueName, NULL);    
    if (messageQ == NULL) {
        System_abort("MessageQ_create failed\n" );
    }
    
    /* Open the remote message queue. Spin until it is ready. */
    do {
        status = MessageQ_open(nextQueueName, &remoteQueueId); 
        /* 
         *  Sleep for 1 clock tick to avoid inundating remote processor
         *  with interrupts if open failed
         */
        if (status < 0) { 
            Task_sleep(1);
        }
    } while (status < 0);
    
    if (MultiProc_self() == 0) {
        /* Allocate a message to be ping-ponged around the processors */
        msg = MessageQ_alloc(HEAPID, sizeof(MessageQ_MsgHeader));
        if (msg == NULL) {
           System_abort("MessageQ_alloc failed\n" );
        }
        
        /* 
         *  Send the message to the next processor and wait for a message
         *  from the previous processor.
         */
        System_printf("Start the main loop\n");
        while (msgId < NUMLOOPS) {     
            /* Increment...the remote side will check this */
            msgId++;
            MessageQ_setMsgId(msg, msgId);
            
            System_printf("Sending a message #%d to %s\n", msgId, nextQueueName);
            
            /* send the message to the remote processor */
            status = MessageQ_put(remoteQueueId, msg);
            if (status < 0) {
               System_abort("MessageQ_put had a failure/error\n");        
            }        
            
            /* Get a message */
            status = MessageQ_get(messageQ, &msg, MessageQ_FOREVER);
            if (status < 0) {
               System_abort("This should not happen since timeout is forever\n");
            }
        }
    }
    else {
        /*
         *  Wait for a message from the previous processor and
         *  send it to the next processor
         */
        System_printf("Start the main loop\n");
        while (TRUE) {
            /* Get a message */
            status = MessageQ_get(messageQ, &msg, MessageQ_FOREVER);
            if (status < 0) {
               System_abort("This should not happen since timeout is forever\n");
            }

            System_printf("Sending a message #%d to %s\n", MessageQ_getMsgId(msg),
                nextQueueName);

            /* Get the message id */
            msgId = MessageQ_getMsgId(msg);

            /* send the message to the remote processor */
            status = MessageQ_put(remoteQueueId, msg);
            if (status < 0) {
               System_abort("MessageQ_put had a failure/error\n");
            }
            
            /* test done */
            if (msgId >= NUMLOOPS) {
                break;
            }
        }
    }
    
    System_printf("The test is complete\n");
    BIOS_exit(0);
}
Exemple #21
0
/******************************************************************************
 * TASK FUNCTION
 *****************************************************************************/
void task_fxn(UArg arg0, UArg arg1){
	Int 				status;
	Int 				coreCount;
	Int 				nextCore;
	MessageQ_Msg 		msg;
	MessageQ_QueueId 	msgQueueIds[MAX_NUM_CORES];

	/* Register this heap with the Message Q */
	MessageQ_registerHeap((IHeap_Handle)SharedRegion_getHeap(0), HEAP_ID);

/*
 * In order to send messages to other cores, we must know that core's Queue
 * ID.  So, we'll create an array on each core that associates the Queue ID
 * with the core number, and then we'll open each queue.  Again, we spin
 * here until the queue is open, sleeping for one tick after every attempt.
 */
	for (coreCount = 0; coreCount < MAX_NUM_CORES; coreCount++){
		System_sprintf(remoteQueueName, "%s", MultiProc_getName(coreCount));
		do {
			status = MessageQ_open(remoteQueueName, &msgQueueIds[coreCount]);
			if (status < 0){
				Task_sleep(1);
			}
		}while (status < 0);
	}


	/*
	 * At this point, our application is ready to begin sending messages using
	 * Message Queue.  The core with the number TOKEN_START_CORE has the
	 * responsibility of sending the first message.  So, we'll handle that in
	 * this block.
	 */
	if (selfId == TOKEN_START_CORE){

		/*
		 * Allocate the initial message.  If the message is not properly
		 * allocated, we must abort
		 */

		/*
		 * TODO: IPC #1 - Allocate Memory for Token Message
		 * Add core below that ALLOCATES the memory for the token message.
		 * We've already declared the variable msg to hold the pointer to
		 * this message.  The code to check if the pointer is NULL is
		 * already included.
		 */
		msg = MessageQ_alloc(HEAP_ID, sizeof(myMsg));

		if (msg == NULL){
			System_abort("MessageQ_alloc failed\n");
		}

		/*
		 * Now randomly select the next processor to send the.  This function
		 * simply selects a random core number and ensures it's not the same as
		 * the current core number.
		 */
		nextCore = findNextCore(selfId);

		/*
		 * Set the Initial Token Count in the message, and specify that the
		 * message type is MSG_TOKEN
		 */
		((myMsg*)msg)->tokenCount = 1;
		((myMsg*)msg)->messageType = MSG_TOKEN;

		/*
		 * We can also set a reply queue so that the core can acknowledge this
		 * message without having to know which core it came from.
		 */
		MessageQ_setReplyQueue(messageQ, msg);

		/*
		 * Now we actually send the message to the next core that we've chosen.
		 */

		/* TODO: IPC #2 - Pass the token to the destination core
		 * Add the code to send the message to the destination core.  This is
		 * done by putting the message in the destination core's queue.  Don't
		 * forget that the ID of the destination core's queue is stored at
		 * element "nextCore" in the array msgQueueIds, and is NOT the same
		 * as the core number.
		 */
		status = MessageQ_put(msgQueueIds[nextCore], msg);

	}

	while (TRUE){
		msgType messageType;
		MessageQ_Msg ack;
		MessageQ_QueueId ackQueueId;
		Int currentTokenCount;

		/* TODO: IPC #3 - Get a Message from the local queue.
		 * Take the message from the local queue and store it in the variable
		 * message.  The function call return value should be stored in the
		 * variable status.  Hint: The parameters passed to this function
		 * specify a time out size.  We want to configure this call to
		 * never time out, and block eternally until a message is received.
		 */
		status = MessageQ_get(messageQ, &msg, MessageQ_FOREVER);

		if (status < 0){
			System_abort("This should not occur since the timeout is forever\n");
		}

		/*
		 * Read the Message Type from the received message, along with the current
		 * token count.
		 */
		messageType = ((myMsg*)msg)->messageType;
		currentTokenCount = ((myMsg*)msg)->tokenCount;

		/*
		 * Now, check what type of message it is and take action.  Here are the
		 * actions to be taken.
		 *
		 * MSG_TOKEN
		 * 	- Acknowledge that token is received to sending core.
		 * 	- If token count is less than MAX_MESSAGES
		 * 		- Increment the token count.
		 * 		- Forward the token on to the next random core
		 *	- If token count is equal to MAX Messages
		 *		- Free the Token message.
		 *		- Send a Done Message to all other cores.
		 *		- Break out of the infinite loop.
		 *
		 * MSG_ACK
		 * 	- Free the Ack message
		 * MSG_DONE
		 *  - Free the Done Message
		 *  - Break Out of infinite loop
		 */
		switch (messageType){
		case MSG_TOKEN:
			System_printf("Token Received - Count = %d\n", currentTokenCount);

			/*
			 * TODO: IPC #4 - Get the Reply Queue for the token
			 * Store the ID of the reply queue in the variable ackQueueId.
			 * This function allows us to not have to figure out which core
			 * sent this message.  This is the analogous function to the
			 * MessageQ_setReplyQueue() function that was set before the
			 * message was sent.  This data is stored in the MessageQ_MsgHeader
			 * element that's included with the message
			 */
			ackQueueId = MessageQ_getReplyQueue(msg);

			/*
			 * TODO: IPC #5 - Allocate the acknowledge message
			 * Allocate the acknowledge message and store the pointer to it
			 * in the variable ack.
			 */
			ack = MessageQ_alloc(HEAP_ID, sizeof(myMsg));

			// Set the Message Type of the new Message to MSG_ACK
			if (ack==NULL){
				System_abort("MessageQ Alloc Failed\n");
			}

			// Set the Message Type of the new Message to MSG_ACK
			((myMsg*)ack)->messageType = MSG_ACK;

			/*
			 * TODO: IPC #6 - Send the Acknowledge message
			 * Don't forget that we've already stored the reply queue ID in
			 * ackQueueId above.
			 */
			status = MessageQ_put(ackQueueId, ack);

			/*
			 * Now handle the actions required by the status of the message. First
			 * we must check to see if we're at the Token Passing limit.  So we'll
			 * compare the current Token count with MAX_MESSAGES.
			 */

			/*
			 * If the current token count is the max, then we must free the current
			 * message and then allocate new DONE messages to be sent to the other
			 * cores.
			 */
			if (currentTokenCount == NUM_MESSAGES){
				/*
				 * TODO: IPC #7 - Free the memory used by the token message
				 * Don't forget that the pointer to this memory is in the
				 * variable msg.
				 */
				MessageQ_free(msg);

				/*
				 * Now allocate and send ALL cores a DONE message.  We don't need to
				 * worry about special handling of the current core.  It will just
				 * send itself a DONE message and handle it just as the other cores
				 * do
				 */
				/*
				 * TODO: IPC #8 - Note that this core will send itself a message.
				 * There's nothing to be added here.  just note that this
				 * routine is blindly sending done messages to all of the cores
				 * and not taking into account it's own core number.  So, this
				 * core will send one of these messages to itself.
				 */
				for (coreCount =0; coreCount < MAX_NUM_CORES; coreCount++){
					msg = MessageQ_alloc(HEAP_ID, sizeof(myMsg));
					if (msg == NULL){
						System_abort("MessageQ Alloc Failed\n");
					}

					// Set the Message Type to MSG_DONE
					((myMsg*)msg)->messageType = MSG_DONE;

					// Now send it to the selected core
					status = MessageQ_put(msgQueueIds[coreCount], msg);
				}
				break;
			}

			/*
			 * If we're not at the last message, then we must increment the
			 * tokenCount and pass the message on to a random core.  Don't
			 * forget to set the reply queue so we can get an acknowledge.
			 */
			nextCore = findNextCore(selfId);
			((myMsg*)msg)->tokenCount = currentTokenCount + 1;

			/*
			 * TODO: IPC #9- Set the reply queue for the token message.
			 * We need to be sure to set the reply queue each time.
			 * Otherwise, the wrong core will receive the acknowledge.
			 */
			MessageQ_setReplyQueue(messageQ, msg);

			// Put the message on the proper queue
			status = MessageQ_put(msgQueueIds[nextCore], msg);

			break;
		case MSG_ACK:
			System_printf("Ack Received\n");
			/*
			 * All we need to do in this case is free the Ack message
			 */
			MessageQ_free(msg);
			break;
		case MSG_DONE:
			System_printf("Done Received\n");
			/*
			 * If we receive the Done message we just need to free the message, and
			 * then exit SYS/BIOS because the application is complete.
			 */
			MessageQ_free(msg);
			BIOS_exit(0);
			break;
		default:
			System_printf("Invalid Message Type Received\n");
			return;
		}


	}
}
Exemple #22
0
Void tsk0_func(UArg arg0, UArg arg1) {

	switch (MultiProc_self()) {
#ifdef CORE0
	case 0:
		core0();
		break;
#endif

#ifdef CORE1
	case 1:
		core1();
		break;
#endif

#ifdef CORE2
	case 2:
		core2();
		break;
#endif

#ifdef CORE3
	case 3:
		core3();
		break;
#endif

#ifdef CORE4
	case 4:
		core4();
		break;
#endif

#ifdef CORE5
	case 5:
		core5();
		break;
#endif

#ifdef CORE6
	case 6:
		core6();
		break;
#endif

#ifdef CORE7
	case 7:
		core7();
		break;
#endif
	default:
		communicationInit();
		while (1) {
			busy_barrier();
		}
		//break;
	}

	System_printf("The test is complete\n");
	BIOS_exit(0);
}
Exemple #23
0
/*
 *  ======== tsk1_func ========
 *  Send and receive messages
 */
Void tsk1_func(UArg arg0, UArg arg1)
{
    MessageQ_Msg     msg;    
    MessageQ_Handle  messageQ;
    MessageQ_QueueId remoteQueueId;
    HeapBufMP_Handle heapHandle;
    Int              status;
    UInt16           msgId;

    /* 
     *  Open the heap that is created on the other processor. Loop until opened.
     *  Not using the name since the interrupts are not enabled yet!
     */
    do {
        status = HeapBufMP_open(HEAP_NAME, &heapHandle);
        /* 
         *  Sleep for 1 clock tick to avoid inundating remote processor
         *  with interrupts if open failed
         */
        if (status < 0) {
            Task_sleep(1);
        }
    } while (status < 0);

    /* Register this heap with MessageQ */
    MessageQ_registerHeap((IHeap_Handle)heapHandle, HEAPID);

    /* Create a local message queue */
    messageQ = MessageQ_create(DSP_MESSAGEQNAME, NULL);    
    if (messageQ == NULL) {
        System_abort("MessageQ_create failed\n" );
    }    
    
    /* Open the core0 message queue. Spin until it is ready. */
    do {
        status = MessageQ_open(CORE0_MESSAGEQNAME, &remoteQueueId);  
        /* 
         *  Sleep for 1 clock tick to avoid inundating remote processor
         *  with interrupts if open failed
         */
        if (status < 0) { 
            Task_sleep(1);
        }        
    } while (status < 0);

    /* Wait for a message and send it to core0 */
    System_printf("Start the main loop\n");
    while (TRUE) {
        /* Get a message */
        status = MessageQ_get(messageQ, &msg, MessageQ_FOREVER);
        if (status < 0) {
           System_abort("This should not happen since timeout is forever\n");
        }

        System_printf("Sending a message #%d to CORE0\n", MessageQ_getMsgId(msg));

        /* Get the message id */
        msgId = MessageQ_getMsgId(msg);

        /* send the message to the remote processor */
        status = MessageQ_put(remoteQueueId, msg);
        if (status < 0) {
           System_abort("MessageQ_put had a failure/error\n");
        }
        
        /* test done */
        if (msgId == NUMLOOPS) {
            System_printf("Test complete!\n");
            BIOS_exit(0);
        }
    }
}
Exemple #24
0
/*
 *  ======== idl0Fxn ========
 */
Void idl0Fxn()
{
    BIOS_exit(0);
}
Exemple #25
0
/*
 *  ======== taskFxn ========
 *  Task to perform a file copy
 *
 *  Task tries to open an existing file inputfile[]. If the file doesn't
 *  exist, create one and write some known content into it.
 *  The contents of the inputfile[] are then copied to an output file
 *  outputfile[]. Once completed, the contents of the output file are
 *  printed onto the system console (stdout).
 *
 *  Task for this function is created statically. See the project's .cfg file.
 */
Void taskFxn(UArg arg0, UArg arg1)
{
    FRESULT fresult;
    SDSPI_Handle sdspiHandle;
    SDSPI_Params sdspiParams;

    /* Variables to keep track of the file copy progress */
    unsigned int bytesRead = 0;
    unsigned int bytesWritten = 0;
    unsigned int filesize;
    unsigned int totalBytesCopied = 0;

    /* Mount and register the SD Card */
    SDSPI_Params_init(&sdspiParams);
    sdspiHandle = SDSPI_open(Board_SDSPI0, DRIVE_NUM, &sdspiParams);
    if (sdspiHandle == NULL) {
        System_abort("Error starting the SD card\n");
    }
    else {
        System_printf("Drive %u is mounted\n", DRIVE_NUM);
    }

    printDrive(STR(DRIVE_NUM), &(dst.fs));

    /* Try to open the source file */
    fresult = f_open(&src, inputfile, FA_READ);
    if (fresult != FR_OK) {
        System_printf("Creating a new file \"%s\"...", inputfile);

        /* Open file for both reading and writing */
        fresult = f_open(&src, inputfile, FA_CREATE_NEW|FA_READ|FA_WRITE);
        if (fresult != FR_OK) {
            System_printf("Error: \"%s\" could not be created.\n"
                          "Please check the Getting Started Guide "
                          "if additional jumpers are necessary.\n",
                          inputfile);
            System_abort("Aborting...\n");
        }

        f_write(&src, textarray, strlen(textarray), &bytesWritten);
        f_sync(&src);

        /* Reset the internal file pointer */
        f_lseek(&src, 0);

        System_printf("done\n");
    }
    else {
        System_printf("Using existing copy of \"%s\"\n", inputfile);
    }

    /* Create a new file object for the file copy */
    fresult = f_open(&dst, outputfile, FA_CREATE_ALWAYS|FA_WRITE);
    if (fresult != FR_OK) {
        System_printf("Error opening \"%s\"\n", outputfile);
        System_abort("Aborting...\n");
    }
    else {
        System_printf("Starting file copy\n");
    }

    /*  Copy the contents from the src to the dst */
    while (true) {
        /*  Read from source file */
        fresult = f_read(&src, cpy_buff, CPY_BUFF_SIZE, &bytesRead);
        if (fresult || bytesRead == 0) {
            break; /* Error or EOF */
        }

        /*  Write to dst file */
        fresult = f_write(&dst, cpy_buff, bytesRead, &bytesWritten);
        if (fresult || bytesWritten < bytesRead) {
            System_printf("Disk Full\n");
            break; /* Error or Disk Full */
        }

        /*  Update the total number of bytes copied */
        totalBytesCopied += bytesWritten;
    }

    f_sync(&dst);

    /* Get the filesize of the source file */
    filesize = f_size(&src);

    /* Close both inputfile[] and outputfile[] */
    f_close(&src);
    f_close(&dst);

    System_printf("File \"%s\" (%u B) copied to \"%s\" (Wrote %u B)\n",
                  inputfile, filesize, outputfile, totalBytesCopied);

    /* Now output the outputfile[] contents onto the console */
    fresult = f_open(&dst, outputfile, FA_READ);
    if (fresult != FR_OK) {
        System_printf("Error opening \"%s\"\n", outputfile);
        System_abort("Aborting...\n");
    }

    /* Print file contents */
    while (true) {
        /* Read from output file */
        fresult = f_read(&dst, cpy_buff, CPY_BUFF_SIZE, &bytesRead);
        if (fresult || bytesRead == 0) {
            break; /* Error or EOF */
        }
        cpy_buff[bytesRead] = '\0';
        /* Write output */
        System_printf("%s", cpy_buff);
        System_flush();
    }

    /* Close the file */
    f_close(&dst);

    printDrive(STR(DRIVE_NUM), &(dst.fs));

    /* Stopping the SDCard */
    SDSPI_close(sdspiHandle);
    System_printf("Drive %u unmounted\n", DRIVE_NUM);

    BIOS_exit(0);
}
Exemple #26
0
/*
 *  ======== clientTask ========
 */
Void clientTask(UArg arg0, UArg arg1)
{
    MessageQ_Handle  messageQ;
    MessageQ_QueueId serverQueue;
    MessageQ_Msg     msg;
    UInt16           msgId = arg0;
    Int              status;
    Int              i;

    /*
     *  Create client's MessageQ.
     *
     *  Use 'NULL' for name since no since this queueId is passed by
     *  referene and no one opens it by name. 
     *  Use 'NULL' for params to get default parameters.
     */
    messageQ = MessageQ_create(NULL, NULL);
    if (messageQ == NULL) {
        System_abort("Failed to create MessageQ\n");
    }

    /* Open the server's MessageQ */
    do {
        status = MessageQ_open(SERVERNAME, &serverQueue);
        if (status < 0) {
            Task_sleep(1);  /* give server a chance to create queue */ 
        }
    }
    while (status < 0);
    
    msg = MessageQ_alloc(HEAPID, sizeof(MessageQ_MsgHeader));
    if (msg == NULL) {
        System_abort("MessageQ_alloc failed\n" );
    }
    
    /* Have the remote processor reply to this message queue */
    MessageQ_setReplyQueue(messageQ, msg);

    /* Loop requesting information from the server task */
    System_printf("Client #%d is starting to send requests\n", arg0);
    for (i = 0; i < NUMMSGS; i++) {        

        /* Server will increment and send back */
        MessageQ_setMsgId(msg, msgId);
        msgId += NUMCLIENTS;       

        /* Send the message off */
        status = MessageQ_put(serverQueue, msg);
        if (status < 0) {            
            MessageQ_free(msg);
            System_abort("MessageQ_put failed\n");
        }

        /* Wait for the reply... */
        status = MessageQ_get(messageQ, &msg, MessageQ_FOREVER);
        if (status < 0) {
            System_abort("MessageQ_get had an error\n");
        }

        /* Validate the returned message. */
        if (MessageQ_getMsgId(msg) != msgId) {
            System_abort("Unexpected value\n");
        }

        System_printf("Client #%d received response #%d\n", arg0, i + 1);

        /* To make some variation in the execution order */
        Task_sleep(500 * (arg0 + 1));
    }
    
    System_printf("Client #%d is done sending requests\n", arg0);
    
    numCompleted++;
    if (numCompleted == 3) {
        /* All client tasks are done sending requests */
        BIOS_exit(0);
    }



}
Exemple #27
0
Void uartFxn(UArg arg0, UArg arg1)
{
    int8_t input[] = "               ";

    LcdObj lcd_message;
    int index = 0;
    for(index = 0; index < 15; index++) {
    	lcd_message.buffer[index] = ' ';
    }
    lcd_message.position = 1;

    UART_Handle uart;
    UART_Params uartParams;

    /* Create a UART with data processing off. */
    UART_Params_init(&uartParams);
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readReturnMode = UART_RETURN_FULL;
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.baudRate = 9600;
    uart = UART_open(Board_UART0, &uartParams);

    if (uart == NULL) {
        System_abort("Error opening the UART");
    }

    Semaphore_pend(start_data_semaphore, BIOS_WAIT_FOREVER);	// wait on button semaphore

    //send this char for handshaking with PC
    int8_t prompt = 65;

    UART_write(uart, &prompt, 1);

    int total_x = 0;
    int total_y = 0;
    int total_z = 0;

    int average_x = 0;
    int average_y = 0;
    int average_z = 0;

    int counter = 0;

    int rx = 0;

    while (1) {

      UART_read(uart, &input, 2);

      if(input[0] == '$' && input[1] == '$') {
        P2OUT &= ~BIT1;
        P1OUT |= BIT0;
        BIOS_exit(1);
      }
      rx = (int)input[1];

      if(input[0] == '-') {
        rx = 0 - rx; 
      }

      total_x = total_x + rx;

      UART_read(uart, &input, 2);

      if(input[0] == '$' && input[1] == '$') {
        P2OUT &= ~BIT1;
        P1OUT |= BIT0;
        BIOS_exit(1);
      }
      rx = (int)input[1];

      if(input[0] == '-') {
        rx = 0 - rx; 
      }

      total_y = total_y + rx;

      UART_read(uart, &input, 2);

      if(input[0] == '$' && input[1] == '$') {
        P2OUT &= ~BIT1;
        P1OUT |= BIT0;
        BIOS_exit(1);
      }
      rx = (int)input[1];

      if(input[0] == '-') {
        rx = 0 - rx; 
      }

      total_z = total_z + rx;
      /*
      if((counter % 3) == 0) {
      total_x = total_x + rx;
      } else if ((counter % 3) == 1) {
      total_y = total_y + rx;
      } else {
      total_z = total_z + rx;
      }*/

      counter++;

      if(counter > 50) {


          average_x = total_x/counter;
          average_y = total_y/counter;
          average_z = total_z/counter;
          combine_ints_to_string(average_x, average_y, average_z, 15,lcd_message.buffer);
          counter = 0;
          total_x = 0;
          total_y = 0;
          total_z = 0;

          lcd_message.position = 1;
          Mailbox_post(LCD_Mbx, &lcd_message, BIOS_WAIT_FOREVER);
      }
        MAP_Interrupt_enableInterrupt(INT_ADC14);
  }
}