Пример #1
0
Void Timer_enableCC26xx(Int id)
#endif
{
    UInt gpt = INVALID_TIMER_ID;

    /* map timer ID to the appropriate driverlib ID */
    switch (id) {
        case 0: gpt = PRCM_PERIPH_TIMER0;
                break;

        case 1: gpt = PRCM_PERIPH_TIMER1;
                break;

        case 2: gpt = PRCM_PERIPH_TIMER2;
                break;

        case 3: gpt = PRCM_PERIPH_TIMER3;
                break;

        default:
                break;
    }

    /* if a valid GPT timer ID, enable the GPT ... */
    if (gpt != INVALID_TIMER_ID) {

        /* if it is not already on, turn on the PERIPH domain */
        if (PRCMPowerDomainStatus(PRCM_DOMAIN_PERIPH) !=
            PRCM_DOMAIN_POWER_ON) {
            PRCMPowerDomainOn(PRCM_DOMAIN_PERIPH);
            while (PRCMPowerDomainStatus(PRCM_DOMAIN_PERIPH) !=
                PRCM_DOMAIN_POWER_ON) {};
        }

        /* now enable the GPT clocks */
        PRCMPeripheralRunEnable(gpt);
        PRCMPeripheralSleepEnable(gpt);
        PRCMPeripheralDeepSleepEnable(gpt);
        PRCMLoadSet();
        while(!PRCMLoadGet()){};
    }
}
Пример #2
0
/**
 * Function documented in platform/uart.h
 */
otError otPlatUartEnable(void)
{
    PRCMPowerDomainOn(PRCM_DOMAIN_SERIAL);

    while (PRCMPowerDomainStatus(PRCM_DOMAIN_SERIAL) != PRCM_DOMAIN_POWER_ON);

    PRCMPeripheralRunEnable(PRCM_PERIPH_UART0);
    PRCMPeripheralSleepEnable(PRCM_PERIPH_UART0);
    PRCMPeripheralDeepSleepEnable(PRCM_PERIPH_UART0);
    PRCMLoadSet();

    while (!PRCMLoadGet());

    IOCPinTypeUart(UART0_BASE, IOID_2, IOID_3, IOID_UNUSED, IOID_UNUSED);

    UARTConfigSetExpClk(UART0_BASE, SysCtrlClockGet(), 115200,
                        UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE);
    UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
    UARTIntRegister(UART0_BASE, UART0_intHandler);
    UARTEnable(UART0_BASE);
    return OT_ERROR_NONE;
}
Пример #3
0
/*
 *  ======== Power_shutdown ========
 */
Power_Status Power_shutdown(UArg arg)
{
    Power_Status status = Power_EFAIL;
    Bool exitNow = FALSE;
    UInt32 constraints;
    UInt hwiKey;

    /* make sure shutdown request doesn't violate a constraint */
    constraints = Power_getConstraintInfo();
    if ((constraints & (Power_SD_DISALLOW)) != 0) {
        status = Power_ECHANGE_NOT_ALLOWED;
    }

    if (status == Power_EFAIL) {

        /* make sure Power is not still busy with a previous transition */
        hwiKey = Hwi_disable();

        if (Power_module->state == Power_ACTIVE) {
            /* set new transition state to entering shutdown */
            Power_module->state = Power_SHUTDOWN;
        }
        else {
            exitNow = TRUE;
        }

        Hwi_restore(hwiKey);

        if (exitNow == TRUE) {
            status = Power_EBUSY;
        }

        else {

            /* disable interrupts as start the shutdown sequence */
            Hwi_disable();

            /* signal all clients registered for pre-shutdown notification */
            status = Power_notify(Power_ENTERING_SHUTDOWN);

            /* check for any error */
            if (status != Power_SOK) {
                Power_module->state = Power_ACTIVE;
                CPUcpsie();
                return (status);
            }

            /* proceed with shutdown sequence ... */

            /* switch to RCOSC_HF and RCOSC_LF */
            OSCInterfaceEnable();
            if(OSCClockSourceGet(OSC_SRC_CLK_HF) != OSC_RCOSC_HF) {
                OSCClockSourceSet(OSC_SRC_CLK_HF | OSC_SRC_CLK_MF,
                    OSC_RCOSC_HF);
                while(!OSCHfSourceReady());
                OSCHfSourceSwitch();
            }
            OSCClockSourceSet(OSC_SRC_CLK_LF,OSC_RCOSC_LF);
            while(OSCClockSourceGet(OSC_SRC_CLK_LF) != OSC_RCOSC_LF);
            OSCInterfaceDisable();

            /* make sure DMA and CRYTO clocks are off in deep-sleep */
            PRCMPeripheralDeepSleepDisable(PRCM_PERIPH_CRYPTO);
            PRCMPeripheralDeepSleepDisable(PRCM_PERIPH_UDMA);
            PRCMLoadSet();
            while(!PRCMLoadGet()){};

            /* power OFF AUX and disconnect from bus */
            AUXWUCPowerCtrl(AUX_WUC_POWER_OFF);

            /* remove AUX force ON */
            HWREG(AON_WUC_BASE + AON_WUC_O_AUXCTL) &=
                ~AON_WUC_AUXCTL_AUX_FORCE_ON;

            /*
             * reset AON event source IDs to avoid pending events powering
             * on MCU/AUX
             */
            HWREG(AON_EVENT_BASE + AON_EVENT_O_MCUWUSEL) = 0x3F3F3F3F;
            HWREG(AON_EVENT_BASE + AON_EVENT_O_AUXWUSEL) = 0x003F3F3F;

            /* sync AON */
            HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);

            /*
             * enable shutdown - this latches the IOs, so configuration of
             * IOCFGx registers must be done prior to this
             */
            AONWUCShutDownEnable();

            /* sync AON */
            HWREG(AON_RTC_BASE + AON_RTC_O_SYNC);

            /* wait until AUX powered off */
            while (AONWUCPowerStatusGet() & AONWUC_AUX_POWER_ON);

            /* request to power off MCU when go to deep sleep */
            PRCMMcuPowerOff();

            /* turn off power domains inside MCU VD (BUS, FL_BUS, RFC, CPU) */
            PRCMPowerDomainOff(PRCM_DOMAIN_RFCORE | PRCM_DOMAIN_SERIAL |
                PRCM_DOMAIN_PERIPH | PRCM_DOMAIN_CPU | PRCM_DOMAIN_VIMS);

            /* deep sleep to activate shutdown */
            PRCMDeepSleep();
        }
    }

    Power_module->state = Power_ACTIVE;

    /* if get here failed to shutdown, return failure code */
    return (Power_EFAIL);
}
Пример #4
0
/*
 *  ======== Power_setDependency ========
 *  Declare a dependency upon a resource.
 */
