Exemple #1
0
/* IRQ handler to handle USART2 interruptss (both transmit and receive
 * interrupts). */
void USART2_IRQHandler()
{
	static signed portBASE_TYPE xHigherPriorityTaskWoken;

	/* If this interrupt is for a transmit... */
	if (USART_GetITStatus(USART2, USART_IT_TXE) != RESET) {
		/* "give" the serial_tx_wait_sem semaphore to notfiy processes
		 * that the buffer has a spot free for the next byte.
		 */
		xSemaphoreGiveFromISR(serial_tx_wait_sem, &xHigherPriorityTaskWoken);

		/* Diables the transmit interrupt. */
		USART_ITConfig(USART2, USART_IT_TXE, DISABLE);
		/* If this interrupt is for a receive... */
	}else if(USART_GetITStatus(USART2, USART_IT_RXNE) != RESET){
		char msg = USART_ReceiveData(USART2);

		/* If there is an error when queueing the received byte, freeze! */
		if(!xQueueSendToBackFromISR(serial_rx_queue, &msg, &xHigherPriorityTaskWoken))
			while(1);
	}
	else {
		/* Only transmit and receive interrupts should be enabled.
		 * If this is another type of interrupt, freeze.
		 */
		while(1);
	}

	if (xHigherPriorityTaskWoken) {
		taskYIELD();
	}
}
Exemple #2
0
/*
 * UART rx Interrupt routine
 */
static void uart_isr(void *arg)
{
	uint8_t temp;
	signed portBASE_TYPE ret;
	portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
	if (UART_RXFIFO_FULL_INT_ST != (READ_PERI_REG(UART_INT_ST(UART0)) & UART_RXFIFO_FULL_INT_ST))
	{
		return;
	}
	WRITE_PERI_REG(UART_INT_CLR(UART0), UART_RXFIFO_FULL_INT_CLR);

    while (READ_PERI_REG(UART_STATUS(UART0)) & (UART_RXFIFO_CNT << UART_RXFIFO_CNT_S)) {
		temp = READ_PERI_REG(UART_FIFO(UART0)) & 0xFF;
		ret = xQueueSendToBackFromISR
                    (
                        uart_rx_queue,
						&temp,
                        &xHigherPriorityTaskWoken
                    );
		if (ret != pdTRUE)
		{
			uart_rx_overruns++;
		} 
		else
		{
			uart_rx_bytes++;
		}
	}
	portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
}
Exemple #3
0
/**
 * ADC12 Interrupt service routine
 * Execute once the 6 ADCs have been sampled
 */
interrupt(ADC12_VECTOR) adc12irq(void) {
	uint16_t iv;
	iv = ADC12IV;

	if (iv == 16) {
		if (data_frame.length < SAMPLE_MAX) {
			for (iv = 0; iv < 6; iv++) {
				data_frame.measures[data_frame.length][iv] = ADC12MEMx[iv];
			}
			data_frame.length++;
			data_frame.seq++;

			if (data_frame.length == SAMPLE_MAX) {
				uint16_t event = SEND;
				portBASE_TYPE yield;
				xQueueSendToBackFromISR(xDataQueue, &event, &yield);
				if (yield) {
					taskYIELD();
				}
			}
		} else {
			data_frame.seq++;
			ADC12IFG = 0;
		}
	} else {
		ADC12IFG = 0;
	}

}
Exemple #4
0
void QActive_postFIFO(QActive *me, QEvent const *e) {
	portBASE_TYPE err;
    QF_INT_LOCK_KEY_
#ifdef YYY
    QF_INT_LOCK_();
    if (e->dynamic_ != (uint8_t)0) {
        ++((QEvent *)e)->dynamic_;
    }
    QF_INT_UNLOCK_();
#endif
 //  	 err = xQueueSendToBack(me->eQueue, &e, (portTickType)0);
#define XXX
#ifdef XXX
	if (ulCriticalNesting == (unsigned portLONG)0) { /* task level? */
		     QF_INT_LOCK_();
  			  if (e->dynamic_ != (uint8_t)0) {
      		  ++((QEvent *)e)->dynamic_;
 			   }
  			  QF_INT_UNLOCK_();
			 err = xQueueSendToBack(me->eQueue, &e, (portTickType)0);
	}
	else { /* must be ISR level */
		portBASE_TYPE xHigherPriorityTaskWoken;
		err = xQueueSendToBackFromISR(me->eQueue, &e,&xHigherPriorityTaskWoken);
	}

#endif
   Q_ASSERT(err == pdPASS);
}
		void TIMER1_IRQHandler(void) {
			if(Chip_TIMER_MatchPending(LPC_TIMER1, 1)) {
				AdcEvent event = AdcEvent::ADC_SCAN;
				Chip_TIMER_ClearMatch(LPC_TIMER1, 1);
				xQueueSendToBackFromISR(event_queue, &event, 0);
			}
		}
