Пример #1
0
void i2c_0_init()
{
    
 //enable I2C module 0
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
 
    //reset module
    ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_I2C0);
     
    //enable GPIO peripheral that contains I2C 0
    // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
 
    // Configure the pin muxing for I2C0 functions on port B2 and B3.
    ROM_GPIOPinConfigure(GPIO_PIN_2);
    ROM_GPIOPinConfigure(GPIO_PIN_3);
     
    // Select the I2C function for these pins.
    GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
    GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
 
    // Enable and initialize the I2C0 master module.  Use the system clock for
    // the I2C0 module.  The last parameter sets the I2C data transfer rate.
    // If false the data rate is set to 100kbps and if true the data rate will
    // be set to 400kbps.
    ROM_I2CMasterInitExpClk(I2C0_BASE, SysCtlClockGet(), true);
     
    //clear I2C FIFOs
    // HWREG(I2C0_BASE + I2C_O_FIFOCTL) = 80008000;
}
void initialize_network_hardware() {
	initDMA();

	EthernetIntRegister(ETH_BASE, EthernetISR);

	/* Enable/Reset the Ethernet Controller */
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ETH);
	ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_ETH);

	ROM_EthernetIntDisable(ETH_BASE,
			(ETH_INT_PHY | ETH_INT_MDIO | ETH_INT_RXER | ETH_INT_RXOF | ETH_INT_TX | ETH_INT_TXER | ETH_INT_RX));

	/* Clear any interrupts that were already pending. */
	unsigned long temp = ROM_EthernetIntStatus(ETH_BASE, 0);
	ROM_EthernetIntClear(ETH_BASE, temp);

	/* Initialise the MAC and connect. */
	EthernetInit(ETH_BASE);
	ROM_EthernetConfigSet(ETH_BASE, (ETH_CFG_TX_DPLXEN | ETH_CFG_TX_CRCEN | ETH_CFG_TX_PADEN | ETH_CFG_RX_AMULEN));

	setMACAddress();

	ROM_EthernetEnable(ETH_BASE);
	ROM_IntEnable(INT_ETH);
	ROM_EthernetIntEnable(ETH_BASE, ETH_INT_RX);
}
Пример #3
0
void TwoWire::forceStop(void) {

    //force a stop to release the bus
    ROM_GPIOPinTypeGPIOOutput(g_uli2cBase[i2cModule],
                              g_uli2cSCLPins[i2cModule] | g_uli2cSDAPins[i2cModule]);
    ROM_GPIOPinWrite(g_uli2cBase[i2cModule], g_uli2cSDAPins[i2cModule], 0);
    ROM_GPIOPinWrite(g_uli2cBase[i2cModule],
                     g_uli2cSCLPins[i2cModule], g_uli2cSCLPins[i2cModule]);
    ROM_GPIOPinWrite(g_uli2cBase[i2cModule],
                     g_uli2cSDAPins[i2cModule], g_uli2cSDAPins[i2cModule]);

    ROM_GPIOPinTypeI2C(g_uli2cBase[i2cModule], g_uli2cSDAPins[i2cModule]);
    ROM_GPIOPinTypeI2CSCL(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule]);
    //reset I2C controller
    //without resetting the I2C controller, the I2C module will
    //bring the bus back to it's erroneous state
    ROM_SysCtlPeripheralReset(g_uli2cPeriph[i2cModule]);
    while(!ROM_SysCtlPeripheralReady(g_uli2cPeriph[i2cModule]));
    ROM_I2CMasterInitExpClk(MASTER_BASE, F_CPU, speedMode);//Bus speed

    if(speedMode==I2C_SPEED_FASTMODE_PLUS)//Force 1Mhz
    {
        uint32_t ui32TPR = ((F_CPU + (2 * 10 * 1000000l) - 1) / (2 * 10 * 1000000l)) - 1;
        HWREG(MASTER_BASE + I2C_O_MTPR) = ui32TPR;
    }
}
Пример #4
0
int wolfSSL_TI_CCMInit(void)
{
    if (ccm_init)
        return true;
    ccm_init = true;

#ifndef TI_DUMMY_BUILD
    SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                       SYSCTL_OSC_MAIN |
                                       SYSCTL_USE_PLL |
                                       SYSCTL_CFG_VCO_480), 120000000);

    if (!ROM_SysCtlPeripheralPresent(SYSCTL_PERIPH_CCM0))
        return false;

         ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_CCM0);
    WAIT(ROM_SysCtlPeripheralReady(SYSCTL_PERIPH_CCM0));
         ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_CCM0);
    WAIT(ROM_SysCtlPeripheralReady(SYSCTL_PERIPH_CCM0));

