Пример #1
0
static void My_LPT(void* pvParameters)
{
    unsigned char LowPrio;
	
	LED_PORT = 	LED_My_LPT;	  /* Led to indicate the execution of My_LPT*/

	LowPrio = uxTaskPriorityGet(LPT_Handle);
	UART_Printf("\n\rLPT:%d,Acquiring semaphore",LowPrio);

	xSemaphoreTake(Sem_A,portMAX_DELAY);

    UART_Printf("\n\rLPT: Creating HPT");
	xTaskCreate( My_HPT, ( signed char * )"HighTask", configMINIMAL_STACK_SIZE, NULL, 3, &HPT_Handle );

	LED_PORT = 	LED_My_LPT;	  /* Led to indicate the execution of My_LPT*/
	LowPrio = uxTaskPriorityGet(LPT_Handle);
	UART_Printf("\n\rLPT:%d Creating MPT",LowPrio);
	xTaskCreate( My_MPT, ( signed char * )"MidTask", configMINIMAL_STACK_SIZE, NULL, 2, &MPT_Handle );

	LED_PORT = 	LED_My_LPT;	  /* Led to indicate the execution of My_LPT*/
	LowPrio = uxTaskPriorityGet(LPT_Handle);
	UART_Printf("\n\rLPT:%d Releasing Semaphore",LowPrio);
	xSemaphoreGive(Sem_A);

	LED_PORT = 	LED_My_LPT;	  /* Led to indicate the execution of My_LPT*/
    LowPrio = uxTaskPriorityGet(LPT_Handle);
	UART_Printf("\n\rFinally Exiting LPT:%d",LowPrio);
	vTaskDelete(LPT_Handle);
}
Пример #2
0
/** Tests validity of pointed data */
inline enum IMUErrorMask eIMUDataValid( const struct IMUData * const pxIMUData )
{
enum IMUErrorMask eErrorMask = IMU_ERR_NONE;

	eErrorMask |= prvAltitudeValid( pxIMUData )
			| prvAngleValid( pxIMUData );
			/*
			| prvSpeedValid( pxIMUData )
			| prvAccelValid( pxIMUData );
			*/

	if( eErrorMask == IMU_ERR_NONE )
	{
		ulDebugMsg( xTaskGetTickCount(), "INFO ", pcTaskGetTaskName( NULL ),
				uxTaskPriorityGet( NULL ), MODULE, "eIMUDataValid()",
				"IMU measure is in valid range" );
	}
	else
	{
		ulDebugMsg( xTaskGetTickCount(), "ERROR", pcTaskGetTaskName( NULL ),
				uxTaskPriorityGet( NULL ), MODULE, "eIMUDataValid()",
				"IMU measure is not in valid range !" );
	}

	return eErrorMask;
}
Пример #3
0
/*
 * Just keep counting the shared variable up.  The control task will suspend
 * this task when it wants.
 */
static portTASK_FUNCTION( vContinuousIncrementTask, pvParameters )
{
volatile uint32_t *pulCounter;
UBaseType_t uxOurPriority;

	/* Take a pointer to the shared variable from the parameters passed into
	the task. */
	pulCounter = ( uint32_t * ) pvParameters;

	/* Query our priority so we can raise it when exclusive access to the
	shared variable is required. */
	uxOurPriority = uxTaskPriorityGet( NULL );

	for( ;; )
	{
		/* Raise the priority above the controller task to ensure a context
		switch does not occur while the variable is being accessed. */
		vTaskPrioritySet( NULL, uxOurPriority + 1 );
		{
			configASSERT( ( uxTaskPriorityGet( NULL ) == ( uxOurPriority + 1 ) ) );
			( *pulCounter )++;
		}
		vTaskPrioritySet( NULL, uxOurPriority );

		#if( configUSE_PREEMPTION == 0 )
			taskYIELD();
		#endif

		configASSERT( ( uxTaskPriorityGet( NULL ) == uxOurPriority ) );
	}
}
Пример #4
0
/*
 * Just keep counting the shared variable up.  The control task will suspend
 * this task when it wants.
 */