bool ISR_LineSend_16(unsigned char ucFrame,unsigned char ucLine,unsigned short* pLine, unsigned long ulLength)
{
	portBASE_TYPE ptRet;
	unsigned char* pBuf;
	ptRet = xQueueReceiveFromISR(s_QueueBuff,&pBuf,0);
	if (ptRet != pdPASS)
		return false;
	
	ASSERT(ulLength==512);
	pBuf[0] = ucFrame;
	pBuf[1] = ucLine;
	unsigned char* pDst = &pBuf[2];
	unsigned short* pSrc = pLine;
	for (int i=0;i<ulLength;i++) {
		*pDst = ((*pSrc) & (0x00FF<<7)) >> 7;
		++pDst;
		++pSrc;
	}
	//memcpy(&pBuf[2],pLine,512);
	
	ptRet = xQueueSendToBackFromISR(s_QueueLine,&pBuf,0);
	ASSERT(ptRet == pdPASS);
	
	return true;
}
unsigned char sensorcommunication_getByteISR()
{
	COMMUNICATION_MESSAGE theMessage;
	if(xQueueReceiveFromISR(sensorcommunicationData.sensorIntQueue, (void*)&(theMessage), 0))
	{
		int i = 0;
		if( theMessage.type == sensorcommunicationData.sensorIntRxMsgSeq)
		{
			sensorcommunicationData.sensorRxMsgSeq++;
			return theMessage.msg;
		}
		else
		{
			while( theMessage.type != sensorcommunicationData.sensorIntRxMsgSeq)
			{
				i++;																		
				if(i == COMMUNICATIONQUEUESIZE)
				{
					xQueueReset(sensorcommunicationData.sensorIntQueue);	//clear queue. we dropped the packet
				}
				xQueueSendToBackFromISR(sensorcommunicationData.sensorIntQueue, (void*)&(theMessage), 0);	//send to back
				xQueueReceiveFromISR(sensorcommunicationData.sensorIntQueue, (void*)&(theMessage), 0 );	//get another
			}
			debugU("COM message loaded\n");
			return theMessage.msg;
		}
	}
}
Exemple #8
0
/**
 *
 * @brief   Appends an item to a queue from ISR context.
 *
 * @param[in] queuep       pointer to instance of @p struct pios_queue
 * @param[in] itemp        pointer to item which will be appended to the queue
 * @param[in] timeout_ms   timeout for appending item to queue in milliseconds
 *
 * @returns true on success or false on timeout or failure
 *
 */