#ifndef SINGLE_THREADED
    if (wc_InitMutex(&TI_CCM_Mutex))
        return false;
#endif
#endif /* !TI_DUMMY_BUILD */

    return true;
}
Пример #5
0
// * svm_init *****************************************************************
// * setup pins and PWM hardware to talk to servomotors                       *
// * Assumes system clock already configured                                  *
// ****************************************************************************
void svm_init(void)
{
  ROM_SysCtlPeripheralEnable(SVM_OUTPUT_PORT);            // enable clock to GPIO port
  ROM_SysCtlPeripheralReset(SVM_OUTPUT_PORT);             // reset to clear any previous config
                                                          // configure output pads 
  GPIOPinTypeGPIOOutput(SVM_OUTPUT_PORT_BASE, SVM_OUTPUT_PINS);
  
                                                          // configure PWM
  ROM_SysCtlPeripheralEnable(SVM_PWM_MODULE);             // enable clock to pwm module
  ROM_SysCtlPWMClockSet(SVM_PWM_FPWM_DIV);                // configure clock divider to derive Fpwm from Fsys
                                                          // wrap 16b PWM counter at 1041 for 3kHz pwm output
  ROM_PWMDeadBandDisable(SVM_PWM_BASE, SVM_PWM_GEN);      // allow PWM0, PWM1 to behave independently
  ROM_PWMGenConfigure(SVM_PWM_BASE, SVM_PWM_GEN,          // configure pwm generator
                      PWM_GEN_MODE_DOWN |                 // up/down count for center timed PWM
                      PWM_GEN_MODE_NO_SYNC);              // outputs from generator behave independently
  ROM_PWMGenPeriodSet(SVM_PWM_BASE, SVM_PWM_GEN,          // sets period for generator to appropriate period
                      SVM_PWM_PERIOD_TICKS);
  ROM_PWMPulseWidthSet(SVM_PWM_BASE, SVM_1_PWM, 0);       // set initial pulse widths to 0 for safety
  ROM_PWMPulseWidthSet(SVM_PWM_BASE, SVM_2_PWM, 0);       // set initial pulse widths to 0 for safety
  
  ROM_GPIOPinConfigure(SVM_1_PWM_MUX);                    // select mux for pwm output hbridge 1
  ROM_GPIOPinConfigure(SVM_2_PWM_MUX);                    // select mux for pwm output hbridge 2
  ROM_GPIOPinTypePWM(SVM_OUTPUT_PORT_BASE, SVM_1_PWM_PIN);// do some other step configuring pwm...
  ROM_GPIOPinTypePWM(SVM_OUTPUT_PORT_BASE, SVM_2_PWM_PIN);// ...exact function is unknown
  
  ROM_PWMOutputState(SVM_PWM_BASE, SVM_1_PWM_BIT | SVM_2_PWM_BIT, true);
                                                          // enable outputs from pwm generator to pins
  ROM_PWMGenEnable(SVM_PWM_BASE, SVM_PWM_GEN);            // enable pwm output generator
}
Пример #6
0
//*****************************************************************************
//
// Initialize the ADC inputs used by the game pad device.  This example uses
// the ADC pins on Port E pins 1, 2, and 3(AIN0-2).
//
//*****************************************************************************
void
ADCInit(void)
{
    int32_t ui32Chan;

    //
    // Enable the GPIOs and the ADC used by this example.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOE);

    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
    ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_ADC0);

    //
    // Select the external reference for greatest accuracy.
    //
    ROM_ADCReferenceSet(ADC0_BASE, ADC_REF_EXT_3V);

    //
    // Configure the pins which are used as analog inputs.
    //
    ROM_GPIOPinTypeADC(GPIO_PORTE_AHB_BASE, GPIO_PIN_3 | GPIO_PIN_2 |
                       GPIO_PIN_1);

    //
    // Configure the sequencer for 3 steps.
    //
    for(ui32Chan = 0; ui32Chan < 2; ui32Chan++)
    {
        //
        // Configure the sequence step
        //
        ROM_ADCSequenceStepConfigure(ADC0_BASE, 0, ui32Chan, ui32Chan);
    }

    ROM_ADCSequenceStepConfigure(ADC0_BASE, 0, 2, ADC_CTL_CH2 | ADC_CTL_IE |
                                 ADC_CTL_END);
    //
    // Enable the sequence but do not start it yet.
    //
    ROM_ADCSequenceEnable(ADC0_BASE, 0);
}
Пример #7
0
void TwoWire::forceStop(void) {

    //force a stop to release the bus
    ROM_GPIOPinTypeGPIOOutput(g_uli2cBase[i2cModule],
                              g_uli2cSCLPins[i2cModule] | g_uli2cSDAPins[i2cModule]);
    ROM_GPIOPinWrite(g_uli2cBase[i2cModule], g_uli2cSDAPins[i2cModule], 0);
    ROM_GPIOPinWrite(g_uli2cBase[i2cModule],
                     g_uli2cSCLPins[i2cModule], g_uli2cSCLPins[i2cModule]);
    ROM_GPIOPinWrite(g_uli2cBase[i2cModule],
                     g_uli2cSDAPins[i2cModule], g_uli2cSDAPins[i2cModule]);

    ROM_GPIOPinTypeI2C(g_uli2cBase[i2cModule], g_uli2cSDAPins[i2cModule]);
    ROM_GPIOPinTypeI2CSCL(g_uli2cBase[i2cModule], g_uli2cSCLPins[i2cModule]);
    //reset I2C controller
    //without resetting the I2C controller, the I2C module will
    //bring the bus back to it's erroneous state
    ROM_SysCtlPeripheralReset(g_uli2cPeriph[i2cModule]);
    while(!ROM_SysCtlPeripheralReady(g_uli2cPeriph[i2cModule]));
    ROM_I2CMasterInitExpClk(MASTER_BASE, F_CPU, false);
}
Пример #8
0
static void tm4c123_i2c_reset(void)
{
    uint32_t speed, tpr;

    ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_I2C3);

    /*
     * speed = SystemCoreClock / (20 * (1 + TPR))
     * TPR = (SystemCoreClock / (20 * speed)) - 1;
     */

    speed = 400000;

    tpr = (SystemCoreClock / (20 * speed)) - 1;

    /* Enable I2C3 */
    I2C3->MCR  = I2C_MCR_MFE;
    I2C3->MTPR = tpr;
    I2C3->MIMR = I2C_MIMR_IM;
    I2C3->MICR = (I2C_MICR_CLKIC | I2C_MICR_IC);
}
Пример #9
0
//*****************************************************************************
//
// Initialize the AES and CCM modules.
//
//*****************************************************************************
bool
AESInit(void)
{
    uint32_t ui32Loop;

    //
    // Check that the CCM peripheral is present.
    //
    if(!ROM_SysCtlPeripheralPresent(SYSCTL_PERIPH_CCM0))
    {
        UARTprintf("No CCM peripheral found!\n");

        //
        // Return failure.
        //
        return(false);
    }

    //
    // The hardware is available, enable it.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_CCM0);

    //
    // Wait for the peripheral to be ready.
    //
    ui32Loop = 0;
    while(!ROM_SysCtlPeripheralReady(SYSCTL_PERIPH_CCM0))
    {
        //
        // Increment our poll counter.
        //
        ui32Loop++;

        if(ui32Loop > CCM_LOOP_TIMEOUT)
        {
            //
            // Timed out, notify and spin.
            //
            UARTprintf("Time out on CCM ready after enable.\n");

            //
            // Return failure.
            //
            return(false);
        }
    }

    //
    // Reset the peripheral to ensure we are starting from a known condition.
    //
    ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_CCM0);

    //
    // Wait for the peripheral to be ready again.
    //
    ui32Loop = 0;
    while(!ROM_SysCtlPeripheralReady(SYSCTL_PERIPH_CCM0))
    {
        //
        // Increment our poll counter.
        //
        ui32Loop++;

        if(ui32Loop > CCM_LOOP_TIMEOUT)
        {
            //
            // Timed out, spin.
            //
            UARTprintf("Time out on CCM ready after reset.\n");

            //
            // Return failure.
            //
            return(false);
        }
    }

    //
    // Return initialization success.
    //
    return(true);
}
Пример #10
0
//*****************************************************************************
//
// This is the main application entry function.
//
//*****************************************************************************
int
main(void)
{
    uint32_t ui32TxCount;
    uint32_t ui32RxCount;
    //uint32_t ui32Loop;

    //
    // Enable lazy stacking for interrupt handlers.  This allows floating-point
    // instructions to be used within interrupt handlers, but at the expense of
    // extra stack usage.
    //
    ROM_FPULazyStackingEnable();

    //
    // Set the clocking to run from the PLL at 50MHz
    //
#if 1
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                       SYSCTL_XTAL_16MHZ);

    //
    // Configure the required pins for USB operation.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    ROM_GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_5 | GPIO_PIN_4);
       //ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / 100);

    /* This code taken from: http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/t/311237.aspx
    */