static void vContinuousIncrementTask( void * pvParameters )
{
unsigned long *pulCounter;
unsigned portBASE_TYPE uxOurPriority;

	/* Take a pointer to the shared variable from the parameters passed into
	the task. */
	pulCounter = ( unsigned long * ) pvParameters;

	/* Query our priority so we can raise it when exclusive access to the 
	shared variable is required. */
	uxOurPriority = uxTaskPriorityGet( NULL );

	for( ;; )
	{
		/* Raise our priority above the controller task to ensure a context
		switch does not occur while we are accessing this variable. */
		vTaskPrioritySet( NULL, uxOurPriority + 1 );
			( *pulCounter )++;		
		vTaskPrioritySet( NULL, uxOurPriority );

		#if configUSE_PREEMPTION == 0
			taskYIELD();
		#endif
	}
}
Пример #5
0
/** \brief This is the task function for monitoring the button and joysticks.
 *  \details This function monitors the "Target Set" button, and when it is pressed,
 *  updates shared variables "motor1_power_SHARED", and "motor2_power_SHARED" with adc_channel
 *  readings. If the button is NOT pressed, the motor power shareds are set to the effective
 *  "zero power" value of 512.(1024 adc values corresponding to full forward(1023), and
 *  full reverse(0);
 */
void task_sensors(void* pvParameters){
	uint8_t default_sensor_prio = uxTaskPriorityGet(NULL);
	portTickType xLastWakeTime;
    xLastWakeTime = xTaskGetTickCount();
    adc_init();
    uint16_t joystick_y;
    uint16_t joystick_x;
    button_init();
       
    while(1)
    {
        if(button_pressed()){
            joystick_y = adc_read(ADC_JOYSTICK_Y);
            joystick_x = adc_read(ADC_JOYSTICK_X);
            vTaskPrioritySet(NULL, configMAX_PRIORITIES - 1);
    	        motor1_power_SHARED = joystick_y;
    	        motor2_power_SHARED = joystick_x;
    	    vTaskPrioritySet(NULL, default_sensor_prio);
    	}
    	else{
	    vTaskPrioritySet(NULL, configMAX_PRIORITIES - 1);
    	        motor1_power_SHARED = 512;
    	        motor2_power_SHARED = 512;
    	    vTaskPrioritySet(NULL, default_sensor_prio);
	    }
    	vTaskDelayUntil(&xLastWakeTime, 100/portTICK_RATE_MS);
    }

	
}
Пример #6
0
THandle OsThreadCreate(const char* aName, uint32_t aPriority, uint32_t aStackBytes, ThreadEntryPoint aEntryPoint, void* aArg)
{
    portBASE_TYPE result;
    xTaskHandle task;

    /* The task application tag is used to hold a pointer to the containing Thread object.
       If the child task is higher priority than it's parent, it'll run before the tag is 
       set. Bad. So we set the initial priority as slightly lower than parent thread, set
       the tag, then promote the child task to it's rightful priority. */

    result =  xTaskCreate(  aEntryPoint,                          // pdTASK_CODE pvTaskCode, 
                            (const signed char * const) aName,    // const portCHAR * const pcName, 
                            (aStackBytes != 0 ? aStackBytes : 1024 * 32) / sizeof( portSTACK_TYPE ),
                                                                  // unsigned portSHORT usStackDepth, 
                            aArg,                                 // void *pvParameters, 
                            uxTaskPriorityGet(NULL) - 1,          // unsigned portBASE_TYPE uxPriority, 
                            &task                                 // xTaskHandle *pvCreatedTask 
                          );

    if ( result != pdPASS )
        return kHandleNull;

    vTaskSetApplicationTaskTag(task, aArg);
    vTaskPrioritySet(task, aPriority);
    
    return (THandle) task;
}
Пример #7
0
/*
 * Just keep counting the shared variable up.  The control task will suspend
 * this task when it wants.
 */
