Exemple #1
0
//*****************************************************************************
//
//!    main function demonstrates the use of the timers to generate
//! periodic interrupts.
//!
//! \param  None
//!
//! \return none
//
//*****************************************************************************
int
main(void)
{
    //
    // Initialize board configurations
    BoardInit();
    //
    // Pinmuxing for LEDs
    //
    PinMuxConfig();
    //
    // configure the LED RED and GREEN
    //
    GPIO_IF_LedConfigure(LED1|LED3);

    GPIO_IF_LedOff(MCU_RED_LED_GPIO);
    GPIO_IF_LedOff(MCU_GREEN_LED_GPIO); 

    //
    // Base address for first timer
    //
    g_ulBase = TIMERA0_BASE;
    //
    // Base address for second timer
    //
    g_ulRefBase = TIMERA1_BASE;
    //
    // Configuring the timers
    //
    Timer_IF_Init(PRCM_TIMERA0, g_ulBase, TIMER_CFG_PERIODIC, TIMER_A, 0);
    Timer_IF_Init(PRCM_TIMERA1, g_ulRefBase, TIMER_CFG_PERIODIC, TIMER_A, 0);

    //
    // Setup the interrupts for the timer timeouts.
    //
    Timer_IF_IntSetup(g_ulBase, TIMER_A, TimerBaseIntHandler);
    Timer_IF_IntSetup(g_ulRefBase, TIMER_A, TimerRefIntHandler);

    //
    // Turn on the timers feeding values in mSec
    //
    Timer_IF_Start(g_ulBase, TIMER_A, 500);
    Timer_IF_Start(g_ulRefBase, TIMER_A, 1000);
	
    //
    // Loop forever while the timers run.
    //
    while(FOREVER)
    {
    }
}
/* EFFECTS: Initializes Timer A and enables it */
void TimerConfigNStart()
{
  // Configure Timer for blinking the LED for IP acquisition
  Timer_IF_Init(PRCM_TIMERA0, TIMERA0_BASE, TIMER_CFG_PERIODIC, TIMER_A, 0);
  Timer_IF_IntSetup(TIMERA0_BASE, TIMER_A, TimerPeriodicIntHandler);
  Timer_IF_Start(TIMERA0_BASE, TIMER_A, TIME_IN_MSECS);
}
Exemple #3
0
//****************************************************************************
//
//! Function to configure and start timer to blink the LED while device is
//! trying to connect to an AP
//!
//! \param none
//!
//! return none
//
//****************************************************************************
void LedTimerConfigNStart()
{
    //
    // Configure Timer for blinking the LED for IP acquisition
    //
    Timer_IF_Init(PRCM_TIMERA0,TIMERA0_BASE,TIMER_CFG_PERIODIC,TIMER_A,0);
    Timer_IF_IntSetup(TIMERA0_BASE,TIMER_A,TimerPeriodicIntHandler);
    Timer_IF_Start(TIMERA0_BASE,TIMER_A,100);   // time value is in mSec
}
Exemple #4
0
//****************************************************************************
//
//! Function to configure and start timer to blink the LED while device is
//! trying to connect to an AP
//!
//! \param none
//!
//! return none
//
//****************************************************************************
void LedTimerConfigNStart()
{
  //
  // Configure Timer for blinking the LED for IP acquisition
  //
  Timer_IF_Init(PRCM_TIMERA0,TIMERA0_BASE,TIMER_CFG_PERIODIC,TIMER_A,0);
  Timer_IF_IntSetup(TIMERA0_BASE,TIMER_A,TimerPeriodicIntHandler);
  Timer_IF_Start(TIMERA0_BASE,TIMER_A,PERIODIC_TEST_CYCLES / 10);
}
Exemple #5
0
//****************************************************************************
//
//! Implements Sleep followed by wakeup using GPT timeout
//!
//! \param none
//!
//! This function
//!    1. Implements Sleep followed by wakeup using GPT
//!
//! \return None.
//
//****************************************************************************
void PerformPRCMSleepGPTWakeup()
{
    //
    // Power On the GPT along with sleep clock
    //
    MAP_PRCMPeripheralClkEnable(PRCM_TIMERA0, PRCM_RUN_MODE_CLK);

    //
    // Initialize the GPT as One Shot timer
    //
    Timer_IF_Init(PRCM_TIMERA0, TIMERA0_BASE, TIMER_CFG_ONE_SHOT, TIMER_BOTH, 0);
    Timer_IF_IntSetup(TIMERA0_BASE, TIMER_BOTH, AppGPTCallBackHandler);

    //
    // Start timer with value in mSec
    //
    Timer_IF_Start(TIMERA0_BASE, TIMER_BOTH, 4000);

    //
    // Enable the Sleep Clock
    //
    MAP_PRCMPeripheralClkEnable(PRCM_TIMERA0, PRCM_SLP_MODE_CLK);

    //
    // Enter SLEEP...WaitForInterrupt ARM intrinsic
    //
    DBG_PRINT("GPT_SLEEP: Entering Sleep\n\r");
    MAP_UtilsDelay(80000);
    MAP_PRCMSleepEnter();
    DBG_PRINT("GPT_SLEEP: Exiting Sleep\n\r");

    //
    // Disable the Sleep Clock
    //
    MAP_PRCMPeripheralClkDisable(PRCM_TIMERA0, PRCM_SLP_MODE_CLK);

    //
    // Deinitialize the GPT
    //
    Timer_IF_Stop(TIMERA0_BASE, TIMER_BOTH);
    Timer_IF_DeInit(TIMERA0_BASE, TIMER_BOTH);

    //
    // PowerOff GPT
    //
    MAP_PRCMPeripheralClkDisable(PRCM_TIMERA0, PRCM_RUN_MODE_CLK);
}
//****************************************************************************
//                            MAIN FUNCTION
//****************************************************************************
void main()
{
    long lRetVal = 0;
    char data[BUF_SIZE];
    char sent_data[BUF_SIZE];
    unsigned char highByte, lowByte;
    int i;

    unsigned long tempStartTimeStamp, tempStopTimeStamp;

    memset(sent_data, 0, 10);
    // Board Initialization
    BoardInit();

    // Configure the pinmux settings for the peripherals exercised
    PinMuxConfig();

    // Initialize the PWM outputs on the board
    InitServos();

    // Initialize the sensor ADC
    InitSensorADC();

    // Configuring UART
    InitTerm();

    // Display banner
    DisplayBanner(APPLICATION_NAME);

    // Connect to WIFI using default info
    //WlanConnect(NULL, NULL, NULL);
    WlanConnect("Nagui's Network", "SL_SEC_TYPE_WPA", "19520605");

    // Setup the TCP Server Socket
    BsdTcpServerSetup(PORT_NUM);

    // Recieve Data
    while (lRetVal >= 0)
    {
    	lRetVal = BsdTcpServerReceive(data);

		//SysTickPeriodSet(800000000);				// test
		//SysTickEnable();						// test
    	Timer_IF_Init(PRCM_TIMERA0, TIMERA0_BASE, TIMER_CFG_PERIODIC, TIMER_A, 0);
    	Timer_IF_Start(TIMERA0_BASE, TIMER_A, MILLISECONDS_TO_TICKS(2000));
		//tempStartTimeStamp = SysTickValueGet();		// test
    	tempStartTimeStamp = Timer_IF_GetCount(TIMERA0_BASE, TIMER_A);

    	for (i = 0; i<NUM_SERVOS; i++)
    	{
    		MoveServo((unsigned char)data[i], (enum Servo_Joint_Type)i);
    		UART_PRINT("%d", (unsigned int) data[i]);
    	}

    	for (i = 0; i< NUM_SENSORS; i++)
    	{
        	//UnsignedShort_to_UnsignedChar(GetSensorReading((enum Fingertip_Sensor_Type)i), &highByte, &lowByte);
    		UnsignedShort_to_UnsignedChar(GetSensorReading(SENSOR_FINGER_INDEX), &highByte, &lowByte);
        	sent_data[i*2] = (char)highByte;
        	sent_data[i*2+1] = (char)lowByte;
    	}
    	//tempStopTimeStamp = SysTickValueGet();					// test
    	tempStopTimeStamp = Timer_IF_GetCount(TIMERA0_BASE, TIMER_A);
    	lRetVal = BsdTcpServerSend(sent_data, 10);
    	UART_PRINT("timestamp start: %lu\n\r", tempStartTimeStamp);	//test
    	UART_PRINT("timestamp stop: %lu\n\r", tempStopTimeStamp);	//test
    	UART_PRINT("Sent 10 bytes to client.\n\r");

    }
    UART_PRINT("Exiting Application ...\n\r");

    // power of the Network processor
    lRetVal = sl_Stop(SL_STOP_TIMEOUT);

}
Exemple #7
0
//*****************************************************************************
//                            MAIN FUNCTION
//*****************************************************************************
void main()
{
    long lRetVal = -1;

    //
    // Board Initialization
    //
    BoardInit();
    
    //
    // configure the GPIO pins for LEDs,UART
    //
    PinMuxConfig();

    //
    // Configure the UART
    //
#ifndef NOTERM
    InitTerm();
#endif  //NOTERM
    
    //
    // Display Application Banner
    //
    DisplayBanner(APPLICATION_NAME);
    
    //
    // Configure all 3 LEDs
    //
    GPIO_IF_LedConfigure(LED1|LED2|LED3);

    // switch off all LEDs
    GPIO_IF_LedOff(MCU_ALL_LED_IND);

	//
    // SysTick Enabling
    //
    //SysTickIntRegister(SysTickHandler);
    ///SysTickPeriodSet(SYSTICK_RELOAD_VALUE);
    //SysTickEnable();

    //
    // Base address for first timer
    //
    g_ulBase = TIMERA0_BASE;
    //
    // Configuring the timers
    //
    Timer_IF_Init(PRCM_TIMERA0, g_ulBase, TIMER_CFG_PERIODIC, TIMER_A, 0);

    //
    // Setup the interrupts for the timer timeouts.
    //
    Timer_IF_IntSetup(g_ulBase, TIMER_A, TimerBaseIntHandler);

    //
    // Turn on the timers feeding values in mSec
    //
    Timer_IF_Start(g_ulBase, TIMER_A, 1000);
	
    //
    // Start the SimpleLink Host
    //
    lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY);
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }

    //
    // Start the WlanStationMode task
    //
    lRetVal = osi_TaskCreate( WlanStationMode, \
                                (const signed char*)"Wlan Station Task", \
                                OSI_STACK_SIZE, NULL, 1, NULL );
    if(lRetVal < 0)
    {
        ERR_PRINT(lRetVal);
        LOOP_FOREVER();
    }
     
    //
    // Start the task scheduler
    //
    osi_start();
  }