Beispiel #1
0
/**************************************************************************//**
 * @brief  Gpio callback
 * @param  pin - pin which triggered interrupt
 *****************************************************************************/
void gpioCallback(uint8_t pin)
{
  if (pin == 9)
  {
    BSP_LedToggle(1);
  }
  else if (pin == 10)
  {
    BSP_LedToggle(0);
  }
}
/* Notes      :(1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
*                   used.  The compiler should not generate any code for this statement.
*
*
*********************************************************************************************************
*/
void APP_TaskOne(void *p_arg)
{
    OS_ERR err = OS_ERR_NONE;
    static CPU_INT32U ledPos = 0U; /* LED position variable  */


    (void)p_arg; /* Note(1) */

    while (1U)
    {   /* Task body, always written as an infinite loop  */

        /* Delay with 100msec                             */
        OSTimeDlyHMSM(0U, 0U, 0U, 100U, (OS_OPT_TIME_DLY | OS_OPT_TIME_HMSM_STRICT), &err);

        /* Animate LEDs */
        BSP_LedToggle(ledPos);

        /* Modify LED position variable                   */
        if (4u == ++ledPos)
        {
            ledPos = 0; /* 3bit overflow */
        }

        /* Delay task for 1 system tick (uC/OS-III suspends this task and executes
         * the next most important task) */
        OSTimeDly(1U, OS_OPT_TIME_DLY, &err);
    }
}
/* Notes      :(1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
*                   used.  The compiler should not generate any code for this statement.
*
*
*********************************************************************************************************
*/
void APP_TaskOne(void *p_arg)
{
  static INT32U ledPos = 0; /* LED position variable  */

  (void)p_arg; /* Note(1) */

  while (1)
  { /* Task body, always written as an infinite loop  */

    /* Delay with 100msec                             */
    OSTimeDlyHMSM(0, 0, 0, 100);

    /* Animate LEDs */
    BSP_LedToggle(ledPos);

    /* Modify LED position variable                   */
    if (BSP_NO_OF_LEDS == ++ledPos)
    {
      ledPos = 0; /* 3bit overflow */
    }

    /* Delay task for 1 system tick (uC/OS-II suspends this task and executes
     * the next most important task) */
    OSTimeDly(1);
  }
}
Beispiel #4
0
/**************************************************************************//**
 * @brief Simple task which is blinking led
 * @param *pParameters pointer to parameters passed to the function
 *****************************************************************************/
static void LedBlink(void *pParameters)
{
  TaskParams_t     * pData = (TaskParams_t*) pParameters;
  const portTickType delay = pData->delay;

  for (;;)
  {
    BSP_LedToggle(pData->ledNo);
    vTaskDelay(delay);
  }
}
Beispiel #5
0
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
  /* Chip errata */
  CHIP_Init();

  /* If first word of user data page is non-zero, enable eA Profiler trace */
  BSP_TraceProfilerSetup();

  /* Setup SysTick Timer for 1 msec interrupts  */
  if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000)) while (1) ;

  /* Initialize LED driver */
  BSP_LedsInit();
  BSP_LedSet(0);

  /* Infinite blink loop */
  while (1)
  {
    BSP_LedToggle(0);
    BSP_LedToggle(1);
    Delay(1000);
  }
}
Beispiel #6
0
/**************************************************************************//**
 * @brief Simple task which is blinking led
 * @param *pParameters pointer to parameters passed to the function
 *****************************************************************************/
static void LedTask(void *pParameters)
{
    vTaskDelay(1000 / portTICK_RATE_MS);

    LedTaskParams_t     * pData = (LedTaskParams_t*) pParameters;
    const portTickType delay = pData->delay;

    for (;;)
    {
        BSP_LedToggle(pData->ledNo);
        vTaskDelay(delay);
        printf("%s. FreeHeap: %d\n", pcTaskGetTaskName(NULL), xPortGetFreeHeapSize());
    }
}
/**************************************************************************//**
 * @brief Blink Led
 * This function uses a software delay to illustrate the difference between
 * running the CPU on 32 MHz and 64 Hz. Software delays are generally  not
 * a good idea!
 *****************************************************************************/