#else       
#include "hw_nvic.h"
       FlashErase(0x00000000);
       ROM_IntMasterDisable();
       ROM_SysTickIntDisable();
       ROM_SysTickDisable();
       uint32_t ui32SysClock;
       ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
       ui32SysClock = ROM_SysCtlClockGet();
       ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
       ROM_GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_4 | GPIO_PIN_5);
       ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / 100);
       HWREG(NVIC_DIS0) = 0xffffffff;
       HWREG(NVIC_DIS1) = 0xffffffff;
       HWREG(NVIC_DIS2) = 0xffffffff;
       HWREG(NVIC_DIS3) = 0xffffffff;
       HWREG(NVIC_DIS4) = 0xffffffff;
       int ui32Addr;
       for(ui32Addr = NVIC_PRI0; ui32Addr <= NVIC_PRI34; ui32Addr+=4)
       {
          HWREG(ui32Addr) = 0;
       }
       HWREG(NVIC_SYS_PRI1) = 0;
       HWREG(NVIC_SYS_PRI2) = 0;
       HWREG(NVIC_SYS_PRI3) = 0;
       ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
       ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_USB0);
       ROM_SysCtlUSBPLLEnable();
       ROM_SysCtlDelay(ui32SysClock*2 / 3);
       ROM_IntMasterEnable();
       ROM_UpdateUSB(0);
       while(1)
           {
           }