bool PIOS_Queue_Send_FromISR(struct pios_queue *queuep, const void *itemp, bool *wokenp)
{
	portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
	portBASE_TYPE result = xQueueSendToBackFromISR((xQueueHandle)queuep->queue_handle, itemp, &xHigherPriorityTaskWoken);
	*wokenp = *wokenp || xHigherPriorityTaskWoken == pdTRUE;
	return result == pdTRUE;
}
Exemple #9
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);
}
Exemple #10
0
void USART2_IRQHandler( void )
{
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
char cChar;

	if( USART_GetITStatus( USART2, USART_IT_TXE ) == SET )
	{
		/* The interrupt was caused by the THR becoming empty.  Are there any
		more characters to transmit? */
		if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE )
		{
			/* A character was retrieved from the queue so can be sent to the
			THR now. */
			USART_SendData( USART2, cChar );
			while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);
		}
		else
		{
			USART_ITConfig( USART2, USART_IT_TXE, DISABLE );		
		}		
	}
	
	if( USART_GetITStatus( USART2, USART_IT_RXNE ) == SET )
	{
		cChar = USART_ReceiveData( USART2 );
		xQueueSendToBackFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken );
	}	
	
	portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
}
Exemple #11
0
/******************************************************************************
 * Function: RtlMailboxSendToBack
 * Desc: To put a message block to the tail of a given mailbox.
 * Para:
 *  MboxID: The identifier of the target mailbox.
 *  pMsg: The pointer of the message block to be put into the mailbox.
 *  MSToWait: If the mailbox is full, this value gives a time to wait to put 
 *            this message. The time unit is millisecond. 
 *            The special values are: 
 *               0: no waiting; 
 *               0xffffffff: wait without timeout. 
 *            If the waiting is timeout, the message sending is failed and 
 *            return _FAIL.
 *  IsFromISR: Is this function is called from an ISR ?
 * Return: _SUCCESS or _FAIL.
 ******************************************************************************/
