Example #1
0
/* __attribute__((__always_inline__)) */
usci_irq (bsp430_FreeRTOS_USCI *port)
{
	portBASE_TYPE yield = pdFALSE;
	portBASE_TYPE rv = pdFALSE;
	uint8_t c;

	switch (port->usci->iv) {
	default:
	case USCI_NONE:
		break;
	case USCI_UCTXIFG:
		rv = xQueueReceiveFromISR(port->tx_queue, &c, &yield);
		if (xQueueIsQueueEmptyFromISR(port->tx_queue)) {
			signed portBASE_TYPE sema_yield = pdFALSE;
			port->usci->ie &= ~UCTXIE;
			xSemaphoreGiveFromISR(port->tx_idle_sema, &sema_yield);
			yield |= sema_yield;
		}
		if (rv) {
			++port->num_tx;
			port->usci->txbuf = c;
		}
		break;
	case USCI_UCRXIFG:
		c = port->usci->rxbuf;
		++port->num_rx;
		rv = xQueueSendToBackFromISR(port->rx_queue, &c, &yield);
		break;
	}
	portYIELD_FROM_ISR(yield);
}
bool sensorcommunication_sensorIntQueueEmptyISR()
{
	BaseType_t retval;
	retval = xQueueIsQueueEmptyFromISR(sensorcommunicationData.sensorIntQueue);
	if(retval == pdTRUE)
		return true;
	else
		return false;
}
Example #3
0
wiced_result_t wiced_rtos_is_queue_empty( wiced_queue_t* queue )
{
    signed portBASE_TYPE result;

    taskENTER_CRITICAL();
    result = xQueueIsQueueEmptyFromISR( *queue );
    taskEXIT_CRITICAL();

    return ( result != 0 ) ? WICED_SUCCESS : WICED_ERROR;
}
Example #4
0
/* TODO:  Add any necessary local functions.
*/
char isQueueEmpty()
{
    if(pdFALSE == xQueueIsQueueEmptyFromISR(msg_taskData.sendMsg_q))
    {
        return 0;
    }
    else
    {
        return 1;
    }
}
Example #5
0
bool UsbSerial::available() {
	return !xQueueIsQueueEmptyFromISR(rx_queue);
}
Example #6
0
/** Audio ISR (FIFO)
 *
 *
 * Parameters:
 * @param pThisArg  Initialized Audio (TX/RX) object
 *
 * @return None 
 */
void audioRxTx_isr(void *pThisArg) {
	audioRxTx_t *pThis = (audioRxTx_t*) pThisArg;
	chunk_d_t *pChunk = NULL;
	unsigned int samplesInChunk;

	/* Read FIFO Interrupt Status */
	unsigned int intStatus =
			*(volatile u32 *) (FIFO_BASE_ADDR + FIFO_INT_STATUS);

	/* Tx FIFO programmable empty hit */
	if (intStatus & FIFO_INT_TFPE) {
		/* clear TFPE interrupt */
		*(volatile u32 *) (FIFO_BASE_ADDR + FIFO_INT_STATUS) = FIFO_INT_TFPE;

		/* Check if Tx queue is EMPTY
		 *  - set signal that ISR is not running
		 *  - return */
		if (xQueueIsQueueEmptyFromISR(pThis->tx_queue) != pdFALSE) {
			pThis->running = 0; /* indicate that ISR is no longer running */
			return;
		}

		// Tx Queue is not empty - Receive pointer to the next chunk.
		xQueueReceiveFromISR(pThis->tx_queue, &pChunk, NULL);

		/* how many samples does the chunk contain ? */
		samplesInChunk = pChunk->bytesUsed/sizeof(unsigned int);

		// This check might not really be needed - as we have recieved a TPFE trigger from FIFO
		if (samplesInChunk  > (*(volatile u32 *) (FIFO_BASE_ADDR + FIFO_TX_VAC))) {
			printf("audioTx_isr: insufficient space in FIFO\n");
			// should anyway never happen

			// if TX FIFO Does not have the space promised, just drop the chunk
			bufferPool_d_release_from_ISR(pThis->pBuffP, pChunk);
			return;
		}
		/* Transmit the chunk data to the TX FIFO */
		u32 samplNr = 0;
		for (samplNr = 0; samplNr < samplesInChunk; samplNr++) {

			*(volatile u32 *) (FIFO_BASE_ADDR + FIFO_TX_DATA) =
					((unsigned int)pChunk->u16_buff[samplNr]) << 16;
			*(volatile u32 *) (FIFO_BASE_ADDR + FIFO_TX_LENGTH) = 0x1;
		}

		/* Return chunk to buffer pool free list */
		bufferPool_d_release_from_ISR(pThis->pBuffP, pChunk);
	}

														/* RX FIFO programmable Full hit */
	if (intStatus & FIFO_INT_RFPF) {
		/* Clear RFPF interrupt */
		*(volatile u32 *) (FIFO_BASE_ADDR + FIFO_INT_STATUS) = FIFO_INT_RFPF;
		/* is Queue is full ? */
		if ((xQueueIsQueueFullFromISR(pThis->rx_queue)) != pdFALSE) {
			printf(
					"The RX queue is full, and no more incoming data could be captured\n");
			*(volatile u32 *) (FIFO_BASE_ADDR + FIFO_INT_ENABLE) = 0x0;
			return;
		}

		while (bufferPool_d_acquire_ISR(pThis->pBuffP, &pChunk) != 1) {
			printf("RX ISR: buffer pool empty\n\n\n\n\n");
			*(volatile u32 *) (FIFO_BASE_ADDR + FIFO_INT_ENABLE) = 0x0;
			return;
		}

		// How many samples in FIFO?
		samplesInChunk =  *(volatile u32 *) (FIFO_BASE_ADDR + FIFO_RX_OCC);

		// more samples in FIFO than fitting into chunk? Limit
		if(samplesInChunk > pChunk->bytesMax/4){
			samplesInChunk = pChunk->bytesMax/4;
		}

		/* Read the Audio RX samples.*/
		u32 samplNr = 0;
		for (samplNr = 0; samplNr < samplesInChunk; samplNr++) {

			// read from FIFO and right shift by 16 (8 LSBs are 0 anyway, plus we want to use 16 bit only).
			// symmetric to tx side.
			pChunk->u16_buff[samplNr] = (unsigned short) ((*(volatile u32 *) (FIFO_BASE_ADDR
			                                        + FIFO_RX_DATA)) >> 16);
		}

		/* indicate max fill level */
		pChunk->bytesUsed= samplesInChunk * 4;

		xQueueSendFromISR( pThis->rx_queue, &pChunk, NULL);
		return;

	}