#endif
#define BOOTLOADER_TEST 0
#if BOOTLOADER_TEST
#include "hw_nvic.h"
    
    //ROM_UpdateUART();
    // May need to do the following here:
    //  0. See if this will cause bootloader to start
    //ROM_FlashErase(0); 
    //ROM_UpdateUSB(0);
    
#define SYSTICKS_PER_SECOND 100
    uint32_t ui32SysClock = ROM_SysCtlClockGet();
    ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / SYSTICKS_PER_SECOND);
    ROM_SysTickIntEnable();
    ROM_SysTickEnable();
    
    //USBDCDTerm(0);
    
    // Disable all interrupts
    ROM_IntMasterDisable();
    ROM_SysTickIntDisable();
    ROM_SysTickDisable();
    HWREG(NVIC_DIS0) = 0xffffffff;
    HWREG(NVIC_DIS1) = 0xffffffff;
    HWREG(NVIC_DIS2) = 0xffffffff;
    HWREG(NVIC_DIS3) = 0xffffffff;
    HWREG(NVIC_DIS4) = 0xffffffff;
       int ui32Addr;
       for(ui32Addr = NVIC_PRI0; ui32Addr <= NVIC_PRI34; ui32Addr+=4)
       {
          HWREG(ui32Addr) = 0;
       }
       HWREG(NVIC_SYS_PRI1) = 0;
       HWREG(NVIC_SYS_PRI2) = 0;
       HWREG(NVIC_SYS_PRI3) = 0;
    
    //  1. Enable USB PLL
    //ROM_SysCtlUSBPLLEnable();
    //  2. Enable USB controller
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
    ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_USB0);
    //USBClockEnable(USB0_BASE, 8, USB_CLOCK_INTERNAL);
    //HWREG(USB0_BASE + USB_O_CC) = (8 - 1) | USB_CLOCK_INTERNAL;

    ROM_SysCtlUSBPLLEnable();
    
    //  3. Enable USB D+ D- pins

    //  4. Activate USB DFU
    ROM_SysCtlDelay(ui32SysClock * 2 / 3);
    ROM_IntMasterEnable();  // Re-enable interrupts at NVIC level
    ROM_UpdateUSB(0);
    //  5. Should never get here since update is in progress