static portTASK_FUNCTION( vContinuousIncrementTask, pvParameters )
{
unsigned long *pulCounter;
unsigned portBASE_TYPE uxOurPriority;
    char str[64];
    sprintf( str, "[%s]: %d\r\n", __func__, __LINE__ );
    vSerialPutString(configUART_PORT, str, strlen(str) );

	/* Take a pointer to the shared variable from the parameters passed into
	the task. */
	pulCounter = ( unsigned long * ) pvParameters;

	/* Query our priority so we can raise it when exclusive access to the 
	shared variable is required. */
	uxOurPriority = uxTaskPriorityGet( NULL );

	for( ;; )
	{
		/* Raise our priority above the controller task to ensure a context
		switch does not occur while we are accessing this variable. */
		vTaskPrioritySet( NULL, uxOurPriority + 1 );
			( *pulCounter )++;		
		vTaskPrioritySet( NULL, uxOurPriority );
	}
}
static portBASE_TYPE prvTESTFSCommand( int8_t *pcWriteBuffer, size_t xWriteBufferLen, const int8_t *pcCommandString )
{
unsigned portBASE_TYPE uxOriginalPriority;

	/* Avoid compiler warnings. */
	( void ) xWriteBufferLen;
	( void ) pcCommandString;

	/* Limitations in the interaction with the Windows TCP/IP stack require
	the command console to run at the idle priority.  Raise the priority for
	the duration of the tests to ensure there are not multiple switches to the
	idle task as in the simulated environment the idle task hook function may
	include a (relatively) long delay. */
	uxOriginalPriority = uxTaskPriorityGet( NULL );
	vTaskPrioritySet( NULL, configMAX_PRIORITIES - 1 );

	f_dotest( 0 );

	/* Reset back to the original priority. */
	vTaskPrioritySet( NULL, uxOriginalPriority );

	sprintf( ( char * ) pcWriteBuffer, "%s", "Test results were sent to Windows console" );

	return pdFALSE;
}
Пример #9
0
/** Tests correct behavior of the IMU */
inline uint8_t ucIMUTest( void )
{
	ulDebugMsg( xTaskGetTickCount(), "TODO", pcTaskGetTaskName( NULL ),
			uxTaskPriorityGet( NULL ), "imu", "ucIMUTest()", "Does nothing ATM" );

	return 0;
}
Пример #10
0
static void
low_level_init(struct netif *netif)
{
//  struct ethernetif *ethernetif = netif->state;
  unsigned portBASE_TYPE uxPriority;

  /* maximum transfer unit */
  netif->mtu = netifMTU;
  
  /* broadcast capability */
  netif->flags = NETIF_FLAG_BROADCAST;
 
  /* Do whatever else is needed to initialize interface. */  
  xNetIf = netif;

  /* Initialise the MACB.  This routine contains code that polls status bits.
  If the Ethernet cable is not plugged in then this can take a considerable
  time.  To prevent this starving lower priority tasks of processing time we
  lower our priority prior to the call, then raise it back again once the
  initialisation is complete. */
  uxPriority = uxTaskPriorityGet( NULL );
  vTaskPrioritySet( NULL, tskIDLE_PRIORITY );
  while( xMACBInit(&AVR32_MACB) == FALSE )
  {
    __asm__ __volatile__ ( "nop" );
  }
  vTaskPrioritySet( NULL, uxPriority );

  /* Create the task that handles the MACB. */
  // xTaskCreate( ethernetif_input, ( signed portCHAR * ) "ETH_INT", netifINTERFACE_TASK_STACK_SIZE, NULL, netifINTERFACE_TASK_PRIORITY, NULL );
  sys_thread_new( ethernetif_input, NULL, netifINTERFACE_TASK_PRIORITY );
}
Пример #11
0
/** Gets IMU attitude measurements */
inline void vIMUGetData( struct IMUData * const pxIMUData )
{
	ulDebugMsg( xTaskGetTickCount(), "TODO", pcTaskGetTaskName( NULL ),
			uxTaskPriorityGet( NULL ), "imu", "vIMUGetData()", "Does nothing ATM" );

	/* TODO : implement during integration */
}
Пример #12
0
/**
 * \brief In this function, the hardware should be initialized.
 * Called from ethernetif_init().
 *
 * \param netif the already initialized lwip network interface structure
 *        for this ethernetif
 */
