コード例 #1
0
ファイル: attnsvc.C プロジェクト: AmesianX/hostboot
errlHndl_t Service::enableAttns()
{
    ATTN_SLOW("Service::enableAttns() enter");

    errlHndl_t err = configureInterrupts(UP);

    ATTN_SLOW("Service::enableAttns() exit");

    return err;
}
コード例 #2
0
ファイル: serialutil.c プロジェクト: DuinoPilot/cantranslator
void initializeSerial(SerialDevice* device) {
    if(device != NULL) {
        initializeSerialCommon(device);

        configurePins();
        configureUart();
        configureFifo();
        configureFlowControl();
        configureInterrupts();
        CTS_STATE = ACTIVE;
    }
}
コード例 #3
0
ファイル: attnsvc.C プロジェクト: rjknight/hostboot
errlHndl_t Service::stop()
{
    ATTN_SLOW("shutting down...");

    mutex_lock(&iv_mutex);

    tid_t intrTask = iv_intrTask;
    tid_t prdTask = iv_prdTask;

    msg_q_t q = iv_intrTaskQ;

    iv_intrTask = 0;
    iv_prdTask = 0;

    mutex_unlock(&iv_mutex);

    if(intrTask)
    {
        errlHndl_t err = configureInterrupts(q, DOWN);

        if(err)
        {
            errlCommit(err, ATTN_COMP_ID);
        }

        msg_t * shutdownMsg = msg_allocate();
        shutdownMsg->type = SHUTDOWN;

        msg_sendrecv(q, shutdownMsg);
        msg_free(shutdownMsg);

        task_wait_tid(intrTask, 0, 0);

        msg_q_destroy(q);
    }

    if(prdTask)
    {
        sync_cond_signal(&iv_cond);
        task_wait_tid(prdTask, 0, 0);
    }

    ATTN_SLOW("..shutdown complete");

    return 0;
}
コード例 #4
0
main()
{
    // Disable JTAG (on RA0 and RA1 )
    mJTAGPortEnable( DEBUG_JTAGPORT_OFF );

    // Configure the device for maximum performance but do not change the PBDIV
    // Given the options, this function will change the flash wait states, RAM
    // wait state and enable prefetch cache but will not change the PBDIV.
    // The PBDIV value is already set via the pragma FPBDIV option above..
    SYSTEMConfig(GetSystemClock(), SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);

    initializeUART();
    initializeADC();
    initializeLCD();
    initializeRPG();
    
    /* Initialize SD card */
    setup_SDSPI();
    SD_setStart();
    /* Fill tempBuffer[] with int 0 to 63
     * Write it to the current block.
     * Empty tempBuffer[] to all 0.
     * Read from the current block to make sure that it returns the right value.
     */
    fillTempBuffer();
    testSDReadWrite(tempBuffer);

    curr_read_block = curr_block;
    
    ConfigTimer1(); // Enable Timer1 for second counts
    configureInterrupts();

    // T2CON = 0x8030; // TMR1 on, prescale 1:256 PB

    mPORTASetPinsDigitalOut( LED_MASK ); // LEDs = output
    mPORTDSetPinsDigitalIn( PB_MASK_D ); // PBs on D = input

    curr_state = READY;
    // enable interrupts
    INTEnableInterrupts();
    int i = 0;
    while( 1 )
    {
        if (getPrintToUARTFlag() == 1){
            LCDMenuControl();
        
            //mPORTAToggleBits( LED_MASK );
            convertAndPrintIntegerToString("i => ", i++);
            convertAndPrintIntegerToString("timeElapse => ", timeElapsed);
            convertAndPrintIntegerToString("timeElapsedLEDSample => ", timeElapsedLEDSample);
            convertAndPrintIntegerToString("timeElapsedLEDTurnedOff => ", timeElapsedLEDTurnedOff);
            convertAndPrintIntegerToString("sampleLEDNow => ", sampleLEDNow);

            convertAndPrintIntegerToString(" ADC Value => ", getChannel5Value());
            printShadowDetect();
            printLightLevel();
            drawLightDetectedBar();
            controlPowerRelay();

            switch(curr_state) {
            case READY : WriteString("State => READY     ");
                        break;
            case SLEEP : WriteString("State => SLEEP    ");
                        break;
            case HIBERNATE : WriteString("State => HIBERNATE");
                        break;
            case BUSY : WriteString("State => BUSY     ");
                        break;
            }

            WriteString("\r");
            
            setPrintToUARTFlag(0);
        }
        if (NEW_BYTE_RECEIVED == 1){
            curr_state = READY;
            NEW_BYTE_RECEIVED = 0;
            //mPORTAToggleBits( LED_MASK );
            char tempArray[] = "g";
            tempArray[0] = characterByteReceived;
            WriteString(tempArray);
            if(curr_state = HIBERNATE) {
                addByteToBuffer(characterByteReceived);
            }
            else {
                PutCharacter(characterByteReceived);
            }
        }
        if(bufferIndex == 512) {
            SDWriteBlock(currBlock);
            currBlock++;
            bufferIndex = 0;
        }
         if((curr_state == READY) && (timeElapsed >= SLEEP_TIMEOUT) && (timeElapsed < HIBERNATE_TIMEOUT)) {
             curr_state = SLEEP;
         }
         else if((curr_state == SLEEP) && (timeElapsed >= HIBERNATE_TIMEOUT)) {
             curr_state = HIBERNATE;
             timeElapsed = 0;
         }
        if (transmitDataFromSDCard == 1) {
            transmitDataFromSDCard = 0;
            forwardDataToPrinter();
        }
    } // main (while) loop

    return 0;

} // main
コード例 #5
0
ファイル: attnsvc.C プロジェクト: rjknight/hostboot
errlHndl_t Service::start()
{
    errlHndl_t err = NULL;
    bool cleanStartup = false;

    ATTN_SLOW("starting...");

    mutex_lock(&iv_mutex);

    do {

        if(!iv_intrTaskQ) {

            // register msg q with interrupt
            // service for attention type interrupts

            msg_q_t q = msg_q_create();

            err = configureInterrupts(q, UP);

            if(err)
            {
                msg_q_destroy(q);
                break;
            }

            iv_intrTaskQ = q;
        }

        if(!startIntrTask())
        {
            break;
        }

        if(!startPrdTask())
        {
            break;
        }

        cleanStartup = true;

    } while(0);

    tid_t prd = iv_prdTask, intr = iv_intrTask;

    mutex_unlock(&iv_mutex);

    if(!cleanStartup)
    {
        errlHndl_t err2 = stop();

        if(err2)
        {
            errlCommit(err2, ATTN_COMP_ID);
        }
    }
    else
    {
        ATTN_SLOW("..startup complete, intr: %d, prd: %d", intr, prd);
    }

    return err;
}