#endif // BOOTLOADER_TEST

    //
    // Enable the GPIO port that is used for the on-board LED.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);    // gjs Our board uses GPIOB for LEDs
    // gjs original ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

    //
    // Enable the GPIO pins for the LED (PF2 & PF3).
    //
    ROM_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_0|GPIO_PIN_1);
    // gjs original ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3|GPIO_PIN_2);

    //
    // Not configured initially.
    //
    g_bUSBConfigured = false;

    //
    // Enable the UART that we will be redirecting.
    //
    ROM_SysCtlPeripheralEnable(USB_UART_PERIPH);

    //
    // Enable and configure the UART RX and TX pins
    //
    ROM_SysCtlPeripheralEnable(TX_GPIO_PERIPH);
    ROM_SysCtlPeripheralEnable(RX_GPIO_PERIPH);
    ROM_GPIOPinTypeUART(TX_GPIO_BASE, TX_GPIO_PIN);
    ROM_GPIOPinTypeUART(RX_GPIO_BASE, RX_GPIO_PIN);

    //
    // TODO: Add code to configure handshake GPIOs if required.
    //

    //
    // Set the default UART configuration.
    //
    ROM_UARTConfigSetExpClk(USB_UART_BASE, ROM_SysCtlClockGet(),
                            DEFAULT_BIT_RATE, DEFAULT_UART_CONFIG);
    ROM_UARTFIFOLevelSet(USB_UART_BASE, UART_FIFO_TX4_8, UART_FIFO_RX4_8);

    //
    // Configure and enable UART interrupts.
    //
    ROM_UARTIntClear(USB_UART_BASE, ROM_UARTIntStatus(USB_UART_BASE, false));
    ROM_UARTIntEnable(USB_UART_BASE, (UART_INT_OE | UART_INT_BE | UART_INT_PE |
                      UART_INT_FE | UART_INT_RT | UART_INT_TX | UART_INT_RX));

    //
    // Enable the system tick.
    //
#if 0    
    ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / SYSTICKS_PER_SECOND);
    ROM_SysTickIntEnable();
    ROM_SysTickEnable();
#endif
    //
    // Initialize the transmit and receive buffers.
    //
    USBBufferInit(&g_sTxBuffer);
    USBBufferInit(&g_sRxBuffer);

    //
    // Set the USB stack mode to Device mode with VBUS monitoring.
    //
    USBStackModeSet(0, eUSBModeDevice, 0);

    //
    // Pass our device information to the USB library and place the device
    // on the bus.
    //
    USBDCDCInit(0, &g_sCDCDevice);

    //
    // Clear our local byte counters.
    //
    ui32RxCount = 0;
    ui32TxCount = 0;

    //
    // Enable interrupts now that the application is ready to start.
    //
    ROM_IntEnable(USB_UART_INT);

    // Enable FreeRTOS
    mainA(); // FreeRTOS. Will not return
    
#if 0    
    //
    // Main application loop.
    //
    while(1)
    {
        //
        // Have we been asked to update the status display?
        //
        if(g_ui32Flags & COMMAND_STATUS_UPDATE)
        {
            //
            // Clear the command flag
            //
            ROM_IntMasterDisable();
            g_ui32Flags &= ~COMMAND_STATUS_UPDATE;
            ROM_IntMasterEnable();
        }

        //
        // Has there been any transmit traffic since we last checked?
        //
        if(ui32TxCount != g_ui32UARTTxCount)
        {
            //
            // Turn on the Green LED.
            //
            // gjs ROM_UARTCharPutNonBlocking(USB_UART_BASE, 'b');

#if 1
            if (ui32TxCount & 1) {
                GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_0, GPIO_PIN_0);
            } else {
                GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_0, 0);
            }
#else            
            if (1 || g_ui32UARTTxCount & 0x01) {
                GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, GPIO_PIN_3);
            } else {
                //GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0);
            }

            //
            // Delay for a bit.
            //
            for(uint32_t ui32Loop = 0; ui32Loop < 150000; ui32Loop++)
            {
            }

            //
            // Turn off the Green LED.
            //
            GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0);