static void low_level_init(struct netif *netif)
{

#ifdef FREERTOS_USED
    unsigned portBASE_TYPE uxPriority;
#endif

    /* Set MAC hardware address length */
    netif->hwaddr_len = sizeof(gs_uc_mac_address);
    /* Set MAC hardware address */
    netif->hwaddr[0] = gs_uc_mac_address[0];
    netif->hwaddr[1] = gs_uc_mac_address[1];
    netif->hwaddr[2] = gs_uc_mac_address[2];
    netif->hwaddr[3] = gs_uc_mac_address[3];
    netif->hwaddr[4] = gs_uc_mac_address[4];
    netif->hwaddr[5] = gs_uc_mac_address[5];

    /* Maximum transfer unit */
    netif->mtu = NET_MTU;

    /* Configure EMAC pins */
//	ethPinsInit();
    /*	gpio_configure_pin(PIN_EEMAC_EREFCK, PIN_EMAC_FLAGS);
    	gpio_configure_pin(PIN_EMAC_ETX0, PIN_EMAC_FLAGS);
    	gpio_configure_pin(PIN_EMAC_ETX1, PIN_EMAC_FLAGS);
    	gpio_configure_pin(PIN_EMAC_ETXEN, PIN_EMAC_FLAGS);
    	gpio_configure_pin(PIN_EMAC_ECRSDV, PIN_EMAC_FLAGS);
    	gpio_configure_pin(PIN_EMAC_ERX0, PIN_EMAC_FLAGS);
    	gpio_configure_pin(PIN_EMAC_ERX1, PIN_EMAC_FLAGS);
    	gpio_configure_pin(PIN_EMAC_ERXER, PIN_EMAC_FLAGS);
    	gpio_configure_pin(PIN_EMAC_EMDC, PIN_EMAC_FLAGS);
    	gpio_configure_pin(PIN_EMAC_EMDIO, PIN_EMAC_FLAGS);
    */
    /* device capabilities */
    /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
    netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP
#if defined(DHCP_USED)
                    | NETIF_FLAG_DHCP
#endif
                    ;

    netif->flags |= NETIF_FLAG_LINK_UP; //the link is up?
    //printf("netif->flags %X \n", netif->flags);

#ifdef FREERTOS_USED
    /*
    * NOTE: This routine contains code that polls status bits. If the Ethernet
    * cable is not plugged in then this can take a considerable time.  To prevent
    * this from starving lower priority tasks of processing time we lower our
    * priority prior to the call, then raise it back again once the initialization
    * is complete.
    */

    /* Read the priority of the current task. */
    uxPriority = uxTaskPriorityGet( NULL );
    /* Set the priority of the current task to the lowest possible. */
    vTaskPrioritySet( NULL, tskIDLE_PRIORITY );
#endif

}
Пример #13
0
void vTask2(void* pvParameters)
{
	UBaseType_t uxPriority;

	// Task 1will always run before this task as Task 1 is created with the
	// higher priority. Neither Task 1 nor Task 2 ever block so will always be
	// in either the Running or the Ready state.
	
	// Query the priority at which this task is running - passing in NULL means
	// "return my priority".
	uxPriority = uxTaskPriorityGet(NULL);

	for (;;)
	{
		// For this task to reach this point Task 1 must have already run and
		// set the priority of this task higher than its own.
		
		// Print out the name of this task.
		printf("Task2 is running\n");
		fflush(stdout);

		// Set our priority back down to its original value. Passing in NULL
		// as the task handle means "change my priority". Setting the priority
		// below that of Task 1 will cause Task 1 to immediately start running
		// again - pre-empting this task.
		printf("About to lower the Task 2 priority\n");
		fflush(stdout);
		vTaskPrioritySet(NULL, uxPriority-2);
	}
}
Пример #14
0
void vTask1(void* pvParameters)
{
	UBaseType_t uxPriority;

	// This task will always run before Task2 as it is created with the higher
	// priority. Neither Task1 nor Task2 ever block so both will always be
	// in either the Running or the Ready state.
	
	// Query the priority at which this task is running - passing in NULL means
	// "return my priority".
	uxPriority = uxTaskPriorityGet(NULL);

	for (;;)
	{
		// Print out the name of this task.
		vTaskSuspendAll();
		printf("Task 1 is running\n");
		fflush(stdout);
		xTaskResumeAll();

		// Setting the Task 2 priority above the Task 1 priority will cause
		// Task2 to immediately start running (as then Task 2 will have the 
		// higher priority of the two created tasks). Note the use of the handle
		// to task 2 (xTask2Handle) in the call to vTaskPrioritySet().
		// main() shows how the handle was obtained.
		printf("About to raise the Task 2 priority\n");
		fflush(stdout);
		vTaskPrioritySet(xTask2Handle, uxPriority+1);

		// Task 1 will only run when it has a priority higher than Task 2.
		// Therefore, for this task to reach this point Task2 must already
		// have executed and set its priority back down to below the priority
		// of this task.
	}
}
/**
* @brief   Get current priority of an active thread.
* @param   thread_id     thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
* @retval  current priority value of the thread function.
* @note   MUST REMAIN UNCHANGED: \b osThreadGetPriority shall be consistent in every CMSIS-RTOS.
*/
osPriority osThreadGetPriority (osThreadId thread_id)
{
#if (INCLUDE_vTaskPriorityGet == 1)
  return makeCmsisPriority(uxTaskPriorityGet(thread_id));
#else
	return osPriorityError;
#endif
}
Пример #16
0
/*---------------------------------------------------------------------------------------
   Name: osal_task_priority_get

   Purpose: gets the priority of the task.
   Parameters:
      task_handle Handle to the task for which the priority is being set. Passing a NULL
                  handle results in the priority of the calling task being returned.
   returns: The priority of task
---------------------------------------------------------------------------------------*/
uint32 osal_task_priority_get( void **task_handle )
{
  uint32 status;

  status = uxTaskPriorityGet( task_handle );

  return status;
}
/**
 * In this function, the hardware should be initialized.
 * Called from ethernetif_init().
 *
 * @param netif the already initialized lwip network interface structure
 *        for this ethernetif
 */