Bool Power_setDependency(Power_Resource resourceID)
{
    UInt8 parent;
    UInt8 count;
    UInt32 id;
    UInt key;

    /* disable interrupts */
    key = Hwi_disable();

    /* read and increment reference count */
    count = ti_sysbios_family_arm_cc26xx_Power_refCount[resourceID]++;

    /* if resource was NOT activated previously ... */
    if (count == 0) {

        /* propagate set up the dependency tree ... */

        /* check for a first parent */
        parent = ti_sysbios_family_arm_cc26xx_Power_db[resourceID].flags
          & PARENTMASK;

        /* if first parent, make recursive call to set that dependency */
        if (parent != NOPARENT) {
            Power_setDependency(parent);
        }

        /* check for a second parent */
        parent = ti_sysbios_family_arm_cc26xx_Power_db[resourceID].flags2
          & PARENTMASK;

        /* if second parent, make recursive call to set that dependency */
        if (parent != NOPARENT) {
            Power_setDependency(parent);
        }

        /* now activate this resource ... */
        id = ti_sysbios_family_arm_cc26xx_Power_db[resourceID].driverlibID;

        /* is resource a peripheral?... */
        if (ti_sysbios_family_arm_cc26xx_Power_db[resourceID].flags & PERIPH) {
            PRCMPeripheralRunEnable(id);
            PRCMPeripheralSleepEnable(id);
            PRCMPeripheralDeepSleepEnable(id);
            PRCMLoadSet();
            while(!PRCMLoadGet()){};
        }

        /* else, does resource require a special handler?... */
        else if (ti_sysbios_family_arm_cc26xx_Power_db[resourceID].flags
            & SPECIAL) {

            /* call the special handler */
            ti_sysbios_family_arm_cc26xx_Power_resourceHandlers[id](ENABLE);
        }

        /* else resource is a power domain */
        else {
            PRCMPowerDomainOn(id);
            while (PRCMPowerDomainStatus(id) != PRCM_DOMAIN_POWER_ON) {};
        }
    }

    /* re-enable interrupts */
    Hwi_restore(key);

    /* return the resource's activation status */
    return (ti_sysbios_family_arm_cc26xx_Power_isDependencyActive(resourceID));
}
Пример #5
0
/*
 *  ======== Power_releaseDependency ========
 *  Release a previously declared dependency.
 */
Void Power_releaseDependency(Power_Resource resourceID)
{
    UInt8 parent;
    UInt8 count;
    UInt32 id;
    UInt key;

    /* disable interrupts */
    key = Hwi_disable();

    /* read and decrement the reference count */
    count = ti_sysbios_family_arm_cc26xx_Power_refCount[resourceID];

    Assert_isTrue(count != 0, Power_A_tooManyCallsReleaseDependency);

    ti_sysbios_family_arm_cc26xx_Power_refCount[resourceID] = count - 1;

    /* if this was the last dependency being released.., */
    if (count == 1) {

        /* deactivate this resource ... */
        id = ti_sysbios_family_arm_cc26xx_Power_db[resourceID].driverlibID;

        /* is resource a peripheral?... */
        if (ti_sysbios_family_arm_cc26xx_Power_db[resourceID].flags
            & PERIPH) {
            PRCMPeripheralRunDisable(id);
            PRCMPeripheralSleepDisable(id);
            PRCMPeripheralDeepSleepDisable(id);
            PRCMLoadSet();
            while(!PRCMLoadGet()){};
        }

        /* else, does resource require a special handler?... */
        else if (ti_sysbios_family_arm_cc26xx_Power_db[resourceID].flags
            & SPECIAL) {

            /* call the special handler */
            ti_sysbios_family_arm_cc26xx_Power_resourceHandlers[id](DISABLE);
        }

        /* else resource is a power domain */
        else {
            PRCMPowerDomainOff(id);
            while (PRCMPowerDomainStatus(id) != PRCM_DOMAIN_POWER_OFF) {};
        }

        /* propagate release up the dependency tree ... */

        /* check for a first parent */
        parent = ti_sysbios_family_arm_cc26xx_Power_db[resourceID].flags
          & PARENTMASK;

        /* if 1st parent, make recursive call to release that dependency */
        if (parent != NOPARENT) {
            Power_releaseDependency(parent);
        }

        /* check for a second parent */
        parent = ti_sysbios_family_arm_cc26xx_Power_db[resourceID].flags2
          & PARENTMASK;

        /* if 2nd parent, make recursive call to release that dependency */
        if (parent != NOPARENT) {
            Power_releaseDependency(parent);
        }
    }

    /* re-enable interrupts */
    Hwi_restore(key);
}