u8 RtlMailboxSendToBack(
    IN u8 MboxID, 
    IN MSG_BLK *pMsg, 
    IN u32 MSToWait, 
    IN u8 IsFromISR
)
{
    RTL_MAILBOX *pMbox=NULL;
    u32 wait_ticks;
#ifdef PLATFORM_FREERTOS
    portBASE_TYPE ret;
#endif

    pMbox = RtlMBoxIdToHdl(MboxID);

    if (NULL == pMbox) {
   	    MSG_MBOX_ERR("RtlMailboxSendToBack: Didn't find matched MBoxID=%d\n", MboxID);
        return _FAIL;
    }

#ifdef PLATFORM_FREERTOS
    if (MBOX_WAIT_NO_TIMEOUT == MSToWait) {
        wait_ticks = portMAX_DELAY;
    }
    else if (MBOX_WAIT_NONE == MSToWait) {
        wait_ticks = 0;
    }
    else {
        wait_ticks = ((MSToWait/portTICK_RATE_MS)>0)?(MSToWait/portTICK_RATE_MS):(1);
    }

    if (IsFromISR) {
        ret = xQueueSendToBackFromISR(pMbox->mbox_hdl, (void *)pMsg, NULL);//(portTickType) wait_ticks);
    }
    else {
        ret = xQueueSendToBack(pMbox->mbox_hdl, (void *)pMsg, (portTickType) wait_ticks);
    }
    
    if(ret != pdPASS ) {
        // send message to the queue failed
   	    MSG_MBOX_ERR("RtlMailboxSendToBack: Put Msg to Queue Failed, MBoxID=%d\n", MboxID);
        ret = _FAIL;
    }
    else {
        // try to give a semaphore to wake up the receiving task
        if (pMbox->pWakeSema) {
            RtlUpSema(pMbox->pWakeSema);  
        }
        ret = _SUCCESS;
    }

    return ret;
#endif

#ifdef PLATFORM_ECOS
    // TODO: Put the message to a mailbox
#endif

}
void HardwareSerial::uartReceiveInterruptHandler(void *para)
{
    /* uart0 and uart1 intr combine togther, when interrupt occur, see reg 0x3ff20020, bit2, bit0 represents
     * uart1 and uart0 respectively
     */
    HardwareSerial* Self = hardwareSerialObjects[UART_ID_0];
    uint8 RcvChar;

    if (UART_RXFIFO_FULL_INT_ST != (READ_PERI_REG(UART_INT_ST(UART_ID_0)) & UART_RXFIFO_FULL_INT_ST))
        return;

    WRITE_PERI_REG(UART_INT_CLR(UART_ID_0), UART_RXFIFO_FULL_INT_CLR);

    while (READ_PERI_REG(UART_STATUS(UART_ID_0)) & (UART_RXFIFO_CNT << UART_RXFIFO_CNT_S))
    {
        RcvChar = READ_PERI_REG(UART_FIFO(UART_ID_0)) & 0xFF;

        /* you can add your handle code below.*/
        if (Self->useRxBuff)
        {
            Self->rxBuffer.Push(RcvChar);
        }

        if ((Self->HWSDelegate) || (Self->commandExecutor))
        {
            SerialDelegateMessage serialDelegateMessage;
            serialDelegateMessage.uart = Self->uart;
            serialDelegateMessage.rcvChar = RcvChar;
            serialDelegateMessage.charCount = Self->rxBuffer.Len();

            if (Self->HWSDelegate)
            {
//        	  system_os_post(USER_TASK_PRIO_0, SERIAL_SIGNAL_DELEGATE, serialQueueParameter);
                serialDelegateMessage.type = SERIAL_SIGNAL_DELEGATE;
                xQueueSendToBackFromISR ( serialDelegateQueue, &serialDelegateMessage, NULL);
            }
            if (Self->commandExecutor)
            {
//        	  system_os_post(USER_TASK_PRIO_0, SERIAL_SIGNAL_COMMAND, serialQueueParameter);
                serialDelegateMessage.type = SERIAL_SIGNAL_COMMAND;
                xQueueSendToBackFromISR ( serialDelegateQueue, &serialDelegateMessage, NULL);
            }
        }
    }
}
Exemple #13
0
bool_t mac_queue_send_from_isr(osel_event_t *msg)
{
    portBASE_TYPE res = xQueueSendToBackFromISR(mac_queue, msg, 0); //*< send wait for 10s max
    if (res == errQUEUE_FULL)
    {
        return FALSE;
    }

    return TRUE;
}
Exemple #14
0
static uint16_t measure_time(void) {
	uint16_t event = MEASURE;
	portBASE_TYPE woken = pdFALSE;
	xQueueSendToBackFromISR(xDataQueue, &event, &woken);

	if (woken == pdTRUE) {
		taskYIELD();
	}

	return 0;
}
/*!
 * \brief Queues a message to be sent to the radio transceiver.
 *
 * \param buf Pointer to the message data to be sent.
 * \param bufSize Size of buffer.
 * \param payloadSize Size of payload data.
 * \param fromISR If called from an ISR routine.
 * \param isTx If message is TX or RX.
 * \param flags Packet flags.
 *
 * \return Error code, ERR_OK if message has been queued.
 */