static void
low_level_init(struct netif *netif)
{
#ifdef FREERTOS_USED
  unsigned portBASE_TYPE uxPriority;
#endif


  /* set MAC hardware address length */
  netif->hwaddr_len = ETHARP_HWADDR_LEN;

  /* set MAC hardware address */
	netif->hwaddr[0] = cMACAddress[0];
	netif->hwaddr[1] = cMACAddress[1];
	netif->hwaddr[2] = cMACAddress[2];
	netif->hwaddr[3] = cMACAddress[3];
	netif->hwaddr[4] = cMACAddress[4];
	netif->hwaddr[5] = cMACAddress[5];

  /* maximum transfer unit */
  netif->mtu = 1500;

  /* device capabilities */
  /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
  netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP
#if defined(DHCP_USED)
    | NETIF_FLAG_DHCP
#endif
  ;

  /* Do whatever else is needed to initialize interface. */
  /* Initialise the MACB. */
#ifdef FREERTOS_USED
  // NOTE: This routine contains code that polls status bits. If the Ethernet
  // cable is not plugged in then this can take a considerable time.  To prevent
  // this from starving lower priority tasks of processing time we lower our
  // priority prior to the call, then raise it back again once the initialization
  // is complete.

  // Read the priority of the current task.
  uxPriority = uxTaskPriorityGet( NULL );
  // Set the priority of the current task to the lowest possible.
  vTaskPrioritySet( NULL, tskIDLE_PRIORITY );
#endif
  // Init the MACB interface.
  while( xMACBInit(&AVR32_MACB) == false )
  {
    __asm__ __volatile__ ( "nop" );
  }
#ifdef FREERTOS_USED
  // Restore the priority of the current task.
  vTaskPrioritySet( NULL, uxPriority );

  /* Create the task that handles the MACB input packets. */
  sys_thread_new( "ETHINT", ethernetif_input, netif, netifINTERFACE_TASK_STACK_SIZE,
                  netifINTERFACE_TASK_PRIORITY );
#endif
}
Пример #18
0
static void
low_level_init(struct netif *netif)
{
  //struct ethernetif *ethernetif = netif->state;
  
  /* MAKINGTHINGS: Addition for FREERTOS */
  unsigned portBASE_TYPE uxPriority;
  
  /* set MAC hardware address length */
  netif->hwaddr_len = 6;

  /* set MAC hardware address */
  /* MAKINGTHINGS: Added */
  /* MAKINGTHINGS: Tweaked */
  netif->hwaddr[0] = emacETHADDR0;
  netif->hwaddr[1] = emacETHADDR1;
  netif->hwaddr[2] = emacETHADDR2;
  netif->hwaddr[3] = emacETHADDR3;
  netif->hwaddr[4] = emacETHADDR4;
  netif->hwaddr[5] = emacETHADDR5;

  /* MAKINGTHINGS: Removed */
  /* netif->hwaddr[0] = ;
  ...
  netif->hwaddr[5] = ; */

  /* maximum transfer unit */
  
  /* MAKINGTHINGS: Added */
  netif->mtu = netifMTU;
  
  /* MAKINGTHINGS: Removed */
  //netif->mtu = 1500;
  
  /* broadcast capability */
  netif->flags = NETIF_FLAG_BROADCAST;
 
  /* Do whatever else is needed to initialize interface. */  

  xNetIf = netif;

  /* Initialise the EMAC.  This routine contains code that polls status bits.  
  If the Ethernet cable is not plugged in then this can take a considerable 
  time.  To prevent this starving lower priority tasks of processing time we
  lower our priority prior to the call, then raise it back again once the
  initialisation is complete. */
  uxPriority = uxTaskPriorityGet( NULL );
  vTaskPrioritySet( NULL, tskIDLE_PRIORITY );
  while( xEMACInit() == NULL )
  {
          __asm( "NOP" );
  }
  vTaskPrioritySet( NULL, uxPriority );

  /* Create the task that handles the EMAC. */
  xTaskCreate( ethernetif_input, ( signed portCHAR * ) "ETH_INT", netifINTERFACE_TASK_STACK_SIZE, NULL, netifINTERFACE_TASK_PRIORITY, NULL );
}
Пример #19
0
UBaseType_t MPU_uxTaskPriorityGet( TaskHandle_t pxTask )
{
    UBaseType_t uxReturn;
    BaseType_t xRunningPrivileged = prvRaisePrivilege();

    uxReturn = uxTaskPriorityGet( pxTask );
    portRESET_PRIVILEGE( xRunningPrivileged );
    return uxReturn;
}
Пример #20
0
	UBaseType_t MPU_uxTaskPriorityGet( TaskHandle_t pxTask )
	{
	UBaseType_t uxReturn;
	BaseType_t xRunningPrivileged = xPortRaisePrivilege();

		uxReturn = uxTaskPriorityGet( pxTask );
		vPortResetPrivilege( xRunningPrivileged );
		return uxReturn;
	}
