void timer_init(void){ PRCMPowerDomainOn(PRCM_DOMAIN_PERIPH); PRCMLoadSet(); PRCMPeripheralSleepEnable(PRCM_PERIPH_TIMER2); PRCMLoadSet(); PRCMPeripheralDeepSleepEnable(PRCM_PERIPH_TIMER2); PRCMLoadSet(); PRCMPeripheralRunEnable(PRCM_PERIPH_TIMER2); PRCMLoadSet(); TimerDisable(GPT2_BASE, TIMER_BOTH); TimerConfigure(GPT2_BASE, TIMER_CFG_PERIODIC); TimerLoadSet(GPT2_BASE, TIMER_A, 48000000); TimerIntClear(GPT2_BASE, TIMER_TIMA_TIMEOUT); TimerIntEnable(GPT2_BASE, TIMER_TIMA_TIMEOUT); TimerEnable(GPT2_BASE, TIMER_A); }
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()){}; } }
/** * 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; }
/* * ======== 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)); }