static uint8_t QueuePut( uint8_t *buf, size_t bufSize, size_t payloadSize, bool fromISR, bool isTx,
        bool toBack, uint8_t flags )
{
    /* data format is: dataSize(8bit) data */
    uint8_t res = ERR_OK;
    xQueueHandle queue;
    BaseType_t qRes;

    if ( bufSize != LORAPHY_BUFFER_SIZE ) {
        return ERR_OVERFLOW; /* must be exactly this buffer size!!! */
    }

    if ( isTx ) {
        queue = msgTxQueue;
    } else {
        queue = msgRxQueue;
    }

    LORAPHY_BUF_FLAGS(buf) = flags;
    LORAPHY_BUF_SIZE(buf) = (uint8_t) payloadSize;

#if(LORAMESH_DEBUG_OUTPUT_PAYLOAD == 1)
    LOG_TRACE("LoRaPhy %s - Size %d", __FUNCTION__, payloadSize);
    LOG_TRACE_BARE("\t");
    for ( uint8_t i = 0; i < (payloadSize + 2); i++ )
    LOG_TRACE_BARE("0x%02x ", buf[i]);
    LOG_TRACE_BARE("\r\n");
#endif

    if ( fromISR ) {
        signed portBASE_TYPE
        pxHigherPriorityTaskWoken;

        if ( toBack ) {
            qRes = xQueueSendToBackFromISR(queue, buf, &pxHigherPriorityTaskWoken);
        } else {
            qRes = xQueueSendToFrontFromISR(queue, buf, &pxHigherPriorityTaskWoken);
        }
        if ( qRes != pdTRUE ) {
            /* was not able to send to the queue. Well, not much we can do here... */
            res = ERR_BUSY;
        }
    } else {
        if ( toBack ) {
            qRes = xQueueSendToBack(queue, buf, MSG_QUEUE_PUT_WAIT);
        } else {
            qRes = xQueueSendToFront(queue, buf, MSG_QUEUE_PUT_WAIT);
        }
        if ( qRes != pdTRUE ) {
            res = ERR_BUSY;
        }
    }
    return res;
}
Exemple #16
0
//------------------------------------------------------------------------------
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
	char cIn = 'a';
	BaseType_t highPriorityTaskWoken = pdFALSE;

	if (htim == &timer2Handle) {
        if (commQueue1 != NULL) {
        	xQueueSendToBackFromISR(commQueue1, &cIn, &highPriorityTaskWoken);
        }
	}
}
void USART3_IRQHandler(void)
{
    volatile char temp = 0;
    BaseType_t xHigherPriorityTaskWoken, xResult;

    // xHigherPriorityTaskWoken must be initialised to pdFALSE.
    xHigherPriorityTaskWoken = pdFALSE;
    
    if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET)
    {
        temp = USART_ReceiveData(USART3);
        xResult = xQueueSendToBackFromISR(uart3_rx_queue, (void *)&temp, &xHigherPriorityTaskWoken);
        if (errQUEUE_FULL == xResult)
        {
            //TODO: do something.
//            __ASM("nop;");
        }
        if(USART_GetFlagStatus(USART3, USART_FLAG_ORE) != RESET)
        {
            USART_ClearFlag(USART3, USART_FLAG_ORE);
            USART_ReceiveData(USART3);
        }
    }
  
    if(USART_GetITStatus(USART3, USART_IT_TXE) != RESET)
    {
        xResult = xQueueReceiveFromISR(uart3_tx_queue, (void *)&temp, &xHigherPriorityTaskWoken);
        if (pdPASS == xResult)
        {
            USART_SendData(USART3, temp);
        }
        else //empty
        {
            USART_ITConfig(USART3, USART_IT_TXE, DISABLE);
        }
    }
    
    // error happen
    if(USART_GetITStatus(USART3, USART_IT_PE) != RESET)
    {
        USART_ClearITPendingBit(USART3, USART_IT_PE);
//        udprintf("\r\n===============Uart3.Parity error");
    }
    
    if(USART_GetITStatus(USART3, USART_IT_FE | USART_IT_NE) != RESET)
    {
        USART_ClearITPendingBit(USART3, USART_IT_FE | USART_IT_NE);
    }

    if(xHigherPriorityTaskWoken)
    {
        taskYIELD ();
    }
}
Exemple #18
0
// this is the interrupt request handler (IRQ) for ALL USART1 interrupts
void USART1_IRQHandler(void)
{

	// check if the USART1 receive interrupt flag was set
	if( USART_GetITStatus(USART1, USART_IT_RXNE) )
	{
		char t = USART1->DR; // the character from the USART1 data register is saved in t

		if (_p_queue_uart_char)
			xQueueSendToBackFromISR(*_p_queue_uart_char, &t, 0);
	}
}
Exemple #19
0
void CAN1_RX0_IRQHandler(void)
{
	CanRxMsg RxMessage;
	static portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
	if (CAN_GetITStatus (CAN1, CAN_IT_FMP0))
	{
		CAN_Receive(CAN1, CAN_FIFO0, &RxMessage);
		if ((RxMessage.StdId == CAN_SLAVE_STD_ID) && (RxMessage.IDE == CAN_ID_STD) && (RxMessage.DLC == CAN_DATA_LENGTH))
		xQueueSendToBackFromISR(CanRxQueue, &RxMessage, &xHigherPriorityTaskWoken);
	}
	portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
}
Exemple #20
0
void SProxy::commMessageReceived(EComponentID sender)
{
	CMessage msg(sender,
			     EComponentID::COMM_COMP,
				 ECommEvent::EV_COMM_MSG_RECEIVED);
	if(errQUEUE_FULL == xQueueSendToBackFromISR(mCommComp.mQueue,
												static_cast<void*>(&msg),
												0U))
	{
		//Diagevent
	}
}
Exemple #21
0
void onDataPacketReceived(){
	if(SEC_HMAC_verify(&shh,&frame,HMAC_LENGTH,frame.digest)==SEC_STATE_HMAC_VERIFY_OK){
		//		xQueueSendToBack(SN_tx_queue,&ap_package,MAX_WAIT);
		NetPackage pNetPackage;
		memcpy(&pNetPackage,frame.msg,16);
		xQueueSendToBackFromISR(SN_mng_queue , &pNetPackage, pdFALSE);
	}
	else{
		//Butta la frame
		//LOG
	}
}
Exemple #22
0
void SProxy::timerCallback()
{
	CMessage msg(EComponentID::CONTROL_COMP,
				 EComponentID::CONTROL_COMP,
				 EControlEvent::EV_TIMER);
	if(errQUEUE_FULL == xQueueSendToBackFromISR(mControlComp.mQueue,
												static_cast<void*>(&msg),
												0U))
	{
		//Diagevent
	}
}
Exemple #23
0
static void associated(void) {
	uint16_t event = ASSOCIATED;
	portBASE_TYPE woken = pdFALSE;

	printf("asso\n");

	xQueueSendToBackFromISR(xDataQueue, &event, &woken);

	if (woken == pdTRUE) {
		taskYIELD();
	}
}
Exemple #24
0
void USART1_IRQHandler(void)
{
	xData ReceiveData;
	static portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
	ReceiveData.ID = USART_ID;
	if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
	{
		ReceiveData.Value =(unsigned char)USART_ReceiveData(USART1);
		xQueueSendToBackFromISR(RxQueue, &ReceiveData, &xHigherPriorityTaskWoken);
		xSemaphoreGiveFromISR(UART_xCountingSemaphore, &xHigherPriorityTaskWoken);
	}
	portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);
}
Exemple #25
0
/* Interrupt Handlers --------------------------------------------------------*/
void CTP_INT_Callback()
{
#if defined(MULTIPLE_TOUCH_POINTS)
	uint8_t numOfPoints = 0;
	uint8_t data = FT5206_REGISTER_TD_STATUS;
	I2C2_TransmitFromISR(FT5206_ADDRESS, &data, 1);
	I2C2_ReceiveFromISR(FT5206_ADDRESS, &numOfPoints, 1);

	uint32_t i;
	for (i = 0; i < numOfPoints; i++)
	{
		uint8_t reg = prvBaseRegisterForPoint[i];
		I2C2_TransmitFromISR(FT5206_ADDRESS, &reg, 1);
		uint8_t storage[4] = {0x00};
		I2C2_ReceiveFromISR(FT5206_ADDRESS, storage, 4);

		LCDEventMessage message;
		message.event = LCDEvent_TouchEvent;
		message.data[0] = ((storage[0] & 0x0F) << 8) | storage[1];
		message.data[1] = ((storage[2] & 0x0F) << 8) | storage[3];
		message.data[2] = (storage[0] & 0xC0) >> 6;
		message.data[3] = i+1;
		xQueueSendToBackFromISR(xLCDEventQueue, &message, NULL);
	}
#else
	uint8_t reg = prvBaseRegisterForPoint[FT5206Point_1 - 1];
	I2C2_TransmitFromISR(FT5206_ADDRESS, &reg, 1);
	uint8_t storage[4] = {0x00};
	I2C2_ReceiveFromISR(FT5206_ADDRESS, storage, 4);

	LCDEventMessage message;
	message.event = LCDEvent_TouchEvent;
	message.data[0] = ((storage[0] & 0x0F) << 8) | storage[1];
	message.data[1] = ((storage[2] & 0x0F) << 8) | storage[3];
	message.data[2] = (storage[0] & 0xC0) >> 6;
	message.data[3] = FT5206Point_1;
	xQueueSendToBackFromISR(xLCDEventQueue, &message, NULL);
#endif
}
Exemple #26
0
static uint16_t xRxOk_cb(void)
{
    uint16_t xHigherPriorityTaskWoken;
    uint8_t event = EVENT_FRAME_RECEIVED;

    xQueueSendToBackFromISR(xEvent, &event, &xHigherPriorityTaskWoken);

    if (xHigherPriorityTaskWoken)
    {
        vPortYield();
        return 1;
    }
    return 0;
}
/**
  * @brief  Receives an amount of data in non blocking mode
  * @param  huart: pointer to a UART_HandleTypeDef structure that contains
  *                the configuration information for the specified UART module.
  * @retval HAL status
  */