Пример #21
0
	unsigned portBASE_TYPE MPU_uxTaskPriorityGet( xTaskHandle pxTask )
	{
	unsigned portBASE_TYPE uxReturn;
    portBASE_TYPE xRunningPrivileged = prvRaisePrivilege();

		uxReturn = uxTaskPriorityGet( pxTask );
        portRESET_PRIVILEGE( xRunningPrivileged );
		return uxReturn;
	}
Пример #22
0
static void prvQueueSetReceivingTask( void *pvParameters )
{
    uint32_t ulReceived;
    QueueHandle_t xActivatedQueue;
    TickType_t xBlockTime;

    /* Remove compiler warnings. */
    ( void ) pvParameters;

    /* Create the queues and add them to the queue set before resuming the Tx
    task. */
    prvSetupTest();

    for( ;; ) {
        /* For test coverage reasons, the block time is dependent on the
        priority of this task - which changes during the test.  When the task
        is at the idle priority it polls the queue set. */
        if( uxTaskPriorityGet( NULL ) == tskIDLE_PRIORITY ) {
            xBlockTime = 0;
        } else {
            xBlockTime = portMAX_DELAY;
        }

        /* Wait for a message to arrive on one of the queues in the set. */
        xActivatedQueue = xQueueSelectFromSet( xQueueSet, portMAX_DELAY );

        if( xActivatedQueue == NULL ) {
            if( xBlockTime != 0 ) {
                /* This should not happen as an infinite delay was used. */
                xQueueSetTasksStatus = pdFAIL;
            }
        } else {
            /* Reading from the queue should pass with a zero block time as
            this task will only run when something has been posted to a task
            in the queue set. */
            if( xQueueReceive( xActivatedQueue, &ulReceived, queuesetDONT_BLOCK ) != pdPASS ) {
                xQueueSetTasksStatus = pdFAIL;
            }

            /* Ensure the value received was the value expected.  This function
            manipulates file scope data and is also called from an ISR, hence
            the critical section. */
            taskENTER_CRITICAL();
            {
                prvCheckReceivedValue( ulReceived );
            }
            taskEXIT_CRITICAL();

            if( xQueueSetTasksStatus == pdPASS ) {
                ulCycleCounter++;
            }
        }
    }
}
Пример #23
0
static void My_MPT(void* pvParameters)
{
	uint8_t MidPrio;

	LED_PORT = 	LED_My_MPT;	  /* Led to indicate the execution of My_MPT*/
	MidPrio = uxTaskPriorityGet(MPT_Handle);

	UART_Printf("\n\rIn MPT:%d",MidPrio);

	vTaskDelete(MPT_Handle);
}
Пример #24
0
static void My_HPT(void* pvParameters)
{
   	uint8_t HighPrio;
	
	LED_PORT = 	LED_My_HPT;	  /* Led to indicate the execution of Task1*/
	HighPrio = uxTaskPriorityGet(HPT_Handle);
    UART_Printf("\n\rIn HPT:%d, trying to Acquire the semaphore",HighPrio);

    HighPrio = uxTaskPriorityGet(HPT_Handle);
    xSemaphoreTake(Sem_A,portMAX_DELAY);
	LED_PORT = 	LED_My_HPT;	  /* Led to indicate the execution of Task1*/
	UART_Printf("\n\rIn HPT:%d, Acquired the semaphore",HighPrio);

    HighPrio = uxTaskPriorityGet(HPT_Handle);
	UART_Printf("\n\rIn HPT:%d, releasing the semaphore",HighPrio);
	xSemaphoreGive(Sem_A);

	UART_Printf("\n\rExiting the HPT");
	vTaskDelete(HPT_Handle);
}
Пример #25
0
void httpd_task(void *pvParameters)
{
  xTaskCreate(battery_task, "Battery task", 256, NULL, uxTaskPriorityGet(NULL), NULL);

  tCGI pCGIs[] = {
    {"/pid", [](int, int, char*[], char*[]) { return "/pid.html"; }}
  };
  http_set_cgi_handlers(pCGIs, sizeof (pCGIs) / sizeof (pCGIs[0]));

  httpd_websocket_register_callbacks(NULL, (tWsHandler) httpd_websocket_cb);
  httpd_init();

  for (;;);
}
Пример #26
0
int ICACHE_FLASH_ATTR ThreadStart(Thread* thread, void (*fn)(void*), void* arg) {
    int rc = 0;
    uint16_t usTaskStackSize = 280; //(configMINIMAL_STACK_SIZE * 5);
    portBASE_TYPE uxTaskPriority = uxTaskPriorityGet(NULL); /* set the priority as the same as the calling task*/

    rc = xTaskCreate(fn, /* The function that implements the task. */
                     "MQTTTask", /* Just a text name for the task to aid debugging. */
                     usTaskStackSize, /* The stack size is defined in FreeRTOSIPConfig.h. */
                     arg, /* The task parameter, not used in this case. */
                     uxTaskPriority, /* The priority assigned to the task is defined in FreeRTOSConfig.h. */
                     &thread->task); /* The task handle is not used. */

    return rc;
}
Пример #27
0
/**
* @brief   Get current priority of an active thread.
* @param   thread_id     thread ID obtained by \ref osThreadCreate or \ref osThreadGetId.
* @retval  current priority value of the thread function.
* @note   MUST REMAIN UNCHANGED: \b osThreadGetPriority shall be consistent in every CMSIS-RTOS.
*/
osPriority osThreadGetPriority (osThreadId thread_id)
{
#if (INCLUDE_uxTaskPriorityGet == 1)
  if (inHandlerMode())
  {
    return makeCmsisPriority(uxTaskPriorityGetFromISR(thread_id));  
  }
  else
  {  
    return makeCmsisPriority(uxTaskPriorityGet(thread_id));
  }
#else
  return osPriorityError;
#endif
}
Пример #28
0
/**
 * In this function, the hardware should be initialized.
 * Called from ethernetif_init().
 *
 * @param pxNetIf the already initialized lwip network interface structure
 *		for this etherpxNetIf
 */
