Example #1
0
//Обработчик прерываний от DMA2_Channel3 
// will be called with 195.3125 Hz frequence
//==============================================================================
void DMA2_Channel3_IRQHandler(void)     //DAC_Channel1
{  
  sOscParam temp;
  portBASE_TYPE rez;
         
  //if(DMA_GetITStatus(DMA2_IT_HT3) || DMA_GetITStatus(DMA2_IT_TC3)) 
  if( ( DMA2->ISR & 0x400 ) || // ( 1 << 10 )
      ( DMA2->ISR & 0x200 )    // ( 1 << 9 )
    )
  {       
    //информируем, что сообщение пришло от DMA ISR  
    temp.Sig_Type = 7; 
    
    //обязятельно !!!
    rez = pdFALSE;
    
    //посылаем в "голову" очереди
    xQueueSendToFrontFromISR( qTo_Osc, (void *)&temp, &rez );
  
    //если в результате посылки сообщения была разблокирована задача, более приоритетная, чем та,
    //которую прервало данное прерывание, то переключаем контекст не дожидаясь окончания кванта времени 
    if( rez == pdTRUE )
    {
      portEND_SWITCHING_ISR( rez );
    }
  }
  
  //сбрасываем флаг прерывания global interrupt 3 канала DMA 2
  //DMA2->IFCR = (1<<8);//DMA2_IT_GL3; 
  DMA2->IFCR |= 0x100; //DMA2_IT_GL3;  may led to unnormaly work
}
Example #2
0
/******************************************************************************
 * Function: RtlMailboxSendToFront
 * Desc: To put a message block to the head of a 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 RtlMailboxSendToFront(
    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 = xQueueSendToFrontFromISR(pMbox->mbox_hdl, (void *)pMsg, NULL);//(portTickType) wait_ticks);
    }
    else {
        ret = xQueueSendToFront(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: eCos has no API to put message to the head of a mailbox
#endif

}
Example #3
0
AJ_Status AJ_QueuePushFromISR(struct AJ_Queue* q, void* data)
{
    uint8_t hasWoken;
    uint8_t ret;
    if (q && q->q && data) {
        ret = xQueueSendToFrontFromISR(q->q, data, &hasWoken);
    }
    return AJ_OK;
}
Example #4
0
void EXTI0_IRQHandler(void)
{
	if(EXTI_GetITStatus(EXTI_Line0) != RESET)
	{
		xQueueSendToFrontFromISR(xQueue, &c, NULL);

		/* Clear the EXTI line 0 pending bit */
		EXTI_ClearITPendingBit(EXTI_Line0);
	}
}
Example #5
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;
}
Example #6
0
/** \brief
*/
extern uint32_t WGT_SendMessageISR( uint32_t dwMsgID, uint32_t dwParam1, uint32_t dwParam2 )
{
    SWGTCoreMessage sMsg ;

    sMsg.dwID=dwMsgID ;
    sMsg.dwParam1=dwParam1 ;
    sMsg.dwParam2=dwParam2 ;

    // Send message
    if ( xQueueSendToFrontFromISR( g_WGT_CoreData.hMessagesQueue, &sMsg, NULL ) != pdPASS )
    {
        return SAMGUI_E_MSQUEUE ;
    }

    return SAMGUI_E_OK ;
}
Example #7
0
void vApplicationTickHook(void)
{
	static int iCount = 0;
	portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;

	// Print out a message every 200 ticks. The message is not written out
	// directly, but sent to the gatekeeper task.
	iCount++;
	if (iCount >= 200)
	{
		// In this case the last parameter (xHigherPriorityTaskWoken) is not
		// actually used but must still be supplied.
		xQueueSendToFrontFromISR(xPrintQueue,
								&pcStringsToPrint[2],
								&xHigherPriorityTaskWoken);

		// Reset the count ready to print out the string again in 200 ticks
		// time.
		iCount = 0;
	}
}
Example #8
0
/* public (unofficial) functions */
void TIM2_IRQHandler(void)
{
  int i;
  portBASE_TYPE xTaskWokenByPost = pdFALSE;
  static measure_data_t buffer[] =
  {
    { { 0 }, input_channel0, 0 }
    /* code in display does not support multi-channel */
	#if 0
    ,{ { 0 }, input_channel1, 0 }
	#endif
  };
  static unsigned timestamp = 0;

  TIM_ClearITPendingBit( TIM2, TIM_IT_Update );
  
  for(i=0; i<sizeof(buffer)/sizeof(buffer[0]); i++)
  {
    buffer[i].data[timestamp] = read_channel(buffer[i].ch);
  }
  timestamp++;

  if(timestamp == API_MEASURE_DATA_CHUNK_SIZE)
  {
    timestamp = 0;
    for(i=0; i<sizeof(buffer)/sizeof(buffer[0]); i++)
    {
      xQueueSendToFrontFromISR(
          irq_transfer,
          &buffer+i,
          &xTaskWokenByPost);
      buffer[i].timestamp += API_MEASURE_DATA_CHUNK_SIZE;
    }

#if 0/* this is in the example code but make it application unstable */
    if(xTaskWokenByPost)
      taskYIELD();
#endif
  }
}
Example #9
0
/*..........................................................................*/
void QActive_postLIFO(QActive *me, QEvent const *e) {
    portBASE_TYPE err;
    QF_INT_LOCK_KEY_
    QF_INT_LOCK_();
    if (e->dynamic_ != (uint8_t)0) {
        ++((QEvent *)e)->dynamic_;
   	 }
    QF_INT_UNLOCK_();

//  	err = xQueueSendToFront(me->eQueue, &e, (portTickType)0);
#define XXX
#ifdef XXX
	if (ulCriticalNesting == (unsigned portLONG)0) { /* task level? */
			err = xQueueSendToFront(me->eQueue, &e, (portTickType)0);
	}
	else  { /* must be ISR level */
		portBASE_TYPE xHigherPriorityTaskWoken;
		err = xQueueSendToFrontFromISR(me->eQueue, &e,&xHigherPriorityTaskWoken);
	}

#endif
	Q_ASSERT(err == pdPASS);

 }