void vUARTReceive(UART_HandleTypeDef *pxUARTHandle)
{
  BaseType_t xHigherPriorityWoken;

  /* copy data */
  pcInputBuffer[ucInputIndex] = (uint8_t)(pxUARTHandle->Instance->DR & (uint8_t)0x00FF);


  /* if the received character is newline */
  if (pcInputBuffer[ucInputIndex] == (uint8_t)'\n')
  {
    /* put null */
    pcInputBuffer[ucInputIndex+1] = (uint8_t)'\0';
    /* Put in the queue */
    xQueueSendToBackFromISR(qUARTReceive, (void*) pcInputBuffer, &xHigherPriorityWoken);
    /* TODO: what if the Queue is full? */
    ucInputIndex = 0;
    portYIELD_FROM_ISR(xHigherPriorityWoken);
    return;
  }
  /* Increase the buffer index */
  ucInputIndex += 1;
  /* if the index buffer reaches the boundary */
  if (ucInputIndex == confUART_RECEIVE_BUFFER_SIZE-1)
  {
    /* put null */
    pcInputBuffer[ucInputIndex] = (uint8_t)'\0';
    /* TODO: What if the end of line is without \n? what happened to scanf()? */
    /* Put in the queue */
    xQueueSendToBackFromISR(qUARTReceive, (void*) pcInputBuffer, &xHigherPriorityWoken);
    /* TODO: what if the Queue is full? */
    ucInputIndex = 0;
    portYIELD_FROM_ISR(xHigherPriorityWoken);
    return;
  }
  return;
}
	void uart_read_handler(UartError status, uint8_t *data, uint16_t len)
	{
		Event e;
		e.type = READ_EVENT;
		e.length = 1;

		e.data[0] = data[0];
		BaseType_t task_woken = pdFALSE;
		xQueueSendToBackFromISR(event_queue, &e, &task_woken);
		uart->read_async(1, uart_read_del);

		if(task_woken) {
			vPortYield();
		}
	}
Exemple #29
0
//------------------------------------------------------------------------------
void TIM2_IRQHandler(void) 
{
	char cIn = 'a';
	BaseType_t highPriorityTaskWoken = pdFALSE;
	
	if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET) {
		TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
		//queue_push(&events, EV_TIMER1);
		
		xQueueSendToBackFromISR(commQueue1, &cIn, &highPriorityTaskWoken);
#if 0
		toggle_LED2;
#endif	
	}
}
Exemple #30
0
// ISR to handle serial reception
void LEA6T_UartHandler(LEA6T* gps)
{
    static unsigned char data = 0;

    if(gps->usart->SR & USART_FLAG_RXNE)
    {
        data = gps->usart->DR;
        //printf("%c", data);
        xQueueSendToBackFromISR(gps->rxQueue, &data, 0);
    }/*
    else if(gps->usart->SR & USART_FLAG_TC)
	{
        printf("\r\nTransmit complete?!?\r\n");
	}*/
}