예제 #1
0
//*****************************************************************************
//
//! \InterruptTestInit
//!
//! Performs  initialization.
//! This function is called at the start of the test to enable any peripherals
//! used during the test.
//!
//! \param None.
//!
//! \return None.
//
//*****************************************************************************
static void
InterruptTestInit(void)
{
    //
    // Enable and Reset the timer blocks
    //
    MAP_PRCMPeripheralClkEnable(PRCM_TIMERA0, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_TIMERA1, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_TIMERA2, PRCM_RUN_MODE_CLK);

    MAP_PRCMPeripheralReset(PRCM_TIMERA0);
    MAP_PRCMPeripheralReset(PRCM_TIMERA1);
    MAP_PRCMPeripheralReset(PRCM_TIMERA2);

    //
    // Remember the timer interrupt priorities and priority group settings as
    // they are on entry so that we can restore them on exit.
    //
    g_ulTimer0APriority = MAP_IntPriorityGet(INT_TIMERA0A);
    g_ulTimer1APriority = MAP_IntPriorityGet(INT_TIMERA1A);
    g_lPriorityGrouping = MAP_IntPriorityGroupingGet();
    
    SysTickInit();

}
예제 #2
0
//*****************************************************************************
//
//! \InterruptTestTerm
//! Performs termination processing.
//! This function is called once the test completes to tidy up as required.
//!
//! \param None.
//!
//! \return None.
//
//*****************************************************************************
static void
InterruptTestTerm(void)
{

    //
    // Unhook our interrupt handlers if they are still hooked.
    //
    TimerIntUnregister(TIMERA0_BASE, TIMER_A);
    TimerIntUnregister(TIMERA1_BASE, TIMER_A);
    TimerIntUnregister(TIMERA2_BASE, TIMER_A);

    //
    // Restore the original timer interrupt priorities and priority group
    // settings.
    //
    MAP_IntPriorityGroupingSet(g_lPriorityGrouping);
    MAP_IntPrioritySet(INT_TIMERA0A, (unsigned char)g_ulTimer0APriority);
    MAP_IntPrioritySet(INT_TIMERA1A, (unsigned char)g_ulTimer1APriority);

    //
    // Reset and Disable the timer blocks
    //
    MAP_PRCMPeripheralReset(PRCM_TIMERA0);
    MAP_PRCMPeripheralReset(PRCM_TIMERA1);
    MAP_PRCMPeripheralReset(PRCM_TIMERA2);

    MAP_PRCMPeripheralClkDisable(PRCM_TIMERA0, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkDisable(PRCM_TIMERA1, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkDisable(PRCM_TIMERA2, PRCM_RUN_MODE_CLK);

}
예제 #3
0
void HardwareSerial::begin(unsigned long baud)
{
	baudRate = baud;

	/* Set the UART to interrupt whenever the TX FIFO is almost empty or
	 * when any character is received. */
	//MAP_UARTFIFOLevelSet(UART_BASE, UART_FIFO_TX7_8, UART_FIFO_RX7_8);

	/* Initialize the UART. */
//	UARTClockSourceSet(UART_BASE, UART_CLOCK_SYSTEM);
	MAP_PRCMPeripheralReset(g_ulUARTPeriph[uartModule]);

	MAP_PRCMPeripheralClkEnable(g_ulUARTPeriph[uartModule], PRCM_RUN_MODE_CLK);

	MAP_PinTypeUART(g_ulUARTConfig[uartModule][0], PIN_MODE_3);
	MAP_PinTypeUART(g_ulUARTConfig[uartModule][1], PIN_MODE_3);

	MAP_UARTConfigSetExpClk(UART_BASE, 80000000, baudRate,
				(UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE |
				UART_CONFIG_WLEN_8));

	flushAll();
	MAP_IntEnable(g_ulUARTInt[uartModule]);

	/* Enable the UART operation. */
	MAP_UARTEnable(UART_BASE);

	MAP_UARTIntEnable(UART_BASE, UART_INT_RT | UART_INT_TX);
}
예제 #4
0
파일: main.c 프로젝트: gale320/cc3200
//*****************************************************************************
//
//! Function - RunCRC
//!
//! \param uiConfig - Configuration Value
//! \param uiDataLength - DataLength Used
//! \param uiSeed - Seed Value
//! \param puiData - Plain Text Data used
//! \param puiResult - Result Value
//!
//! \return None
//
//*****************************************************************************
void
RunCRC(unsigned int uiConfig,unsigned int uiDataLength,unsigned int uiSeed,
            unsigned int *puiData,unsigned int *puiResult)
{
  //
  // Step1: Reset the Module
  // Step2: Set the Configuration Parameters 
  // Step3: Write the seed value
  // Step4: Start CRC generation
  //

  //
  // Reset the module.
  //
  MAP_PRCMPeripheralReset(PRCM_DTHE);
  
  //
  // Configure the CRC engine.
  //
  MAP_CRCConfigSet(CCM0_BASE, uiConfig);
  
  //
  // Write the seed.
  //
  MAP_CRCSeedSet(CCM0_BASE, uiSeed);
  *puiResult = MAP_CRCDataProcess(CCM0_BASE, (void*) puiData, 
                                        uiDataLength, uiConfig);
}
예제 #5
0
//*****************************************************************************
//
//! Initialize the DMA controller
//!
//! \param None
//!
//! This function initializes
//!        1. Initializes the McASP module
//!
//! \return None.
//
//*****************************************************************************
void UDMAInit()
{
    unsigned int uiLoopCnt;
    //
    // Enable McASP at the PRCM module
    //
    MAP_PRCMPeripheralClkEnable(PRCM_UDMA,PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralReset(PRCM_UDMA);
    //
    // Register interrupt handlers
    //
    MAP_uDMAIntRegister(UDMA_INT_SW, DmaSwIntHandler);
    MAP_uDMAIntRegister(UDMA_INT_ERR, DmaErrorIntHandler);
    //
    // Enable uDMA using master enable
    //
    MAP_uDMAEnable();

    //
    // Set Control Table
    //
    memset(gpCtlTbl,0,sizeof(tDMAControlTable)*CTL_TBL_SIZE);
    MAP_uDMAControlBaseSet(gpCtlTbl);
    //
    // Reset App Callbacks
    //
    for(uiLoopCnt = 0; uiLoopCnt < MAX_NUM_CH; uiLoopCnt++)
    {
        gfpAppCallbackHndl[uiLoopCnt] = NULL;
    }
}
//****************************************************************************
//
//! The delay function uses timer to implement the delay time in milliseconds
//!
//! \param time in millisecond
//
//!  \return void
//****************************************************************************
static void delay(int time_ms)
{
    // Initialize Timer 0B as one-shot down counter.
    MAP_PRCMPeripheralClkEnable(PRCM_TIMERA0, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralReset(PRCM_TIMERA0);
    MAP_TimerConfigure(TIMERA0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_ONE_SHOT);
    MAP_TimerPrescaleSet(TIMERA0_BASE, TIMER_B, PRESCALE);
    //Load the value in milisecond
    MAP_TimerLoadSet(TIMERA0_BASE, TIMER_B, MILLISECONDS_TO_TICKS(time_ms));
    // Enable the timer
    MAP_TimerEnable(TIMERA0_BASE, TIMER_B);
    //Stall during debug
    MAP_TimerControlStall(TIMERA0_BASE, TIMER_B, 1);
    // Enable interrupt upon Time-out
    MAP_TimerIntEnable(TIMERA0_BASE, TIMER_TIMB_TIMEOUT);
    // Clear Interrupt Flag
    MAP_TimerIntClear(TIMERA0_BASE, MAP_TimerIntStatus(TIMERA0_BASE, true));
    //Wait until timer time-out
    while (MAP_TimerIntStatus(TIMERA0_BASE, true) != TIMER_TIMB_TIMEOUT){}
    //Disable the timer
    MAP_TimerDisable(TIMERA0_BASE, TIMER_B);
    //Disable Interrupt
    MAP_TimerIntDisable(TIMERA0_BASE, TIMER_TIMB_TIMEOUT);
    MAP_TimerIntUnregister(TIMERA0_BASE, TIMER_B);
}
예제 #7
0
파일: Tone.cpp 프로젝트: Aginorty/Energia
void tone(uint8_t pin, unsigned int frequency, unsigned long duration)
{
	/* Use TIMERA0B since it is not on any pin */

	tone_timer = digitalPinToTimer(pin);

	if(tone_timer == NOT_ON_TIMER)
		return;

	if(tone_state != 0 && pin != current_pin)
		return;

	g_duration = duration;
	current_pin = pin;
	tone_state = 2;

	MAP_PRCMPeripheralClkEnable(PRCM_TIMERA0, PRCM_RUN_MODE_CLK);
	MAP_PRCMPeripheralReset(PRCM_TIMERA0);
	MAP_TimerConfigure(TIMERA0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_PERIODIC);
	MAP_TimerIntRegister(TIMERA0_BASE, TIMER_B, ToneIntHandler);
	MAP_TimerIntEnable(TIMERA0_BASE, TIMER_TIMB_TIMEOUT);
	MAP_TimerPrescaleSet(TIMERA0_BASE, TIMER_B, 7);
	MAP_TimerLoadSet(TIMERA0_BASE, TIMER_B, (F_CPU / 8) / 1000);
	MAP_TimerEnable(TIMERA0_BASE, TIMER_B);

	PWMWrite(pin, 256, 128, frequency);
}
예제 #8
0
파일: main.c 프로젝트: gale320/cc3200
void
GenerateHash(unsigned int uiConfig,unsigned char *puiKey1,unsigned char *puiData,
             unsigned char *puiResult,unsigned int uiDataLength)
{

    //
    // Step1: Reset the Module
    // Step2: Enable Interrupts
    // Step3: Wait for Context Ready Inteerupt
    // Step4: Set the Configuration Parameters (Hash Algorithm)
    // Step5: Set Key depends on Algorithm
    // Step7: Start Hash Generation
    //
    MAP_PRCMPeripheralReset(PRCM_DTHE);
    //
    // Clear the flags
    //
    g_bContextReadyFlag = false;
    g_bInputReadyFlag = false;
    //
    // Enable interrupts.
    //
    MAP_SHAMD5IntEnable(SHAMD5_BASE, SHAMD5_INT_CONTEXT_READY |
                        SHAMD5_INT_PARTHASH_READY |
                        SHAMD5_INT_INPUT_READY |
                        SHAMD5_INT_OUTPUT_READY);
    //
    // Wait for the context ready flag.
    //
    while(!g_bContextReadyFlag)
    {
    }
    //
    // Configure the SHA/MD5 module.
    //
    MAP_SHAMD5ConfigSet(SHAMD5_BASE, uiConfig);
    //
    // If Keyed Hashing is used, Set Key and start Hash Generation
    //
    if(uiHMAC)
    {
        MAP_SHAMD5HMACKeySet(SHAMD5_BASE, puiKey1);
        MAP_SHAMD5HMACProcess(SHAMD5_BASE,
                              puiData,
                              uiDataLength,
                              puiResult);

    }
    else
    {
        //
        // Perform the hashing operation
        //
        MAP_SHAMD5DataProcess(SHAMD5_BASE, puiData, uiDataLength,
                              puiResult);

    }

}
예제 #9
0
파일: Wire.cpp 프로젝트: Aginorty/Energia
void TwoWire::begin(void)
{
	MAP_PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);
	MAP_PinTypeI2C(PIN_01, PIN_MODE_1);
	MAP_PinTypeI2C(PIN_02, PIN_MODE_1);
	MAP_PRCMPeripheralReset(PRCM_I2CA0);
	MAP_I2CMasterInitExpClk(I2C_BASE, F_CPU, true);
}
예제 #10
0
파일: Motors.c 프로젝트: Robopoly/PIDPOD
void motorSetup()
{
	/* Set pin mode for Hbridge output pins */
	MAP_PinTypeGPIO(AIN1, PIN_MODE_0, false); /* Ain 1 */
	MAP_PinTypeGPIO(AIN2, PIN_MODE_0, false); /* Bin 1 */
	MAP_PinTypeGPIO(BIN1, PIN_MODE_0, false);  /* Bin 2 */
	MAP_PinTypeGPIO(BIN2, PIN_MODE_0, false); /* Ain 2 */

	/* Get port name and bin number from GPIO number (TI lookup table) */
	GPIO_IF_GetPortNPin(AIN1x, &port_ain1, &pin_ain1);
	GPIO_IF_GetPortNPin(AIN2x, &port_ain2, &pin_ain2);
	GPIO_IF_GetPortNPin(BIN1x, &port_bin1, &pin_bin1);
	GPIO_IF_GetPortNPin(BIN2x, &port_bin2, &pin_bin2);

	/* Set pin direction */
	GPIODirModeSet(port_ain1, pin_ain1, 1);
	GPIODirModeSet(port_ain2, pin_ain2, 1);
	GPIODirModeSet(port_bin1, pin_bin1, 1);
	GPIODirModeSet(port_bin2, pin_bin2, 1);

	/* Set value to write to PIN */
	bitA1 = 1 << (AIN1x % 8);
	bitA2 = 1 << (AIN2x % 8);
	bitB1 = 1 << (BIN1x % 8);
	bitB2 = 1 << (BIN2x % 8);

	// Enable timer A peripheral
	MAP_PRCMPeripheralClkEnable(PRCM_TIMERA0, PRCM_RUN_MODE_CLK);
	MAP_PRCMPeripheralReset(PRCM_TIMERA0);

	// Split channels and configure for periodic interrupts
	MAP_TimerConfigure(TIMERA0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC);
	MAP_TimerPrescaleSet(TIMERA0_BASE, TIMER_A, 0);
	MAP_TimerPrescaleSet(TIMERA0_BASE, TIMER_B, 0);

	// Set compare interrupt
	MAP_TimerIntEnable(TIMERA0_BASE, TIMER_TIMA_MATCH);
	MAP_TimerIntEnable(TIMERA0_BASE, TIMER_TIMB_MATCH);

	// Configure compare interrupt, start with 0 speed
	MAP_TimerMatchSet(TIMERA0_BASE, TIMER_A, 0);
	MAP_TimerMatchSet(TIMERA0_BASE, TIMER_B, 0);

	// Set timeout interrupt
	MAP_TimerIntRegister(TIMERA0_BASE, TIMER_A, TimerBaseIntHandlerA);
	MAP_TimerIntRegister(TIMERA0_BASE, TIMER_B, TimerBaseIntHandlerB);
	MAP_TimerIntEnable(TIMERA0_BASE, TIMER_TIMA_TIMEOUT);
	MAP_TimerIntEnable(TIMERA0_BASE, TIMER_TIMB_TIMEOUT);

	// Turn on timers
	MAP_TimerLoadSet(TIMERA0_BASE, TIMER_A, MOTOR_PRESCALER);
	MAP_TimerLoadSet(TIMERA0_BASE, TIMER_B, MOTOR_PRESCALER);

	MAP_TimerEnable(TIMERA0_BASE, TIMER_A);
	MAP_TimerEnable(TIMERA0_BASE, TIMER_B);
}
예제 #11
0
//*****************************************************************************
//
//!     I2CInit
//!    
//!	\param                      Delay  
//!     \return                     None                            
//
//*****************************************************************************
unsigned long I2CInit() {
	// Enable I2C Peripheral
	MAP_PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);
	MAP_PRCMPeripheralReset(PRCM_I2CA0);

	// Configure I2C module, 400 Kbps fast mode
	MAP_I2CMasterInitExpClk(I2CA0_BASE, 80000000, false);
	//  MAP_I2CMasterDisable(I2CA0_BASE);

	return 0;
}
예제 #12
0
//*****************************************************************************
//
//!    Initializing the Timer
//!
//! \param ePeripheral is the peripheral which need to be initialized.
//! \param ulBase is the base address for the timer.
//! \param ulConfig is the configuration for the timer.
//! \param ulTimer selects amoung the TIMER_A or TIMER_B or TIMER_BOTH.
//! \param ulValue is the timer prescale value which must be between 0 and
//! 255 (inclusive) for 16/32-bit timers and between 0 and 65535 (inclusive)
//! for 32/64-bit timers.
//! This function
//!     1. Enables and reset the peripheral for the timer.
//!     2. Configures and set the prescale value for the timer.
//!
//! \return none
//
//*****************************************************************************
void Timer_IF_Init( unsigned long ePeripheral, unsigned long ulBase, unsigned
               long ulConfig, unsigned long ulTimer, unsigned long ulValue)
{
    //
    // Initialize GPT A0 (in 32 bit mode) as periodic down counter.
    //
    MAP_PRCMPeripheralClkEnable(ePeripheral, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralReset(ePeripheral);
    MAP_TimerConfigure(ulBase,ulConfig);
    MAP_TimerPrescaleSet(ulBase,ulTimer,ulValue);
}
예제 #13
0
파일: Motors.cpp 프로젝트: Robopoly/PIDPOD
void motorSetup()
{
  pinMode(AIN1x, OUTPUT);
  pinMode(AIN2x, OUTPUT);
  pinMode(BIN1x, OUTPUT);
  pinMode(BIN2x, OUTPUT);

  bitA1 = digitalPinToBitMask(AIN1x);
  bitA2 = digitalPinToBitMask(AIN2x);
  bitB1 = digitalPinToBitMask(BIN1x);
  bitB2 = digitalPinToBitMask(BIN2x);
  
  portA1 = digitalPinToPort(AIN1x);
  portA2 = digitalPinToPort(AIN2x);
  portB1 = digitalPinToPort(BIN1x);
  portB2 = digitalPinToPort(BIN2x);
  
  baseA1 = (uint32_t) portBASERegister(portA1);
  baseA2 = (uint32_t) portBASERegister(portA2);
  baseB1 = (uint32_t) portBASERegister(portB1);
  baseB2 = (uint32_t) portBASERegister(portB2);
  
  // Enable timer A peripheral
  MAP_PRCMPeripheralClkEnable(PRCM_TIMERA0, PRCM_RUN_MODE_CLK);
  MAP_PRCMPeripheralReset(PRCM_TIMERA0);
  
  // Split channels and configure for periodic interrupts
  MAP_TimerConfigure(TIMERA0_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC);
  MAP_TimerPrescaleSet(TIMERA0_BASE, TIMER_A, 0);
  MAP_TimerPrescaleSet(TIMERA0_BASE, TIMER_B, 0);

  // Set compare interrupt
  MAP_TimerIntEnable(TIMERA0_BASE, TIMER_TIMA_MATCH);
  MAP_TimerIntEnable(TIMERA0_BASE, TIMER_TIMB_MATCH);

  // Configure compare interrupt, start with 0 speed
  MAP_TimerMatchSet(TIMERA0_BASE, TIMER_A, 0);
  MAP_TimerMatchSet(TIMERA0_BASE, TIMER_B, 0);

  // Set timeout interrupt
  MAP_TimerIntRegister(TIMERA0_BASE, TIMER_A, TimerBaseIntHandlerA);
  MAP_TimerIntRegister(TIMERA0_BASE, TIMER_B, TimerBaseIntHandlerB);
  MAP_TimerIntEnable(TIMERA0_BASE, TIMER_TIMA_TIMEOUT);
  MAP_TimerIntEnable(TIMERA0_BASE, TIMER_TIMB_TIMEOUT);

  // Turn on timers
  MAP_TimerLoadSet(TIMERA0_BASE, TIMER_A, MOTOR_PRESCALER);
  MAP_TimerLoadSet(TIMERA0_BASE, TIMER_B, MOTOR_PRESCALER);
 
  MAP_TimerEnable(TIMERA0_BASE, TIMER_A);
  MAP_TimerEnable(TIMERA0_BASE, TIMER_B);
}
예제 #14
0
//*****************************************************************************
//
//!     I2CInit
//!    
//!	\param                      Delay  
//!     \return                     None                            
//
//*****************************************************************************
unsigned long I2CInit()
{
    // Enable I2C Peripheral 
    MAP_PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralReset(PRCM_I2CA0);

    // Configure I2C module, 400 Kbps slow mode
    MAP_I2CMasterInitExpClk(I2CA0_BASE,80000000,false);
    //  MAP_I2CMasterDisable(I2CA0_BASE);
    I2CMasterGlitchFilterConfigSet(I2CA0_BASE , I2C_MASTER_GLITCH_FILTER_8);

    return 0;
}
static void EmitCtrlInit(void)
{
	s_ulTimerEmitCtrl = TIMERA1_BASE;

	MAP_PRCMPeripheralClkEnable(PRCM_TIMERA1,PRCM_RUN_MODE_CLK);
	MAP_PRCMPeripheralReset(PRCM_TIMERA1);
	MAP_TimerConfigure(s_ulTimerEmitCtrl,TIMER_CFG_PERIODIC);
	MAP_TimerPrescaleSet(s_ulTimerEmitCtrl,TIMER_A,0);
	
	//MAP_TimerIntRegister(s_ulTimerEmitCtrl,TIMER_A,TimerEmitCtrlHandler);
	osi_InterruptRegister(INT_TIMERA1A, TimerEmitCtrlHandler, 32);
	
	MAP_TimerIntEnable(s_ulTimerEmitCtrl,TIMER_TIMA_TIMEOUT);
}
예제 #16
0
int i2c_init(i2c_connection conn) {
  struct i2c_state *c = (struct i2c_state *) conn;
  c->base = I2CA0_BASE;
  c->sda_pin_mode = MAP_PinModeGet(c->scl_pin);
  MAP_PinConfigGet(c->sda_pin, &c->sda_pin_strength, &c->sda_pin_type);
  MAP_PinTypeI2C(c->sda_pin, PIN_MODE_1); /* SDA */
  c->scl_pin_mode = MAP_PinModeGet(c->scl_pin);
  MAP_PinConfigGet(c->scl_pin, &c->scl_pin_strength, &c->scl_pin_type);
  MAP_PinTypeI2C(c->scl_pin, PIN_MODE_1); /* SCL */
  MAP_PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);
  MAP_PRCMPeripheralReset(PRCM_I2CA0);
  MAP_I2CMasterInitExpClk(c->base, SYS_CLK, 0 /* 100 KHz */);
  return 0;
}
예제 #17
0
// assumes init parameters have been set up correctly
bool uart_init2(pyb_uart_obj_t *self) {
    uint uartPerh;

    switch (self->uart_id) {
    case PYB_UART_0:
        self->reg = UARTA0_BASE;
        uartPerh = PRCM_UARTA0;
        MAP_UARTIntRegister(UARTA0_BASE, UART0IntHandler);
        MAP_IntPrioritySet(INT_UARTA0, INT_PRIORITY_LVL_3);
        break;
    case PYB_UART_1:
        self->reg = UARTA1_BASE;
        uartPerh = PRCM_UARTA1;
        MAP_UARTIntRegister(UARTA1_BASE, UART1IntHandler);
        MAP_IntPrioritySet(INT_UARTA1, INT_PRIORITY_LVL_3);
        break;
    default:
        return false;
    }

    // Enable the peripheral clock
    MAP_PRCMPeripheralClkEnable(uartPerh, PRCM_RUN_MODE_CLK | PRCM_SLP_MODE_CLK);

    // Reset the uart
    MAP_PRCMPeripheralReset(uartPerh);

    // Initialize the UART
    MAP_UARTConfigSetExpClk(self->reg, MAP_PRCMPeripheralClockGet(uartPerh),
                            self->baudrate, self->config);

    // Enbale the FIFO
    MAP_UARTFIFOEnable(self->reg);

    // Configure the FIFO interrupt levels
    MAP_UARTFIFOLevelSet(self->reg, UART_FIFO_TX4_8, UART_FIFO_RX4_8);
    
    // Configure the flow control mode
    UARTFlowControlSet(self->reg, self->flowcontrol);

    // Enable the RX and RX timeout interrupts
    MAP_UARTIntEnable(self->reg, UART_INT_RX | UART_INT_RT);

    self->enabled = true;

    return true;
}
예제 #18
0
void controller_setup(){
	// Enable timer A peripheral
  	MAP_PRCMPeripheralClkEnable(PRCM_TIMERA1, PRCM_RUN_MODE_CLK);
  	MAP_PRCMPeripheralReset(PRCM_TIMERA1);
  	
  	// Configure one channel for periodic interrupts
  	MAP_TimerConfigure(TIMERA1_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODIC);
  	MAP_TimerPrescaleSet(TIMERA1_BASE, TIMER_A, IMU_CONTROLLER_PRESCALER);
	
  	// Set timeout interrupt
  	MAP_TimerIntRegister(TIMERA1_BASE, TIMER_A, ControllerIntHandler);
  	MAP_TimerIntEnable(TIMERA1_BASE, TIMER_TIMA_TIMEOUT);

  	// Turn on timers
  	MAP_TimerLoadSet(TIMERA1_BASE, TIMER_A, IMU_CONTROLLER_STARTUP); 
  	MAP_TimerEnable(TIMERA1_BASE, TIMER_A);
}
예제 #19
0
파일: pybsd.c 프로젝트: AriZuu/micropython
/// Initalizes the sd card hardware driver
STATIC void pyb_sd_hw_init (pybsd_obj_t *self) {
    if (self->pin_clk) {
        // Configure the clock pin as output only
        MAP_PinDirModeSet(((pin_obj_t *)(self->pin_clk))->pin_num, PIN_DIR_MODE_OUT);
    }
    // Enable SD peripheral clock
    MAP_PRCMPeripheralClkEnable(PRCM_SDHOST, PRCM_RUN_MODE_CLK | PRCM_SLP_MODE_CLK);
    // Reset MMCHS
    MAP_PRCMPeripheralReset(PRCM_SDHOST);
    // Initialize MMCHS
    MAP_SDHostInit(SDHOST_BASE);
    // Configure the card clock
    MAP_SDHostSetExpClk(SDHOST_BASE, MAP_PRCMPeripheralClockGet(PRCM_SDHOST), PYBSD_FREQUENCY_HZ);
    // Set card rd/wr block len
    MAP_SDHostBlockSizeSet(SDHOST_BASE, SD_SECTOR_SIZE);
    self->enabled = true;
}
예제 #20
0
//*****************************************************************************
//
//! Initialize the DMA controller
//!
//! \param None
//!
//! This function initializes
//!        1. Initializes the McASP module
//!
//! \return None.
//
//*****************************************************************************
void UDMAInit()
{
    unsigned int uiLoopCnt;
	
    //
    // Enable McASP at the PRCM module
    //
    MAP_PRCMPeripheralClkEnable(PRCM_UDMA,PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralReset(PRCM_UDMA);

	//
    // Register interrupt handlers
    //
#if defined(USE_TIRTOS) || defined(USE_FREERTOS) || defined(SL_PLATFORM_MULTI_THREADED) 
	// USE_TIRTOS: if app uses TI-RTOS (either networking/non-networking)
	// USE_FREERTOS: if app uses Free-RTOS (either networking/non-networking)
	// SL_PLATFORM_MULTI_THREADED: if app uses any OS + networking(simplelink)
    osi_InterruptRegister(INT_UDMA, DmaSwIntHandler, INT_PRIORITY_LVL_1);
    osi_InterruptRegister(INT_UDMAERR, DmaErrorIntHandler, INT_PRIORITY_LVL_1);
#else
	MAP_IntPrioritySet(INT_UDMA, INT_PRIORITY_LVL_1);
    MAP_uDMAIntRegister(UDMA_INT_SW, DmaSwIntHandler);

	MAP_IntPrioritySet(INT_UDMAERR, INT_PRIORITY_LVL_1);
	MAP_uDMAIntRegister(UDMA_INT_ERR, DmaErrorIntHandler);
#endif

    //
    // Enable uDMA using master enable
    //
    MAP_uDMAEnable();

    //
    // Set Control Table
    //
    memset(gpCtlTbl,0,sizeof(tDMAControlTable)*CTL_TBL_SIZE);
    MAP_uDMAControlBaseSet(gpCtlTbl);

	//
    // Reset App Callbacks
    //
    for(uiLoopCnt = 0; uiLoopCnt < MAX_NUM_CH; uiLoopCnt++)
    {
        gfpAppCallbackHndl[uiLoopCnt] = NULL;
    }
}
예제 #21
0
STATIC void pyb_sleep_flash_powerdown (void) {
    uint32_t status;

    // Enable clock for SSPI module
    MAP_PRCMPeripheralClkEnable(PRCM_SSPI, PRCM_RUN_MODE_CLK | PRCM_SLP_MODE_CLK);
    // Reset SSPI at PRCM level and wait for reset to complete
    MAP_PRCMPeripheralReset(PRCM_SSPI);
    while(!MAP_PRCMPeripheralStatusGet(PRCM_SSPI));

    // Reset SSPI at module level
    MAP_SPIReset(SSPI_BASE);
    // Configure SSPI module
    MAP_SPIConfigSetExpClk (SSPI_BASE, PRCMPeripheralClockGet(PRCM_SSPI),
                            20000000, SPI_MODE_MASTER,SPI_SUB_MODE_0,
                            (SPI_SW_CTRL_CS   |
                             SPI_4PIN_MODE    |
                             SPI_TURBO_OFF    |
                             SPI_CS_ACTIVELOW |
                             SPI_WL_8));

    // Enable SSPI module
    MAP_SPIEnable(SSPI_BASE);
    // Enable chip select for the spi flash.
    MAP_SPICSEnable(SSPI_BASE);
    // Wait for the spi flash
    do {
        // Send the status register read instruction and read back a dummy byte.
        MAP_SPIDataPut(SSPI_BASE, SPIFLASH_INSTR_READ_STATUS);
        MAP_SPIDataGet(SSPI_BASE, &status);

        // Write a dummy byte then read back the actual status.
        MAP_SPIDataPut(SSPI_BASE, 0xFF);
        MAP_SPIDataGet(SSPI_BASE, &status);
    } while ((status & 0xFF) == SPIFLASH_STATUS_BUSY);

    // Disable chip select for the spi flash.
    MAP_SPICSDisable(SSPI_BASE);
    // Start another CS enable sequence for Power down command.
    MAP_SPICSEnable(SSPI_BASE);
    // Send Deep Power Down command to spi flash
    MAP_SPIDataPut(SSPI_BASE, SPIFLASH_INSTR_DEEP_POWER_DOWN);
    // Disable chip select for the spi flash.
    MAP_SPICSDisable(SSPI_BASE);
}
예제 #22
0
void OneMsTaskTimer::start(uint32_t timer_index) {
  uint32_t load = (F_CPU / 1000);
  //// !!!! count = 0;
  overflowing = 0;
  // Base address for first timer
  g_ulBase = TIMERA0_BASE + (timer_index <<12);
  // Configuring the timers
  MAP_PRCMPeripheralClkEnable(PRCM_TIMERA0 + timer_index, PRCM_RUN_MODE_CLK);
  MAP_PRCMPeripheralReset(PRCM_TIMERA0 + timer_index);
  MAP_TimerConfigure(g_ulBase,TIMER_CFG_PERIODIC);
  MAP_TimerPrescaleSet(g_ulBase,TIMER_A,0);
  // Setup the interrupts for the timer timeouts.
  MAP_TimerIntRegister(g_ulBase, TIMER_A, OneMsTaskTimer_int);
  MAP_TimerIntEnable(g_ulBase, TIMER_TIMA_TIMEOUT);
  // Turn on the timers
  MAP_TimerLoadSet(g_ulBase,TIMER_A, load);
  // Enable the GPT 
  MAP_TimerEnable(g_ulBase,TIMER_A);
}
예제 #23
0
파일: odometer.c 프로젝트: Robopoly/PIDPOD
void odometer_controller_setup(void){

	//acc_value_startup = get_accelerometer_default_offset();

	// Enable timer A peripheral
  	MAP_PRCMPeripheralClkEnable(PRCM_TIMERA3, PRCM_RUN_MODE_CLK);
  	MAP_PRCMPeripheralReset(PRCM_TIMERA3);
  	
  	// Configure one channel for periodic interrupts 
  	MAP_TimerConfigure(TIMERA3_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODIC);
  	MAP_TimerPrescaleSet(TIMERA3_BASE, TIMER_A, ODOMETER_CONTROLLER_PRESCALER);
	
  	// Set timeout interrupt
  	MAP_TimerIntRegister(TIMERA3_BASE, TIMER_A, OdometerControllerIntHandler);
  	MAP_TimerIntEnable(TIMERA3_BASE, TIMER_TIMA_TIMEOUT);

  	// Turn on timers
  	MAP_TimerLoadSet(TIMERA3_BASE, TIMER_A, ODOMETER_CONTROLLER_STARTUP); 
  	MAP_TimerEnable(TIMERA3_BASE, TIMER_A);
}
예제 #24
0
/*
 *  ======== Board_initDMA ========
 */
void Board_initDMA(void)
{
    Error_Block eb;
    Hwi_Params  hwiParams;

    if (!dmaInitialized) {
        Error_init(&eb);
        Hwi_Params_init(&hwiParams);
        Hwi_construct(&(hwiStruct), INT_UDMAERR, Board_errorDMAHwi,
                      &hwiParams, &eb);
        if (Error_check(&eb)) {
            System_abort("Couldn't create DMA error hwi");
        }

        MAP_PRCMPeripheralClkEnable(PRCM_UDMA, PRCM_RUN_MODE_CLK);
        MAP_PRCMPeripheralReset(PRCM_UDMA);
        MAP_uDMAEnable();
        MAP_uDMAControlBaseSet(dmaControlTable);

        dmaInitialized = true;
    }
}
예제 #25
0
파일: main.c 프로젝트: PKrza/execom-praksa
//*****************************************************************************
//
//! AES Crypt Function
//!
//! This function Configures Key,Mode and carries out Encryption/Decryption in 
//!                                                  CPU mode
//! \param uiConfig - Configuration Value
//! \param uiKeySize - KeySize used.(128,192 or 256 bit)
//! \param puiKey1 - Key Used
//! \param puiData - Input Data
//! \param puiResult - Resultant Output Data
//! \param uiDataLength - Input Data Length
//! \param uiIV - Initialization Vector used
//!
//! \return none
//
//*****************************************************************************
void 
AESCrypt(unsigned int uiConfig,unsigned int uiKeySize,unsigned int *puiKey1,unsigned int *puiData,
		unsigned int *puiResult,unsigned int uiDataLength,unsigned int *uiIV)
{
    //
    // Step1: Reset the Module
    // Step2: Enable Interrupts
    // Step3: Wait for Context Ready Inteerupt
    // Step4: Set the Configuration Parameters (Direction,AES Mode and Key Size)
    // Step5: Set the Initialization Vector
    // Step6: Write Key
    // Step7: Start the Crypt Process
    //
    MAP_PRCMPeripheralReset(PRCM_DTHE);
    
    //
    // Clear the flags.
    //
    g_bContextInIntFlag = false;
    g_bDataInIntFlag = false;
    g_bContextOutIntFlag = false;
    g_bDataOutIntFlag = false;
    
    //
    // Enable all interrupts.
    //
    MAP_AESIntEnable(AES_BASE, AES_INT_CONTEXT_IN |
	                     AES_INT_CONTEXT_OUT | AES_INT_DATA_IN |
	                     AES_INT_DATA_OUT);
    
    //
    // Wait for the context in flag, the flag will be set in the Interrupt handler.
    //
    while(!g_bContextInIntFlag)
    {
    }
    
    //
    // Configure the AES module with direction (encryption or decryption) and the key size.
    //
    MAP_AESConfigSet(AES_BASE, uiConfig | uiKeySize);
    
    //
    // Write the initial value registers if needed, depends on the mode.
    //
    if(((uiConfig & AES_CFG_MODE_M) == AES_CFG_MODE_CBC) ||
	           ((uiConfig & AES_CFG_MODE_M) == AES_CFG_MODE_CFB) ||
	           ((uiConfig & AES_CFG_MODE_M) == AES_CFG_MODE_CTR) ||
	           ((uiConfig & AES_CFG_MODE_M) == AES_CFG_MODE_ICM) 
	           )
    {
	MAP_AESIVSet(AES_BASE, (unsigned char *)uiIV);
    }
    
    //
    // Write key1.
    //
    //char key[] = "no-preshared-key";
    MAP_AESKey1Set(AES_BASE,(unsigned char *)puiKey1, uiKeySize);
    
    //
    // Start Crypt Process
    //
    //if (uiConfig == 4)
    //{
    //	unsigned char puiBuff[100] = {0x3A, 0xC1, 0xFE, 0x31, 0x71, 0x16, 0x09, 0x6C, 0x61, 0xF8, 0x91, 0xA1, 0x7A, 0xCA, 0xA2, 0x8F, 0xCC, 0xE2, 0x2A, 0x71, 0x20, 0x0C, 0x6E, 0xB9, 0x58, 0x82, 0xB5, 0xA1, 0x8E, 0xEC, 0xDC, 0xB5, 0x0E, 0x4F, 0x6C, 0x6A, 0x6A, 0xD4, 0x52, 0xFF, 0x86, 0xFA, 0x2B, 0xAD, 0x11, 0x4B, 0xA7, 0x41, 0x2F, 0x1B, 0xFB, 0x97, 0xB0, 0x1E, 0x06, 0x35, 0xA9, 0x07, 0x3C, 0x9B, 0xBE, 0xA1, 0x4E, 0x58};
    	//MQTT_payload_string(puiBuff);
    //}
    //else
    //{
    //	unsigned char puiBuff[100] = {0x88, 0xEC, 0x18, 0x67, 0x4A, 0x63, 0x62, 0x84, 0xE6, 0xBF, 0xAF, 0xC9, 0x56, 0x77, 0x8C, 0xE8, 0xCC, 0xE2, 0x2A, 0x71, 0x20, 0x0C, 0x6E, 0xB9, 0x58, 0x82, 0xB5, 0xA1, 0x8E, 0xEC, 0xDC, 0xB5, 0x0E, 0x4F, 0x6C, 0x6A, 0x6A, 0xD4, 0x52, 0xFF, 0x86, 0xFA, 0x2B, 0xAD, 0x11, 0x4B, 0xA7, 0x41, 0xA4, 0x02, 0xB7, 0x8D, 0x75, 0x6A, 0x96, 0x8F, 0xA9, 0xC4, 0x9F, 0xAD, 0x6F, 0xE9, 0x6A, 0x25};
    //}
    //    	unsigned char resBuff[100];

    MAP_AESDataProcess(AES_BASE, (unsigned char *)puiData, (unsigned char *)puiResult, uiDataLength);
}
예제 #26
0
//****************************************************************************
//                            MAIN FUNCTION
//****************************************************************************
void main()
{
    long lRetVal = -1;
  
    //Board Initialization
    BoardInit();
    
    //Pin Configuration
    PinMuxConfig();
    
    //Change Pin 58 Configuration from Default to Pull Down
    MAP_PinConfigSet(PIN_58,PIN_STRENGTH_2MA|PIN_STRENGTH_4MA,PIN_TYPE_STD_PD);
    
    //
    // Initialize GREEN and ORANGE LED
    //
    GPIO_IF_LedConfigure(LED1|LED2|LED3);
    //Turn Off the LEDs
    GPIO_IF_LedOff(MCU_ALL_LED_IND);

    //UART Initialization
    MAP_PRCMPeripheralReset(PRCM_UARTA0);

    MAP_UARTConfigSetExpClk(CONSOLE,MAP_PRCMPeripheralClockGet(CONSOLE_PERIPH),
                            UART_BAUD_RATE,(UART_CONFIG_WLEN_8 | 
                              UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));

    //Display Application Banner on UART Terminal
    DisplayBanner(APPLICATION_NAME);
    
    //
    // Simplelinkspawntask
    //
    lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY);    
    if(lRetVal < 0)
    {
        UART_PRINT("Unable to start simpelink spawn task\n\r");
        LOOP_FOREVER();
    }
    //
    // Create HTTP Server Task
    //
    lRetVal = osi_TaskCreate(HTTPServerTask, (signed char*)"HTTPServerTask",
                         OSI_STACK_SIZE, NULL, OOB_TASK_PRIORITY, NULL );    
    if(lRetVal < 0)
    {
        UART_PRINT("Unable to create task\n\r");
        LOOP_FOREVER();
    }

    //
    // Start OS Scheduler
    //
    osi_start();

    while (1)
    {

    }

}
예제 #27
0
/******************************************************************************
 DEFINE PUBLIC FUNCTIONS
 ******************************************************************************/
void HASH_Init (void) {
    // Enable the Data Hashing and Transform Engine
    MAP_PRCMPeripheralClkEnable(PRCM_DTHE, PRCM_RUN_MODE_CLK | PRCM_SLP_MODE_CLK);
    MAP_PRCMPeripheralReset(PRCM_DTHE);
}
예제 #28
0
파일: main.c 프로젝트: dlugaz/All
//*****************************************************************************
//
//! Main function for uDMA Application 
//!
//! \param  none
//!
//! \return none
//!
//*****************************************************************************
void
main()
{
    static unsigned long ulPrevSeconds;
    static unsigned long ulPrevUARTCount = 0;
    unsigned long ulXfersCompleted;
    unsigned long ulBytesAvg=0;
    int iCount=0;
    
	//
    // Initailizing the board
    //
    BoardInit();
    //
    // Muxing for Enabling UART_TX and UART_RX.
    //
    PinMuxConfig();
    
    //
    // Initialising the Terminal.
    //
    InitTerm();
    
    //
    // Display Welcome Message
    //
    DisplayBanner();
    
    //
    // SysTick Enabling
    //
    SysTickIntRegister(SysTickHandler);
    SysTickPeriodSet(SYSTICK_RELOAD_VALUE);
    SysTickEnable();

    //
    // uDMA Initialization
    //
    UDMAInit();
    
    //
    // Register interrupt handler for UART
    //
    MAP_UARTIntRegister(UARTA0_BASE,UART0IntHandler);
    
    UART_PRINT("Completed DMA Initialization \n\r\n\r");
    
    //
    // Auto DMA Transfer
    //
    UART_PRINT("Starting Auto DMA Transfer  \n\r");
    InitSWTransfer();
    
    //
    // Scatter Gather DMA Transfer
    //
    UART_PRINT("Starting Scatter Gather DMA Operation\n\r");
    InitSGTransfer();
    while(!Done){}
    MAP_UtilsDelay(80000000);
    
    //
    // Ping Pong UART Transfer
    //
    InitUART0Transfer();
    
    //
    // Remember the current SysTick seconds count.
    //
    ulPrevSeconds = g_ulSeconds;

    while(1)
    {
        //
        // Check to see if one second has elapsed.  If so, the make some
        // updates.
        //
        if(g_ulSeconds != ulPrevSeconds)
        {

            uiCount++;
    
            //
            // Remember the new seconds count.
            //
            ulPrevSeconds = g_ulSeconds;
            
            //
            // Calculate how many UART transfers have occurred since the last
            // second.
            //
            ulXfersCompleted = (g_ulRxBufACount + g_ulRxBufBCount -
                                ulPrevUARTCount);

            //
            // Remember the new UART transfer count.
            //
            ulPrevUARTCount = g_ulRxBufACount + g_ulRxBufBCount;
            
            //
            // Compute how many bytes were transferred by the UART.
            //
            ulBytesTransferred[iCount] = (ulXfersCompleted * UART_RXBUF_SIZE );
            iCount++;
            
            //
            // Print a message to the display showing the memory transfer rate.
            //
            if(UARTDone)
            {
                MAP_PRCMPeripheralReset(PRCM_UARTA0);
                MAP_PRCMPeripheralClkEnable(PRCM_UARTA0,PRCM_RUN_MODE_CLK);
                UARTConfigSetExpClk(CONSOLE,SYSCLK, UART_BAUD_RATE,
                                    (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
                                                        UART_CONFIG_PAR_NONE));
            }

        }
        
        //
        // See if we have run long enough and exit the loop if so.
        //
        if(g_ulSeconds >= 6 && UARTDone)
        {
            break;
        }
    }
    
    //
    // Compute average Bytes Transfer Rate for the past 5 seconds
    //
    for(iCount=1;iCount<=5;iCount++)
    {
        ulBytesAvg += ulBytesTransferred[iCount];
    }
    ulBytesAvg=ulBytesAvg/5;

    UART_PRINT("\n\r");
    UART_PRINT("\n\r");

    UART_PRINT("\n\rCompleted Ping Pong Transfer from Memory to UART "
                "Peripheral \n\r");
    UART_PRINT(" \n\rTransfer Rate is %lu Bytes/Sec \n\r", ulBytesAvg);
    UART_PRINT("\n\rTest Ended\n\r");
    return ;

}
예제 #29
0
파일: main.c 프로젝트: dlugaz/All
//*****************************************************************************
//
//! Initializes the UART0 peripheral and sets up the TX and RX uDMA channels.
//! The UART is configured for loopback mode so that any data sent on TX will be
//! received on RX.  The uDMA channels are configured so that the TX channel
//! will copy data from a buffer to the UART TX output.  And the uDMA RX channel
//! will receive any incoming data into a pair of buffers in ping-pong mode.
//!
//! \param None
//!
//! \return None
//!
//*****************************************************************************
void
InitUART0Transfer(void)
{
    unsigned int uIdx;

    //
    // Fill the TX buffer with a simple data pattern.
    //
    for(uIdx = 0; uIdx < UART_TXBUF_SIZE; uIdx++)
    {
        g_ucTxBuf[uIdx] = 65;
    }
    MAP_PRCMPeripheralReset(PRCM_UARTA0);
    MAP_PRCMPeripheralClkEnable(PRCM_UARTA0,PRCM_RUN_MODE_CLK);

    MAP_UARTConfigSetExpClk(CONSOLE,SYSCLK, UART_BAUD_RATE,
                            (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
                                        UART_CONFIG_PAR_NONE));
    MAP_uDMAChannelAssign(UDMA_CH8_UARTA0_RX);
    MAP_uDMAChannelAssign(UDMA_CH9_UARTA0_TX);
    MAP_UARTIntRegister(UARTA0_BASE,UART0IntHandler);
    
    //
    // Set both the TX and RX trigger thresholds to 4.  This will be used by
    // the uDMA controller to signal when more data should be transferred.  The
    // uDMA TX and RX channels will be configured so that it can transfer 4
    // bytes in a burst when the UART is ready to transfer more data.
    //
    MAP_UARTFIFOLevelSet(UARTA0_BASE, UART_FIFO_TX4_8, UART_FIFO_RX4_8);

    //
    // Enable the UART for operation, and enable the uDMA interface for both TX
    // and RX channels.
    //
    MAP_UARTEnable(UARTA0_BASE);

    //
    // This register write will set the UART to operate in loopback mode.  Any
    // data sent on the TX output will be received on the RX input.
    //
    HWREG(UARTA0_BASE + UART_O_CTL) |= UART_CTL_LBE;

    //
    // Enable the UART peripheral interrupts. uDMA controller will cause an 
    // interrupt on the UART interrupt signal when a uDMA transfer is complete.
    //
   
    MAP_UARTIntEnable(UARTA0_BASE,UART_INT_DMATX);
    MAP_UARTIntEnable(UARTA0_BASE,UART_INT_DMARX);

    //
    // Configure the control parameters for the UART TX.  The uDMA UART TX
    // channel is used to transfer a block of data from a buffer to the UART.
    // The data size is 8 bits.  The source address increment is 8-bit bytes
    // since the data is coming from a buffer.  The destination increment is
    // none since the data is to be written to the UART data register.  The
    // arbitration size is set to 4, which matches the UART TX FIFO trigger
    // threshold.
    //
    UDMASetupTransfer(UDMA_CH8_UARTA0_RX | UDMA_PRI_SELECT, UDMA_MODE_PINGPONG,
            sizeof(g_ucRxBufA),UDMA_SIZE_8, UDMA_ARB_4,
            (void *)(UARTA0_BASE + UART_O_DR), UDMA_SRC_INC_NONE,
                                            g_ucRxBufA, UDMA_DST_INC_8);

    UDMASetupTransfer(UDMA_CH8_UARTA0_RX | UDMA_ALT_SELECT, UDMA_MODE_PINGPONG,
            sizeof(g_ucRxBufB),UDMA_SIZE_8, UDMA_ARB_4,
              (void *)(UARTA0_BASE + UART_O_DR), UDMA_SRC_INC_NONE,
                                            g_ucRxBufB, UDMA_DST_INC_8);

    UDMASetupTransfer(UDMA_CH9_UARTA0_TX| UDMA_PRI_SELECT,
               UDMA_MODE_BASIC,sizeof(g_ucTxBuf),UDMA_SIZE_8, UDMA_ARB_4,
               g_ucTxBuf, UDMA_SRC_INC_8,(void *)(UARTA0_BASE + UART_O_DR), 
                                                    UDMA_DST_INC_NONE);
    
    MAP_UARTDMAEnable(UARTA0_BASE, UART_DMA_RX | UART_DMA_TX);
}
예제 #30
0
파일: main.c 프로젝트: dlugaz/All
//****************************************************************************
//
//! Main function
//!
//! \param none
//!
//!
//! \return None.
//
//****************************************************************************
void main()
{

    FIL fp;
    FATFS fs;
    FRESULT res;
    DIR dir;
    UINT Size;

    //
    // Initialize Board configurations
    //
    BoardInit();

    //
    // Muxing for Enabling UART_TX and UART_RX.
    //
    PinMuxConfig();

    //
    // Set the SD card clock as output pin
    //
    MAP_PinDirModeSet(PIN_07,PIN_DIR_MODE_OUT);

    //
    // Enable Pull up on data
    //
    MAP_PinConfigSet(PIN_06,PIN_STRENGTH_4MA, PIN_TYPE_STD_PU);

    //
    // Enable Pull up on CMD
    //
    MAP_PinConfigSet(PIN_08,PIN_STRENGTH_4MA, PIN_TYPE_STD_PU);

    //
    // Initialising the Terminal.
    //
    InitTerm();

    //
    // Clearing the Terminal.
    //
    ClearTerm();

    //
    // Display the Banner
    //
    Message("\n\n\n\r");
    Message("\t\t   ********************************************\n\r");
    Message("\t\t        CC3200 SDHost Fatfs Demo Application  \n\r");
    Message("\t\t   ********************************************\n\r");
    Message("\n\n\n\r");

    //
    // Enable MMCHS
    //
    MAP_PRCMPeripheralClkEnable(PRCM_SDHOST,PRCM_RUN_MODE_CLK);

    //
    // Reset MMCHS
    //
    MAP_PRCMPeripheralReset(PRCM_SDHOST);

    //
    // Configure MMCHS
    //
    MAP_SDHostInit(SDHOST_BASE);

    //
    // Configure card clock
    //
    MAP_SDHostSetExpClk(SDHOST_BASE,
                            MAP_PRCMPeripheralClockGet(PRCM_SDHOST),15000000);

    f_mount(&fs,"0",1);
    res = f_opendir(&dir,"/");
    if( res == FR_OK)
    {
        Message("Opening root directory.................... [ok]\n\n\r");
        Message("/\n\r");
        ListDirectory(&dir);
    }
    else
    {
        Message("Opening root directory.................... [Failed]\n\n\r");
    }

    Message("\n\rReading user file...\n\r");
    res = f_open(&fp,USERFILE,FA_READ);
    if(res == FR_OK)
    {
        f_read(&fp,pBuffer,100,&Size);
        Report("Read : %d Bytes\n\n\r",Size);
        Report("%s",pBuffer);
        f_close(&fp);
    }
    else
    {
        Report("Failed to open %s\n\r",USERFILE);
    }

    Message("\n\n\rWriting system file...\n\r");
    res = f_open(&fp,SYSFILE,FA_CREATE_ALWAYS|FA_WRITE);
    if(res == FR_OK)
    {
        f_write(&fp,SYSTEXT,sizeof(SYSTEXT),&Size);
        Report("Wrote : %d Bytes",Size);
        res = f_close(&fp);
    }
    else
    {
        Message("Failed to create a new file\n\r");
    }

    while(1)
    {

    }
}