static void prvLowLevelInit( struct xFtmac100If *priv )
{
	err_t xStatus;
	unsigned portBASE_TYPE uxOriginalPriority;
	unsigned int maddr, laddr;

	/* Hardware initialisation can take some time, so temporarily lower the
	task priority to ensure other functionality is not adversely effected.
	The priority will get raised again before this function exits. */
	uxOriginalPriority = uxTaskPriorityGet( NULL );
	vTaskPrioritySet( NULL, tskIDLE_PRIORITY );

	/* Reset the mac */
	xStatus = ftMac100_reset_hw();

	if( xStatus == ERR_OK )
	{
		/* setup ring buffer base registers */
		FTMAC100_OFFSET_RXR_BADR = (int) gRxDes;
		FTMAC100_OFFSET_TXR_BADR = (int) gTxDes;

		FTMAC100_OFFSET_APTC = FTMAC100_APTC_RXPOLL_CNT(1);

		/* Set mac address */
		maddr = priv->hwaddr[0] << 8 | priv->hwaddr[1];
		laddr = priv->hwaddr[2] << 24 | priv->hwaddr[3] << 16 |
			priv->hwaddr[4] << 8 | priv->hwaddr[5];
		FTMAC100_OFFSET_MAC_MADR = maddr;
		FTMAC100_OFFSET_MAC_LADR = laddr;

		FTMAC100_OFFSET_MACCR = MACCR_ENABLE_ALL;

		/* Set Rx, Tx interrupt handlers */
		VICVectAddr25 = ( long ) vFtMac100_ISR_Wrapper;

		/* Enable Rx, Tx interrupts */
		FTMAC100_OFFSET_IMR = INT_MASK_ALL_ENABLED;
		VICIRQMask |= ( 1 << 25 );
		VICIRQMode &= ~( 1 << 25 );
		VICIRQLevel &= ~( 1 << 25 );

	}

	/* Reset the task priority back to its original value. */
	vTaskPrioritySet( NULL, uxOriginalPriority );

	configASSERT( xStatus == ERR_OK );
}
Пример #29
0
void TaskBase::print_status (emstream& ser_dev)
{
	ser_dev.puts (pcTaskGetTaskName (handle));
	ser_dev.putchar ('\t');
	if (strlen ((const char*)(pcTaskGetTaskName (handle))) < 8)
	{
		ser_dev.putchar ('\t');
	}
	ser_dev << (uint8_t)(uxTaskPriorityGet (handle)) << PMS ("\t")
			<< get_state ()
		#if (INCLUDE_uxTaskGetStackHighWaterMark == 1)
			<< PMS ("\t") << uxTaskGetStackHighWaterMark(handle) << PMS ("/") 
			<< (size_t)(get_total_stack ()) << PMS ("\t")
		#endif
			<< PMS ("\t") << runs;
}
Пример #30
0
/* This is an entry point for the application.
   All application specific initialization is performed here. */