void blink_led(uint32_t delay, uint32_t rounds)
{
  uint32_t count   = 0;
  bool     enabled = false;

  while (1)
  {
    /* If count is a multiple of delay */
    if (!(count % delay))
    {
      BSP_LedToggle(0);
      if (enabled)
      {
        if (!(--rounds)) break;
      }

      count   = 0;
      enabled = !enabled;
    }
    count++;
  }
}
Beispiel #8
0
int main( void ) 
{
	setupBSP();

	Delay_Init();
 
	setupMEM();
	setupFPGA();
	setupINT();

	setupCMU();

	setupPRS();

	setupDAC();
	setupDMA();
	setupADC();

	setupTIMER();

	Delay_Init();

	BSP_LedsInit();
	BSP_LedsSet(0);

	while(1) {

		//test_and_display();
		BSP_LedToggle(0);
		Delay(1000);
		BSP_LedsSet(0);
		Delay(500);

	}
	
}
Beispiel #9
0
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
	{
  CHIP_Init();                                   // This function addresses some chip errata and should be called at the start of every EFM32 application (need em_system.c)
  uint8_t i, front_back, left_right, command;
  char init_message[] = "Start!\n";

  /* Setup SysTick Timer for 1 msec interrupts  */
  if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000)) while (1) ;

  /* Initialize LED driver */
  BSP_LedsInit();
  BSP_LedSet(0);

  /* initalize clocks */
  CMU->CTRL |= (1 << 14);                         // Set HF clock divider to /2 to keep core frequency <32MHz
  CMU->OSCENCMD |= 0x4;                           // Enable XTAL Oscillator
  while(! (CMU->STATUS & 0x8) );                  // Wait for XTAL osc to stabilize
  CMU->CMD = 0x2;                                 // Select HF XTAL osc as system clock source. 48MHz XTAL, but we divided the system clock by 2, therefore our HF clock should be 24MHz

  usart_init();
  i2cInit();

  // Print test string
  for(i=0; init_message[i] != '\0'; i++) {
    usart_send_data(init_message[i]);
  }

  usart_enable_rx_isr();

  while (1)
  {
	performI2CTransfer();
    BSP_LedToggle(0);
    BSP_LedToggle(1);

    front_back = (uint8_t)(G[1]>>8 & 0xFF);
    left_right = (uint8_t)(G[0]>>8 & 0xFF);

/*
    usart_send_data(0xAA);
    usart_send_data(front_back);
    usart_send_data(0xBB);
    usart_send_data(left_right);
*/
    if (left_right >= 0x30 && front_back <= 0x45){
        	command = 'l';
        }else if (left_right >= 0xC0 && front_back <= 0xDF){
        	command = 'r';
        }else if(front_back >= 0xC0&& front_back <= 0xCD){
    	command = 'f';
    }else if (front_back >= 0x32 && front_back <= 0x35){
    	command = 'b';
    }

    /*else if (left_right >= 0x3E && front_back <= 0x40){
    	command = 'l';
    }else if (left_right >= 0xC4 && front_back <= 0xD0){
    	command = 'r';
    }
    */

    if(command != 0x00){
    	usart_send_data(command);
    	command = 0x00;
    }

    //usart_send_data((uint8_t)(G[0]>>8 & 0xFF));
    //usart_send_data((uint8_t)G[1] & 0xFF);

    Delay(500);
  }
}
Beispiel #10
0
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
  char buffer[] = "AT";
  uint8_t delay_type = 0;

  /* Chip errata */
  CHIP_Init();

  /* initalize clocks */
  CMU->CTRL |= (1 << 14);                         // Set HF clock divider to /2 to keep core frequency <32MHz
  CMU->OSCENCMD |= 0x4;                           // Enable XTAL Oscillator
  while(! (CMU->STATUS & 0x8) );                  // Wait for XTAL osc to stabilize
  CMU->CMD = 0x2;                                 // Select HF XTAL osc as system clock source. 48MHz XTAL, but we divided the system clock by 2, therefore our HF clock should be 24MHz

  /* Setup SysTick Timer for 1 msec interrupts  */
  if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000)) while (1) ;

  usart_init();
  motor_init();

  usart_enable_rx_isr();

  BSP_LedsInit();
  BSP_LedSet(0);
  BSP_LedSet(1);

  usart_send_string(buffer);

  /* Infinite loop */
  while (1) {
	  BSP_LedToggle(1);

	  switch(rx_data){
	    case 'f':
		  Move_Forward();
		  delay_type = 1;
		  break;
	    case 'b':
		  Move_Backward();
		  delay_type = 1;
		  break;
	    case 'r':
		  Move_Left();
		  delay_type = 2;
		  break;
	    case 'l':
		  Move_Right();
		  delay_type = 2;
		  break;
	    default:
	      delay_type = 1;
		  Stop_Robot();
		  break;
	  }

	  rx_data = 0;

	  //Chooses the delay depending on the movement
	  if (delay_type == 1){
		  Delay(1000);
	  }else if(delay_type == 2){
		  Delay(200);
	  }

  }
}
Beispiel #11
0
void halToggleLed(HalBoardLed led)
{
	BSP_LedToggle(led);
}
Beispiel #12
0
static void prvCheckTask( void *pvParameters )
{
TickType_t xDelayPeriod = mainNO_ERROR_CHECK_TASK_PERIOD;
TickType_t xLastExecutionTime;
static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0;
unsigned long ulErrorFound = pdFALSE;

	/* Just to stop compiler warnings. */
	( void ) pvParameters;

	/* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()
	works correctly. */
	xLastExecutionTime = xTaskGetTickCount();

	/* Cycle for ever, delaying then checking all the other tasks are still
	operating without error.  The onboard LED is toggled on each iteration.
	If an error is detected then the delay period is decreased from
	mainNO_ERROR_CHECK_TASK_PERIOD to mainERROR_CHECK_TASK_PERIOD.  This has the
	effect of increasing the rate at which the onboard LED toggles, and in so
	doing gives visual feedback of the system status. */
	for( ;; )
	{
		/* Delay until it is time to execute again. */
		vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );

		/* Check all the demo tasks (other than the flash tasks) to ensure
		that they are all still running, and that none have detected an error. */
		if( xAreMathsTaskStillRunning() != pdTRUE )
		{
			ulErrorFound = 1UL << 1UL;
		}

		if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
		{
			ulErrorFound = 1UL << 2UL;
		}

		if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
		{
			ulErrorFound = 1UL << 4UL;
		}

		if ( xAreGenericQueueTasksStillRunning() != pdTRUE )
		{
			ulErrorFound = 1UL << 5UL;
		}

		if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
		{
			ulErrorFound = 1UL << 6UL;
		}

		if( xIsCreateTaskStillRunning() != pdTRUE )
		{
			ulErrorFound = 1UL << 7UL;
		}

		if( xAreSemaphoreTasksStillRunning() != pdTRUE )
		{
			ulErrorFound = 1UL << 8UL;
		}

		if( xAreTimerDemoTasksStillRunning( ( TickType_t ) xDelayPeriod ) != pdPASS )
		{
			ulErrorFound = 1UL << 9UL;
		}

		if( xAreInterruptSemaphoreTasksStillRunning() != pdPASS )
		{
			ulErrorFound = 1UL << 11UL;
		}

		if( xAreEventGroupTasksStillRunning() != pdPASS )
		{
			ulErrorFound = 1UL << 12UL;
		}

		if( xAreTaskNotificationTasksStillRunning() != pdPASS )
		{
			ulErrorFound = 1UL << 14UL;
		}

		/* Check that the register test 1 task is still running. */
		if( ulLastRegTest1Value == ulRegTest1LoopCounter )
		{
			ulErrorFound = 1UL << 15UL;
		}
		ulLastRegTest1Value = ulRegTest1LoopCounter;

		/* Check that the register test 2 task is still running. */
		if( ulLastRegTest2Value == ulRegTest2LoopCounter )
		{
			ulErrorFound = 1UL << 16UL;
		}
		ulLastRegTest2Value = ulRegTest2LoopCounter;

		/* Toggle the check LED to give an indication of the system status.  If
		the LED toggles every mainNO_ERROR_CHECK_TASK_PERIOD milliseconds then
		everything is ok.  A faster toggle indicates an error. */
		BSP_LedToggle( mainTASK_LED );

		if( ulErrorFound != pdFALSE )
		{
			/* An error has been detected in one of the tasks - flash the LED
			at a higher frequency to give visible feedback that something has
			gone wrong. */
			xDelayPeriod = mainERROR_CHECK_TASK_PERIOD;
		}

		configASSERT( ulErrorFound == pdFALSE );
	}
}