#endif            

            //
            // Take a snapshot of the latest transmit count.
            //
            ui32TxCount = g_ui32UARTTxCount;
        }

        //
        // Has there been any receive traffic since we last checked?
        //
        if(ui32RxCount != g_ui32UARTRxCount)
        {
            //
            // Turn on the Blue LED.
            //
#if 1
            if (ui32RxCount & 1) {
                GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_1, GPIO_PIN_1);
            } else {
                GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_1, 0);
            }
#else            
            GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);

            //
            // Delay for a bit.
            //
            for(uint32_t ui32Loop = 0; ui32Loop < 150000; ui32Loop++)
            {
            }

            //
            // Turn off the Blue LED.
            //
            GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);
#endif
            //
            // Take a snapshot of the latest receive count.
            //
            ui32RxCount = g_ui32UARTRxCount;

        }
    }
#endif    
}
Пример #11
0
//*****************************************************************************
//
// Process data to produce a CRC-32 checksum.
//
//*****************************************************************************
uint32_t
CRC32DataProcess(uint32_t *pui32Data, uint32_t ui32Length, uint32_t ui32Seed,
                 bool bUseDMA)
{
    uint32_t ui32Result;

    //
    // Perform a soft reset.
    //
    ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_CCM0);
    while(!ROM_SysCtlPeripheralReady(SYSCTL_PERIPH_CCM0))
    {
    }

    //
    // Configure the CRC engine.
    //
    ROM_CRCConfigSet(CCM0_BASE, (CRC_CFG_INIT_SEED | CRC_CFG_TYPE_P4C11DB7 |
                                 CRC_CFG_SIZE_32BIT));

    //
    // Write the seed.
    //
    ROM_CRCSeedSet(CCM0_BASE, ui32Seed);

    //
    // Generate CRC using uDMA to copy data.
    //
    if(bUseDMA)
    {
        //
        // Setup the DMA module to copy data in.
        //
        ROM_uDMAChannelAssign(UDMA_CH30_SW);
        ROM_uDMAChannelAttributeDisable(UDMA_CH30_SW,
                                        UDMA_ATTR_ALTSELECT |
                                        UDMA_ATTR_USEBURST |
                                        UDMA_ATTR_HIGH_PRIORITY |
                                        UDMA_ATTR_REQMASK);
        ROM_uDMAChannelControlSet(UDMA_CH30_SW | UDMA_PRI_SELECT,
                                  UDMA_SIZE_32 | UDMA_SRC_INC_32 |
                                  UDMA_DST_INC_NONE | UDMA_ARB_1 |
                                  UDMA_DST_PROT_PRIV);
        ROM_uDMAChannelTransferSet(UDMA_CH30_SW | UDMA_PRI_SELECT,
                                   UDMA_MODE_AUTO, (void *)g_pui32RandomData,
                                   (void *)(CCM0_BASE + CCM_O_CRCDIN),
                                   ui32Length);
        ROM_uDMAChannelEnable(UDMA_CH30_SW);
        UARTprintf(" Data in DMA request enabled.\n");

        //
        // Start the uDMA.
        //
        ROM_uDMAChannelRequest(UDMA_CH30_SW | UDMA_PRI_SELECT);

        //
        // Wait for the transfer to finish.
        //
        while(ROM_uDMAChannelIsEnabled(UDMA_CH30_SW))
        {
        }

        //
        // Read the result.
        //
        ui32Result = ROM_CRCResultRead(CCM0_BASE, false);
    }

    //
    // Generate CRC using CPU to copy data.
    //
    else
    {
        ui32Result = ROM_CRCDataProcess(CCM0_BASE, g_pui32RandomData,
                                        ui32Length, false);
    }

    return(ui32Result);
}
Пример #12
0
//*****************************************************************************
//
// This is the main loop that runs the application.
//
//*****************************************************************************
int
main(void)
{
    uint32_t ui32Read, ui32Write;

    //
    // Run from the PLL at 120 MHz.
    //
    g_ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                         SYSCTL_OSC_MAIN |
                                         SYSCTL_USE_PLL |
                                         SYSCTL_CFG_VCO_480), 120000000);

    //
    // Configure the device pins.
    //
    PinoutSet();

    //
    // Initialize the display driver.
    //
    Kentec320x240x16_SSD2119Init(g_ui32SysClock);

    //
    // Initialize the graphics context.
    //
    GrContextInit(&g_sContext, &g_sKentec320x240x16_SSD2119);

    //
    // Draw the application frame.
    //
    FrameDraw(&g_sContext, "usb-dev-msc");

    //
    // Place the static status text on the display.
    //
    GrStringDrawCentered(&g_sContext, "Status", -1, 160, 58, false);
    GrStringDrawCentered(&g_sContext, "Bytes Read", -1, 160, 118, false);
    GrStringDrawCentered(&g_sContext, "Bytes Written", -1, 160, 178, false);
    GrContextForegroundSet(&g_sContext, ClrGray);
    UpdateCount(0, 138);
    UpdateCount(0, 198);

    //
    // Configure SysTick for a 100Hz interrupt.  This is to detect idle state
    // every 10ms after a state change.
    //
    ROM_SysTickPeriodSet(g_ui32SysClock / 100);
    ROM_SysTickEnable();
    ROM_SysTickIntEnable();

    //
    // Configure and enable uDMA
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA);
    SysCtlDelay(10);
    ROM_uDMAControlBaseSet(&psDMAControlTable[0]);
    ROM_uDMAEnable();

    //
    // Initialize the idle timeout and reset all flags.
    //
    g_ui32IdleTimeout = 0;
    g_ui32Flags = 0;

    //
    // Initialize the state to idle.
    //
    g_eMSCState = MSC_DEV_DISCONNECTED;

    //
    // Draw the status bar and set it to idle.
    //
    UpdateStatus("Disconnected");

    //
    // Enable the USB controller.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);

    //
    // Enable the SSI3 used by SPI flash.
    //
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI3);
    ROM_SysCtlPeripheralReset(SYSCTL_PERIPH_SSI3);

    //
    // Set the USB stack mode to Device mode with VBUS monitoring.
    //
    USBStackModeSet(0, eUSBModeDevice, 0);

    //
    // Pass our device information to the USB library and place the device
    // on the bus.
    //
    USBDMSCInit(0, (tUSBDMSCDevice*)&g_sMSCDevice);

    //
    // Initialize the SD card, if present.  This prevents it from interfering
    // with accesses to the SPI flash.
    //
    disk_initialize(0);

    //
    // Initialize MX66L51235F Flash memory.
    //
    MX66L51235FInit(g_ui32SysClock);

    //
    // Drop into the main loop.
    //
    ui32Read = g_ui32ReadCount;
    ui32Write = g_ui32WriteCount;
    while(1)
    {
        switch(g_eMSCState)
        {
            case MSC_DEV_READ:
            {
                //
                // Update the screen if necessary.
                //
                if(g_ui32Flags & FLAG_UPDATE_STATUS)
                {
                    UpdateStatus("        Reading        ");
                    g_ui32Flags &= ~FLAG_UPDATE_STATUS;
                }

                //
                // If there is no activity then return to the idle state.
                //
                if(g_ui32IdleTimeout == 0)
                {
                    UpdateStatus("        Idle        ");
                    g_eMSCState = MSC_DEV_IDLE;
                }

                break;
            }

            case MSC_DEV_WRITE:
            {
                //
                // Update the screen if necessary.
                //
                if(g_ui32Flags & FLAG_UPDATE_STATUS)
                {
                    UpdateStatus("        Writing        ");
                    g_ui32Flags &= ~FLAG_UPDATE_STATUS;
                }

                //
                // If there is no activity then return to the idle state.
                //
                if(g_ui32IdleTimeout == 0)
                {
                    UpdateStatus("        Idle        ");
                    g_eMSCState = MSC_DEV_IDLE;
                }
                break;
            }

            case MSC_DEV_DISCONNECTED:
            {
                //
                // Update the screen if necessary.
                //
                if(g_ui32Flags & FLAG_UPDATE_STATUS)
                {
                    UpdateStatus("        Disconnected        ");
                    g_ui32Flags &= ~FLAG_UPDATE_STATUS;
                }
                break;
            }

            case MSC_DEV_IDLE:
            {
                break;
            }

            default:
            {
                break;
            }
        }

        //
        // Update the read count if it has changed.
        //
        if(g_ui32ReadCount != ui32Read)
        {
            ui32Read = g_ui32ReadCount;
            UpdateCount(ui32Read, 138);
        }

        //
        // Update the write count if it has changed.
        //
        if(g_ui32WriteCount != ui32Write)
        {
            ui32Write = g_ui32WriteCount;
            UpdateCount(ui32Write, 198);
        }
    }
}