int main(void)
{
    int ret = 0;
    TaskHandle_t blinkLEDHandle = NULL;
    int priority;

    /* Initializes console on UART0 */
    ret = wmstdio_init(UART0_ID, 0);
    if (ret == -WM_FAIL)
    {
        wmprintf("Failed to initialize console on uart0\r\n");
        return -1;
    }

    wmprintf(" LED demo application started\r\n");
    wmprintf(" This application demonstrates the"
                  " use of blinking led\r\n");

    gpio_led = (board_led_2()).gpio;

    wmprintf(" LED Pin : %d\r\n", gpio_led);

    configure_gpios();

    xTaskCreate(prvBlinkLedTask, "Blink led", ( uint16_t ) BLINK_LED_STACK_SIZE, NULL, ( ( UBaseType_t ) BLINK_LED_TASK_PRIORITY ) | portPRIVILEGE_BIT, &blinkLEDHandle);
    // dump blink led task related information
    if (NULL != blinkLEDHandle)
    {
        priority = uxTaskPriorityGet(blinkLEDHandle);
        wmprintf("blink led priority is %d\r\n", priority);
        wmprintf("blink led task name:%s\r\n", pcTaskGetTaskName(blinkLEDHandle));
    }
    wmprintf("run blink led task for 30 seconds\r\n");
    vTaskDelay(30000);
    wmprintf("delete blink led task\r\n");
    if (NULL != blinkLEDHandle)
    {
        vTaskDelete(blinkLEDHandle);
        blinkLEDHandle = NULL;
    }
    while (1)
    {
        vTaskDelay(1000);
    }
    return 0;
}