Пример #1
1
bool btc_a2dp_sink_startup(void)
{
    if (btc_a2dp_sink_state != BTC_A2DP_SINK_STATE_OFF) {
        APPL_TRACE_ERROR("warning : media task already running");
        return false;
    }

    APPL_TRACE_EVENT("## A2DP SINK START MEDIA THREAD ##");

    btc_aa_snk_queue_set = xQueueCreateSet(BTC_A2DP_SINK_TASK_QUEUE_SET_LEN);
    configASSERT(btc_aa_snk_queue_set);
    btc_aa_snk_data_queue = xQueueCreate(BTC_A2DP_SINK_DATA_QUEUE_LEN, sizeof(int32_t));
    configASSERT(btc_aa_snk_data_queue);
    xQueueAddToSet(btc_aa_snk_data_queue, btc_aa_snk_queue_set);

    btc_aa_snk_ctrl_queue = xQueueCreate(BTC_A2DP_SINK_CTRL_QUEUE_LEN, sizeof(void *));
    configASSERT(btc_aa_snk_ctrl_queue);
    xQueueAddToSet(btc_aa_snk_ctrl_queue, btc_aa_snk_queue_set);

    if (!btc_aa_snk_data_queue || !btc_aa_snk_ctrl_queue || !btc_aa_snk_queue_set ) {
        goto error_exit;
    }

    xTaskCreatePinnedToCore(btc_a2dp_sink_task_handler, BTC_A2DP_SINK_TASK_NAME, BTC_A2DP_SINK_TASK_STACK_SIZE, NULL, BTC_A2DP_SINK_TASK_PRIO, &btc_aa_snk_task_hdl, BTC_A2DP_SINK_TASK_PINNED_TO_CORE);
    if (btc_aa_snk_task_hdl == NULL) {
        goto error_exit;
    }

    btc_a2dp_sink_ctrl_post(BTC_MEDIA_TASK_SINK_INIT, NULL);

    APPL_TRACE_EVENT("## A2DP SINK MEDIA THREAD STARTED ##\n");

    return true;

error_exit:;
    APPL_TRACE_ERROR("%s unable to start up media thread\n", __func__);

    if (btc_aa_snk_task_hdl != NULL) {
        vTaskDelete(btc_aa_snk_task_hdl);
        btc_aa_snk_task_hdl = NULL;
    }

    if (btc_aa_snk_data_queue) {
        vQueueDelete(btc_aa_snk_data_queue);
        btc_aa_snk_data_queue = NULL;
    }
    if (btc_aa_snk_ctrl_queue) {
        vQueueDelete(btc_aa_snk_ctrl_queue);
        btc_aa_snk_ctrl_queue = NULL;
    }

    return false;
}
Пример #2
0
	xQueueSetHandle MPU_xQueueCreateSet( unsigned portBASE_TYPE uxEventQueueLength )
	{
	xQueueSetHandle xReturn;
	portBASE_TYPE xRunningPrivileged = prvRaisePrivilege();

		xReturn = xQueueCreateSet( uxEventQueueLength );
		portRESET_PRIVILEGE( xRunningPrivileged );
		return xReturn;
	}
Пример #3
0
QueueSetHandle_t MPU_xQueueCreateSet( UBaseType_t uxEventQueueLength )
{
    QueueSetHandle_t xReturn;
    BaseType_t xRunningPrivileged = prvRaisePrivilege();

    xReturn = xQueueCreateSet( uxEventQueueLength );
    portRESET_PRIVILEGE( xRunningPrivileged );
    return xReturn;
}
Пример #4
0
	QueueSetHandle_t MPU_xQueueCreateSet( UBaseType_t uxEventQueueLength )
	{
	QueueSetHandle_t xReturn;
	BaseType_t xRunningPrivileged = xPortRaisePrivilege();

		xReturn = xQueueCreateSet( uxEventQueueLength );
		vPortResetPrivilege( xRunningPrivileged );
		return xReturn;
	}
