//***************************************************************************** // // USBLibDMAChannelEnable() for USB controllers that use uDMA. // //***************************************************************************** static void uDMAUSBChannelEnable(tUSBDMAInstance *psUSBDMAInst, uint32_t ui32Channel) { uint32_t ui32IntEnabled; // // Save if the interrupt was enabled or not. // ui32IntEnabled = IntIsEnabled(psUSBDMAInst->ui32IntNum); // // Disable the USB interrupt if it was enabled. // if(ui32IntEnabled) { OS_INT_DISABLE(psUSBDMAInst->ui32IntNum); } // // Mark this channel as pending and not complete. // psUSBDMAInst->ui32Pending |= (1 << (ui32Channel - 1)); psUSBDMAInst->ui32Complete &= ~(1 << (ui32Channel - 1)); // // Enable DMA for the endpoint. // if(UDMAConfigIsRx(psUSBDMAInst->pui32Config[ui32Channel - 1])) { MAP_USBEndpointDMAEnable(psUSBDMAInst->ui32Base, psUSBDMAInst->pui8Endpoint[ui32Channel - 1], USB_EP_DEV_OUT | USB_EP_HOST_IN); } else { MAP_USBEndpointDMAEnable(psUSBDMAInst->ui32Base, psUSBDMAInst->pui8Endpoint[ui32Channel - 1], USB_EP_DEV_IN | USB_EP_HOST_OUT); } // // Enable the DMA in the uDMA controller. // MAP_uDMAChannelEnable(ui32Channel - 1); // // Enable the USB interrupt if it was enabled before. // if(ui32IntEnabled) { OS_INT_ENABLE(psUSBDMAInst->ui32IntNum); } }
//***************************************************************************** // // USBLibDMAChannelEnable() for USB controllers with an integrated DMA // controller. // //***************************************************************************** static void iDMAUSBChannelEnable(tUSBDMAInstance *psUSBDMAInst, uint32_t ui32Channel) { uint32_t ui32IntEnabled; // // Save if the interrupt was enabled or not. // ui32IntEnabled = IntIsEnabled(psUSBDMAInst->ui32IntNum); // // Disable the USB interrupt if it was enabled. // if(ui32IntEnabled) { OS_INT_DISABLE(psUSBDMAInst->ui32IntNum); } // // Mark this channel as pending and not complete. // psUSBDMAInst->ui32Pending |= (1 << (ui32Channel - 1)); psUSBDMAInst->ui32Complete &= ~(1 << (ui32Channel - 1)); // // Enable the interrupt for this DMA channel. // USBDMAChannelIntEnable(psUSBDMAInst->ui32Base, ui32Channel - 1); // // Enable the DMA channel. // USBDMAChannelEnable(psUSBDMAInst->ui32Base, ui32Channel - 1); // // Enable the USB interrupt if it was enabled before. // if(ui32IntEnabled) { OS_INT_ENABLE(psUSBDMAInst->ui32IntNum); } }
int main(void) { // Status of Hibernation module uint32_t ui32Status = 0; // Length of time to hibernate uint32_t hibernationTime = 600; g_ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); //************************************************************************* //! I/O config and setup //************************************************************************* SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); // UART SysCtlPeripheralEnable(SYSCTL_PERIPH_UART7); // UART SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // UART0 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); // UART7 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); // SSI SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION); // GPIO SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2); // SSI SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK); // GPIO SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);// Hibernation // UART0 and UART7 GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PC4_U7RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinConfigure(GPIO_PC5_U7TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5); // LED indicators GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // SD Card Detect (PK3) and GPS Pulse Per Second (PK2) // GPIOPinTypeGPIOInput(GPIO_PORTK_BASE, GPIO_PIN_2|GPIO_PIN_3); // Pulse Per Second input pin config as weak pull-down GPIOPadConfigSet(GPIO_PORTK_BASE,GPIO_PIN_2,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPD); // Pulse Per Second input pin config as rising edge triggered interrupt GPIOIntTypeSet(GPIO_PORTK_BASE,GPIO_PIN_2,GPIO_RISING_EDGE); // Register Port K as interrupt GPIOIntRegister(GPIO_PORTK_BASE, PortKIntHandler); // Enable Port K pin 2 interrupt GPIOIntEnable(GPIO_PORTK_BASE, GPIO_INT_PIN_2); // // Disable PPS pin interrupt by default // if(IntIsEnabled(INT_GPIOK)) { IntDisable(INT_GPIOK); } GPIOPinConfigure(GPIO_PD0_SSI2XDAT1); GPIOPinConfigure(GPIO_PD1_SSI2XDAT0); GPIOPinConfigure(GPIO_PD2_SSI2FSS); GPIOPinConfigure(GPIO_PD3_SSI2CLK); // SD Card Detect (CD) - weak pull-up input GPIOPadConfigSet(GPIO_PORTK_BASE, GPIO_PIN_3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); // Debug UART output config UARTConfigSetExpClk(UART0_BASE, g_ui32SysClock, 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); // GPS UART input config UARTConfigSetExpClk(UART7_BASE, g_ui32SysClock, 9600, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); // // Configure SysTick for a 100Hz interrupt. // SysTickPeriodSet(g_ui32SysClock / 100); SysTickIntEnable(); SysTickEnable(); // // Floating point enable // FPUEnable(); FPULazyStackingEnable(); // // Clear user LEDs // GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0 | GPIO_PIN_1, 0x00); //************************************************************************* //! Hibernation mode checks and setup //************************************************************************* // // Check to see if Hibernation module is already active, which could mean // that the processor is waking from a hibernation. // if(HibernateIsActive()) { // // Read the status bits to see what caused the wake. Clear the wake // source so that the device can be put into hibernation again. // ui32Status = HibernateIntStatus(0); HibernateIntClear(ui32Status); // // Wake was due to RTC match. // if(ui32Status & HIBERNATE_INT_RTC_MATCH_0) { // // TODO: add IMU check // } // // Wake was due to the External Wake pin. // else if(ui32Status & HIBERNATE_INT_PIN_WAKE) { // // Switch off low power mode // lowPowerOn = 0; } } // // Configure Hibernate module clock. // HibernateEnableExpClk(g_ui32SysClock); // // If the wake was not due to the above sources, then it was a system // reset. // if(!(ui32Status & (HIBERNATE_INT_PIN_WAKE | HIBERNATE_INT_RTC_MATCH_0))) { // // Configure the module clock source. // HibernateClockConfig(HIBERNATE_OSC_LOWDRIVE); } // // Enable PPS for a single data log. Interrupt on next PPS logic high. // ppsDataLog(); // // Enable RTC mode. // HibernateRTCEnable(); // // Loop forever // while(1) { // // If low power mode is set (default), hibernate again // If not, spin in nested while(1) for faster updates from PPS pin ints. // if(lowPowerOn) { lowPowerMode(hibernationTime); } else { if(!IntIsEnabled(INT_GPIOK)) { IntEnable(INT_GPIOK); } while(1) { } } } } // End function main