Пример #5
0
void vStartQueueSetPollingTask( void )
{
	/* Create the queue that is added to the set, the set, and add the queue to
	the set. */
	xQueue = xQueueCreate( setpollQUEUE_LENGTH, sizeof( uint32_t ) );
	xQueueSet = xQueueCreateSet( setpollQUEUE_LENGTH );
	xQueueAddToSet( xQueue, xQueueSet );

	/* Create the task. */
	xTaskCreate( prvQueueSetReceivingTask, "SetPoll", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
}
Пример #6
0
CQueueSet &CQueueSet::CreateSet(const UBaseType_t uxEventQueueLength) {
#if (configUSE_QUEUE_SETS == 1)
	assert(!IsValid());

	QueueSetHandle_t handle;

	handle = xQueueCreateSet(uxEventQueueLength);
	if (handle != NULL)
		Attach(handle);
#endif
	return *this;
}
Пример #7
0
void scheduler_task::initQueueSet(uint32_t queueSetSize, uint32_t count, ...)
{
    void *handle = 0;
    va_list vl;
    va_start(vl, count);

    mQueueSet = xQueueCreateSet(queueSetSize);
    while(count--) {
        handle = va_arg(vl, void*);
        xQueueAddToSet( handle, mQueueSet);
    }

    va_end(vl);
}
Пример #8
0
void communication_task(){
	int status;

	rsc_info.rsc_tab = (struct resource_table *)&resources;
	rsc_info.size = sizeof(resources);

	zynqMP_r5_gic_initialize();

	/* Initialize RPMSG framework */
	status = remoteproc_resource_init(&rsc_info, rpmsg_channel_created, rpmsg_channel_deleted,
			rpmsg_read_cb ,&proc);
	if (status < 0) {
		return;
	}

#ifdef USE_FREERTOS
	comm_queueset = xQueueCreateSet( 2 );
	xQueueAddToSet( OpenAMPInstPtr.send_queue, comm_queueset);
	xQueueAddToSet( OpenAMPInstPtr.lock, comm_queueset);
#else
	env_create_sync_lock(&OpenAMPInstPtr.lock,LOCKED);
#endif
	env_enable_interrupt(VRING1_IPI_INTR_VECT,0,0);
	while (1) {
#ifdef USE_FREERTOS
		QueueSetMemberHandle_t xActivatedMember;

		xActivatedMember = xQueueSelectFromSet( comm_queueset, portMAX_DELAY);
		if( xActivatedMember == OpenAMPInstPtr.lock ) {
			env_acquire_sync_lock(OpenAMPInstPtr.lock);
			process_communication(OpenAMPInstPtr);
		}
		if (xActivatedMember == OpenAMPInstPtr.send_queue) {
			xQueueReceive( OpenAMPInstPtr.send_queue, &send_data, 0 );
			rpmsg_send(app_rp_chnl, send_data.data, send_data.length);
		}
#else
		env_acquire_sync_lock(OpenAMPInstPtr.lock);
		process_communication(OpenAMPInstPtr);
		echo_test();
		/* Wait for the result data on queue */
		if(pq_qlength(OpenAMPInstPtr.send_queue) > 0) {
			send_data = pq_dequeue(OpenAMPInstPtr.send_queue);
			/* Send the result of echo_test back to master. */
			rpmsg_send(app_rp_chnl, send_data->data, send_data->length);
		}
#endif

	}
}
Пример #9
0
/**
 * \brief	Gatekeeper task initialization. Generates the task and initialize
 * 			the hardware.
 */
void taskGatekeeperInit(void) {

	/* Initialize the serial interface */
	bsp_SerialInit();

	/* Generate the task */
	xTaskCreate(taskGatekeeper, TASK_GATEKEEPER_NAME, TASK_GATEKEEPER_STACKSIZE,
			NULL, TASK_GATEKEEPER_PRIORITY, &taskGatekeeperHandle);

	/* Generate the queue */
	queueMessage = xQueueCreate(Q_MESSAGE_LENGTH, sizeof(message_t));
	queueMessageData = xQueueCreate(Q_MESSAGE_DATA_LENGTH, sizeof(char[DATA_MESSAGE_STRING_LENGTH]));

	/* Create the message queue set */
	queueMessageSet = xQueueCreateSet(Q_MESSAGE_LENGTH + Q_MESSAGE_DATA_LENGTH);
	xQueueAddToSet(queueMessage, queueMessageSet);
	xQueueAddToSet(queueMessageData, queueMessageSet);

	/* Generate the mutual exclusion */
	mutexTxCircBuf = xSemaphoreCreateMutex();
	xSemaphoreGive(mutexTxCircBuf);
}
Пример #10
0
static void prvSetupTest( void )
{
portBASE_TYPE x;
unsigned long ulValueToSend = 0;

	/* Ensure the queues are created and the queue set configured before the
	sending task is unsuspended.

	First Create the queue set such that it will be able to hold a message for
	every space in every queue in the set. */
	xQueueSet = xQueueCreateSet( queuesetNUM_QUEUES_IN_SET * queuesetQUEUE_LENGTH );

	for( x = 0; x < queuesetNUM_QUEUES_IN_SET; x++ )
	{
		/* Create the queue and add it to the set.  The queue is just holding
		unsigned long value. */
		xQueues[ x ] = xQueueCreate( queuesetQUEUE_LENGTH, sizeof( unsigned long ) );
		configASSERT( xQueues[ x ] );
		if( xQueueAddToSet( xQueues[ x ], xQueueSet ) != pdPASS )
		{
			xQueueSetTasksStatus = pdFAIL;
		}
		else
		{
			/* The queue has now been added to the queue set and cannot be added to
			another. */
			if( xQueueAddToSet( xQueues[ x ], xQueueSet ) != pdFAIL )
			{
				xQueueSetTasksStatus = pdFAIL;
			}
		}
	}

	/* Attempt to remove a queue from a queue set it does not belong
	to (NULL being passed as the queue set in this case). */
	if( xQueueRemoveFromSet( xQueues[ 0 ], NULL ) != pdFAIL )
	{
		/* It is not possible to successfully remove a queue from a queue
		set it does not belong to. */
		xQueueSetTasksStatus = pdFAIL;
	}

	/* Attempt to remove a queue from the queue set it does belong to. */
	if( xQueueRemoveFromSet( xQueues[ 0 ], xQueueSet ) != pdPASS )
	{
		/* It should be possible to remove the queue from the queue set it
		does belong to. */
		xQueueSetTasksStatus = pdFAIL;
	}

	/* Add an item to the queue before attempting to add it back into the
	set. */
	xQueueSend( xQueues[ 0 ], ( void * ) &ulValueToSend, 0 );
	if( xQueueAddToSet( xQueues[ 0 ], xQueueSet ) != pdFAIL )
	{
		/* Should not be able to add a non-empty queue to a set. */
		xQueueSetTasksStatus = pdFAIL;
	}

	/* Remove the item from the queue before adding the queue back into the
	set so the dynamic tests can begin. */
	xQueueReceive( xQueues[ 0 ], &ulValueToSend, 0 );
	if( xQueueAddToSet( xQueues[ 0 ], xQueueSet ) != pdPASS )
	{
		/* If the queue was successfully removed from the queue set then it
		should be possible to add it back in again. */
		xQueueSetTasksStatus = pdFAIL;
	}

	/* The task that sends to the queues is not running yet, so attempting to
	read from the queue set should fail. */
	if( xQueueSelectFromSet( xQueueSet, queuesetSHORT_DELAY ) != NULL )
	{
		xQueueSetTasksStatus = pdFAIL;
	}

	/* Resume the task that writes to the queues. */
	vTaskResume( xQueueSetSendingTask );

	/* Let the ISR access the queues also. */
	xSetupComplete = pdTRUE;
}
Пример #11
0
static void
main_thread(void *pdata) {
    QueueSetHandle_t qs;
    QueueSetMemberHandle_t active;

    ASSERT((qs = xQueueCreateSet(SERIAL_RX_SIZE * 3)));
    serial_start(cli_serial, 115200, qs);
    serial_start(&Serial4, 57600, qs);
    serial_start(&Serial5, cfg.gps_baud_rate ? cfg.gps_baud_rate : 57600, qs);
    cli_set_output(cli_serial);
    log_start(cli_serial);
    cl_enabled = 1;

    load_eeprom();
    cfg.flags &= ~FLAG_HOLDOVER_TEST;
    if (cfg.flags & FLAG_GPSEXT) {
        gps_serial = &Serial5;
    } else {
        gps_serial = &Serial4;
    }
    if (!cfg.holdover) {
        cfg.holdover = 60;
    }
    if (!cfg.loopstats_interval) {
        cfg.loopstats_interval = 60;
    }
    ppscapture_start();
    vtimer_start();
    tcpip_start();
    test_reset();
    cli_banner();
    if (!(cfg.flags & FLAG_GPSEXT)) {
        ublox_configure();
        if (HAS_FEATURE(PPSEN) && (cfg.flags & FLAG_PPSEN)) {
            GPIO_OFF(PPSEN);
        }
    }
    cl_enabled = 0;
    while (1) {
        watchdog_main = 5;
        active = xQueueSelectFromSet(qs, pdMS_TO_TICKS(1000));
        if (active == cli_serial->rx_q) {
            int16_t val = serial_get(cli_serial, TIMEOUT_NOBLOCK);
            ASSERT(val >= 0);
            cli_feed(val);
        } else if (active == gps_serial->rx_q) {
            int16_t val = serial_get(gps_serial, TIMEOUT_NOBLOCK);
            ASSERT(val >= 0);
            gps_byte_received(val);
            if (cfg.flags & FLAG_GPSOUT) {
                char tmp = val;
                serial_write(&Serial5, &tmp, 1);
            }
#if 0
        } else if (active == Serial5.rx_q) {
            char tmp = serial_get(&Serial5, TIMEOUT_NOBLOCK);
            serial_write(&Serial4, &tmp, 1);
#endif
        }
    }
}