示例#1
0
// Interrupt routine
nodebug root interrupt void Tmr_A_isr()
{
    char TMRA_status;                    // This will hold the interrupt flags
    TMRA_status = RdPortI(TACSR);        // Read interrupt flags and store to TMRA_status
    // Timer A demultiplexing
    if (TMRA_status & TMA7_MASK) {       // if Timer A7 has trigered
        count_TMRA7++;
        if (count_TMRA7 == MAX_COUNT) {  // if Timer A7 has interrupted the CPU 100 times
            display_count[2]++;          // increment corresponding display counter
            count_TMRA7 = 0;             // clear Timer A7 counter
            OSSemPost(TimerSem[2]);      // Post a semaphore for Timer A7 counter
        }
    }
    if (TMRA_status & TMA6_MASK) {       // if Timer A6 has trigered
        count_TMRA6++;                   // increment Timer A6 counter
        if (count_TMRA6 == MAX_COUNT) {  // if Timer A6 has interrupted the CPU 100 times
            display_count[1]++;          // increment coressponding display counter
            count_TMRA6 = 0;             // clear Timer A6 counter
            OSSemPost(TimerSem[1]);      // Post a semaphore for Timer A6 Counter
        }
    }
    if (TMRA_status & TMA5_MASK) {       // if Timer A5 has trigered
        count_TMRA5++;                   // increment Timer A5 counter
        if (count_TMRA5 == MAX_COUNT) {  // if Timer A5 has interrupted the CPU 100 times
            display_count[0]++;          // increment corresponding display counter
            count_TMRA5 = 0;             // clear the Timer A5 counter
            OSSemPost(TimerSem[0]);      // Post a semaphore for Timer A5 Counter
        }
    }
    OSIntExit();
}
示例#2
0
/*
 * timerTempSeconds - Get a temporary timer from the free list and set
 * it in seconds.  Note that you don't get a handle on the timer record.
 * The record will be automatically returned to the free list when either
 * it expires or it is cancelled.
 *  RETURNS: Zero if OK, otherwise an error code.
 */
INT timerTempSeconds
(
	ULONG timerDelay,				/* The delay value in seconds. */
	void (* timerHandler)(void *),	/* The timer handler function. */
	void *timerArg					/* Arg passed to handler. */
)
{
	INT st;
#ifdef OS_DEPENDENT
    UBYTE err;
	OSSemPend(mutex, 0, &err);
#endif
	if (timerFree == NULL) {
#ifdef OS_DEPENDENT
		OSSemPost(mutex);
#endif
		TIMERDEBUG((LOG_ERR, "timerTempSeconds: No free timer"));
		st = -1;					/* XXX An allocation error code? */
	}
	else {
		Timer *curTimer = timerFree;
		
		timerFree = timerFree->timerNext;
#ifdef OS_DEPENDENT
		OSSemPost(mutex);
#endif
		
		st = timerJiffys(curTimer, timerDelay * TICKSPERSEC, timerHandler, timerArg);
	}
	return st;
}
static void i2c0RegWHandler(void)
{
	i2c0ErrorCode = LPC_I2C0->I2STAT & 0xF8;
	if (i2c0ErrorCode == 0x08) {
		i2c0StartClr();
		LPC_I2C0->I2DAT = i2c0Address << 1;
	} else if (i2c0ErrorCode == 0x10) {
		i2c0StartClr();
		LPC_I2C0->I2DAT = i2c0Address << 1;
	} else if (i2c0ErrorCode == 0x18) {
		LPC_I2C0->I2DAT = i2c0Reg;
	} else if (i2c0ErrorCode == 0x20) {
		i2c0Stop();
		OSSemPost(i2c0Ready);
	} else if (i2c0ErrorCode == 0x28) {
		if (i2c0TxCnt < i2c0TxSize) {
			LPC_I2C0->I2DAT = *(i2c0TxPtr + i2c0TxCnt);
			i2c0TxCnt++;
		} else {
			i2c0Stop();
			OSSemPost(i2c0Ready);
		}
	} else if (i2c0ErrorCode == 0x30) {
		i2c0Stop();
		OSSemPost(i2c0Ready);
	} else if (i2c0ErrorCode == 0x38) {
		OSSemPost(i2c0Ready);
	}
	i2c0IntFlagClr();
}
示例#4
0
void dine(philosopher *thePhilosopher)
{
	INT8U return_code;
	// Try to get lock with really short timeout
	OSSemPend(thePhilosopher->left, 1, &return_code);
	if (return_code != OS_TIMEOUT) {
		// We got the fork!!
		OSSemPend(thePhilosopher->right, 1, &return_code);
		if (return_code != OS_TIMEOUT) { // Success
			thePhilosopher->count++;
			printf("%c I'm eating. I've eaten %d times.\n", thePhilosopher->name, thePhilosopher->count);
			OSTimeDlyHMSM(0,0,5,0); // Sleep 5s
			printf("%c I'm done eating.\n", thePhilosopher->name);
			OSSemPost(thePhilosopher->right);
			OSSemPost(thePhilosopher->left);
		} else { // Failure
			OSSemPost(thePhilosopher->left);
			printf("%c Couldn't get second fork, swapping forks.\n", thePhilosopher->name);
			OS_EVENT *temp;
			temp = thePhilosopher->left;
			thePhilosopher->left = thePhilosopher->right;
			thePhilosopher->right = temp;
		}
	}
}
示例#5
0
文件: sdhal.c 项目: nodreamnolove/sx
/*******************************************************************************************************************
** 函数名称: MCI_DataEndProcess()				
**
** 功能描述: MCI 数据结束处理函数
********************************************************************************************************************/
void MCI_DataEndProcess(void)
{
#if LPC23xx_MCI_DMA_EN
    if (lpc_mci->CurTran == MCI_CUR_SEND)
    {
        while ( !(DMACRawIntTCStatus & 0x01) );
	    DMACIntTCClear |= 0x01;
		lpc_mci->RxTxFlag = SD_NO_ERR;                       /* DMA 接收块数据成功 */
    }
    else
    {
        while ( !(DMACRawIntTCStatus & 0x02) );
		DMACIntTCClear |= 0x02;
		lpc_mci->RxTxFlag = SD_NO_ERR;                       /* DMA 发送块数据成功 */
    }
    
    #if SD_UCOSII_EN
	    OSSemPost(lpc_mci->psds->pSemSdmmcRW);               /* 使等待函数就绪 */
    #endif	

#else
   
    MCIClear |= MCI_DATA_BLK_END;
    if ((lpc_mci->SendCnt >= SD_BLOCKSIZE) || 
        (lpc_mci->RecCnt >= SD_BLOCKSIZE))	   
	{                                                       /* 块数据已收/发成功 */
	    lpc_mci->RxTxFlag = SD_NO_ERR;
	    #if SD_UCOSII_EN
	    	OSSemPost(lpc_mci->psds->pSemSdmmcRW);
		#endif
	} 

#endif	    
	MCIDataCtrl = 0;			                            /* 数据控制寄存器清0  */
}
示例#6
0
////////////////////////////////////////////////////////////////////
//	函数名称:
//	函数功能:
//	入口参数:
//
//
//	出口参数:无
////////////////////////////////////////////////////////////////////
uint8 Check_UDP_Paket(void *pdata, uint16 lg)
{
    uint8 *p;
    struct COMM_XCOM *pxcom;
    struct tagIC2CMD_Header cmd;
    struct BASE_MSG *pmsg;
    p = (uint8 *)pdata;
    pxcom = (struct COMM_XCOM *)Get_XCOM_Port(DEV_XCOM_UDP);
    Mem_Copy((uint8 *)&cmd, p, sizeof( struct tagIC2CMD_Header));
    if (cmd.dwSyncHead != CMD_ABLE_ICII) return 0;
    if ((cmd.byteProtocolType & CMD_SENDER_ACK) == CMD_SENDER_ACK)
    {
        if ((pxcom->Rflag & XCOM_READ_FLAG_WAIT_ACK) && (pxcom->flag != NULL))
            OSSemPost(pxcom->flag);
    }
    else
    {
        if ((pxcom->Rflag & XCOM_READ_FLAG_WAIT_DATA) != XCOM_READ_FLAG_WAIT_DATA) return 0;
        if (pxcom->flag == NULL) return 0;
        pmsg = (struct BASE_MSG *)((uint8 *)pdata + sizeof(struct XCOM_REV_TYPE) + sizeof(struct tagIC2CMD_Header));
        if (pmsg->option != pxcom->RCMDNo) return 0;
        pxcom->Rdata_lg = lg - sizeof(struct tagIC2CMD_Header);
        Mem_Copy(pxcom->pbuf, p + sizeof(struct tagIC2CMD_Header), pxcom->Rdata_lg);
        OSSemPost(pxcom->flag);
        UDP_Send_ACK(pdata);
        return TRUE;
    }
    return FALSE;
}
示例#7
0
void UartRcv_Task (void) 
{
		INT8U err;
	
		uart1SendInfo.clearFreCount = 0;
		uart1SendInfo.outPut = 0x00;
		uart1SendInfo.SEL = 0;
	
		while(1)
		{
				
				printf("In function Uart: ret = %u\n", uart1SendInfo.outPut );
				OSSemPend( UartSendTaskSem, 1000, &err );
				Uart1_Send_Struct(&uart1SendInfo);
				OSSemPost( UartSendTaskSem );
				
				OSTimeDly(1000);
				if ( uart1RcvOK == 1 )
				{			
						OSSemPend(UartRcvTaskSem, 1000, &err );
						uart1RcvInfo = Uart1_Get_Struct();
						OSSemPost(UartRcvTaskSem);
						Uart1LostCnt = 0;
				}
				else 
				{
						Uart1LostCnt++;
				}
		}
		return;
}
示例#8
0
void updateTimeTsk(void)
{

struct watchTime
{
int hms;
int secs;
int mins;
};

watchTime ETime;

int msCntr = 0;

ETime.hms = 0;
ETime.secs = 0;
ETime.mins =0;

OSSemPend(UART_sem, 0, &err);
uHALr_printf("  Task%c Called.\n\n", *(char *)Id);
OSSemPost(UART_sem);


while(1)
{
	OSTimeDly(1);
	if(TimeMode == 1)
	{
		msCntr++;
		if(msCntr == 100)
		{
			msCntr = 0;
			ETime.hms++;
			if(ETime.hms == 10)
			{
				ETime.secs++;
				ETime.hms = 0;
				if(ETime.secs == 60)
				{
					ETime.mins++;
					ETime.secs = 0;
					if(ETime.mins == 999)
					{
						ETime.mins =0;
					}
				}
			}
			
			
			OSSemPend(UART_sem, 0, &err);
          	Uart_Printf(" %03x:%02x:%02x\r",ETime.mins,ETime.secs,ETime.hms);
          	OSSemPost(UART_sem);
			
		}
				
	}
}

}
void TaskSensores(void *pdata)
{    
#if OS_CRITICAL_METHOD == 3 
    OS_CPU_SR  cpu_sr;
#endif
    struct AdcMsg *m;
    INT16U value = 0;
    INT16U ValorTeclado = 0;
	INT8U err;
	for(;;)
	{
        
        m = (struct AdcMsg *) OSMemGet(dMemory,&err);
        if(err == OS_NO_ERR){
            OSSemPend(STeclado,0,&err);
            ValorTeclado = NumeroSensores;
            OSSemPost(STeclado);       
            m->adc0 = 0;
            m->adc1 = 0;
            m->adc2 = 0;
            switch(ValorTeclado){
                case 3:
                    Delay10TCYx(100);
                    SetChanADC(ADC_CH2);
                    ConvertADC();
                    while( BusyADC() );
                    value = ReadADC();
                    m->adc2 = Temp(value);
                case 2:
                    Delay10TCYx(100);
                    SetChanADC(ADC_CH1);
                    ConvertADC();
                    while( BusyADC() );
                    value = ReadADC();
                    m->adc1 = Temp(value);                    
                case 1:
                    Delay10TCYx(100);
                    SetChanADC(ADC_CH0);
                    ConvertADC();
                    while( BusyADC() );
                    value = ReadADC();
                    m->adc0 = Temp(value);
                default:
                    break;
            }

            err = OSQPost(QueueADC0,m);
            if(err == OS_Q_FULL){
                OSMemPut(dMemory,m);
                OSSemPost(STaskTxSerial);
            }
        }else{
            OSSemPost(STaskTxSerial);
        }
		//OSSemPost(STask2);
		OSTimeDly(1);
	}
}
示例#10
0
void safeBufferGet(message_t * const msg) {
  uint8_t osStatus;
  
  OSSemPend(fullSlot, 0, &osStatus);
  OSSemPend(bufMutex, 0, &osStatus);
  getBuffer(msg);
  osStatus = OSSemPost(bufMutex);
  osStatus = OSSemPost(freeSlot);
}
示例#11
0
unsigned long USART0IntHandler(void *pvCBData,
        unsigned long ulEvent,
        unsigned long ulMsgParam,
        void *pvMsgData)
{
	char receive_byte;

	if (Contiki_Sem != NULL){
		if ((ulEvent & UART_EVENT_RX) == UART_EVENT_RX)
		{
			receive_byte = xHWREGB(UART0_BASE + UART_012_D);

			if (slip_input_byte(receive_byte) == 1) OSSemPost(Contiki_Sem);

			buffer_rcvd[buffer_rcvd_i++]=receive_byte;

	#if 0
			if (OSQueuePost(Serial0, receive_byte) == BUFFER_UNDERRUN)
			{
				// Problema: Estouro de buffer
				OSQueueClean(Serial0);
			}
	#endif
		}

		if ((ulEvent & UART_EVENT_TC) == UART_EVENT_TC)
		{
			if ((xHWREGB(UART0_BASE + UART_012_C2) & UART_EVENT_TC) == UART_EVENT_TC)
			{
				UARTIntDisable(UART0_BASE, UART_INT_TC);
				(void)OSSemPost(SerialTX0);
			}
		}

		// ************************
		// Interrupt Exit
		// ************************
		OS_INT_EXIT_EXT();
		// ************************
	}else{
		if ((ulEvent & UART_EVENT_RX) == UART_EVENT_RX)
		{
			receive_byte = xHWREGB(UART0_BASE + UART_012_D);
		}

		if ((ulEvent & UART_EVENT_TC) == UART_EVENT_TC)
		{
			if ((xHWREGB(UART0_BASE + UART_012_C2) & UART_EVENT_TC) == UART_EVENT_TC)
			{
				UARTIntDisable(UART0_BASE, UART_INT_TC);
			}
		}
	}
}
示例#12
0
/* 按键中断0 */
void EXTI0_IRQHandler(void)
{
    if(EXTI_GetITStatus(EXTI_Line0) != RESET) //确保是否产生了EXTI Line中断
    {
        OSIntEnter();
        OSSemPost(key_SEM); // 发送信号量,这个函数并不会引起系统调度,所以中断服务函数一定要简洁。
        OSSemPost(keyDis_SEM);
        EXTI_ClearITPendingBit(EXTI_Line0); // 清除标志位
        OSIntExit();
    }
}
示例#13
0
void network_gm_init(void)
{
	INT8S	res = 0;
	INT8U 		err;
	gd_msg_t 	*send_msg = NULL;
	
	OSSemPend(gd_system.gm_operate_sem, GD_SEM_TIMEOUT, &err);
	if(err != OS_NO_ERR)	
		res = -1;
	else 
		res = gprsmodule_init();
	gd_msg_malloc(&send_msg);
	send_msg->data =  (void*)NULL;				
	if(res == 0)
	{

		res = gm_sms_init("13500250500");
		if(res == 0)
		{
			res = gm_phone_init();
			if(res == 0)
			{
 	OSSemPost(gd_system.gm_operate_sem);

				fail_tick = 0;				
				send_msg->type = GD_MSG_TCP_INIT;
				OSQPost(gd_system.network_task.q_network, (void*)send_msg);		
				return;
			}
		}
		
	}
//	else
	{
 	OSSemPost(gd_system.gm_operate_sem);
		fail_tick++;
		if(fail_tick >= NETWORK_FAIL_COUNT)
		{
			fail_tick = 0;	
			//OSQFlush(gd_system.network_task.q_network);					
			send_msg->type = GD_MSG_GM_RESET;
		}
		else
		{
			send_msg->type = GD_MSG_GM_INIT;
		}			
		OSQPost(gd_system.network_task.q_network, (void*)send_msg);	
	}


}
示例#14
0
//interupt waits for a read from the port
ISR OCOIsr(void)
{
    OS_ISR_ENTER();
    ReceiveVar = sci_read();
    OSSemPost(ReceiveFlag);
    OSIntExit();  
}
示例#15
0
void UserIRQ_Eint4567(void)
{
    OSSemPend(UART_sem, 0, 0);
    Uart_Printf(" SB2 or SB3 had pressed...\r");
    OSSemPost(UART_sem);
	Eint4567Isr();
}
示例#16
0
文件: key.c 项目: postgetme/crco
static void PushKeyTask (void* pdata)
{
	INT8U err;

	while (1)
	{
		OSSemPend (os_sem_push, PUSH_TIME, &err);
		if (err == OS_TIMEOUT)
		{	
			key_hook (TYPE_KEY_PUSH<<24 | change);
			OSQPost (os_q_key_msg, (void*)(TYPE_KEY_PUSH<<24 | change));
		#if KEY_CONTINUOUS_PUSH_EN == 1
			while (1)	
			{
				key_hook (TYPE_KEY_DOWN<<24 | change);
			    OSQPost (os_q_key_msg, (void*)(TYPE_KEY_PUSH<<24 | change));
				OSTimeDly (PUSH_EXECUTE_INTERVAL);
				if (OSSemAccept(os_sem_push))
				{
					OSSemPost (os_sem_push);
					break;
				}
			}
		#else
			OSTaskDel (KEY_PUSH_TASK_PRIO);
		#endif
		}
		else
		{
			OSTaskDel (KEY_PUSH_TASK_PRIO);
		}
	}
}
示例#17
0
INT8U sendbin0(INT8U* dest,int size){
	INT8U err;
	OSSemPend(Sem_UART0Tx,0,&err);
	transbin0(dest,size);
	OSSemPost(Sem_UART0Tx);
	return err;
}
示例#18
0
文件: MyTest.c 项目: super-1943/MCU
//******************************************************************
void  BnPrintf(void *dataptr)
{
    
    INT8U i;
    dataptr = dataptr;
    EA =1;
    while(1)
    {

    	TI = 1;
        for(i=0;i<18;)
        {   if(TI)
            {
            	TI = 0;
            	SBUF = BnPrintfData[i];
            	i++;
	     }
        
        }
        
	OSSemPost(BnPrintfWait);
	
    }
   
}
示例#19
0
static void	handle_dma0_interrupt(void* context)
{
	alt_irq_context        cpu_sr;
	dma_context_state *dma_context_int = (dma_context_state *)context;

	dma_context_int->dma_done = 0;

	// relaunch dma transfer
	alt_dma_txchan_send(dma_context_int->txchan, 
						(void *)dma_context_int->src, 
						dma_context_int->len, 
						NULL, 
						NULL);

	alt_dma_rxchan_prepare(dma_context_int->rxchan, 
						   (void *)dma_context_int->dst, 
						   dma_context_int->len, 
						   dma_context_int->done_callback, 
						   NULL);

	cpu_sr = alt_irq_disable_all();
	alt_irq_enable_all(cpu_sr);

	OSSemPost(SEM_DMA0);
}
示例#20
0
interrupt void Timer2Overflow(void)
#endif
{
	// ************************
	// Entrada de interrupção
	// ************************
	OS_INT_ENTER();
		
	// Interrupt handling
	TPM2SC_TOF = 0;

#if (NESTING_INT == 1)
	OS_ENABLE_NESTING();
#endif   

	// ************************
	// Handler code for the tick
	// ************************	
	TimerOverflowCallback();
	
#if (SD_WAVE == 1)
	OSSemPost(Audio);
#endif

	// ************************
	// Interrupt Exit
	// ************************
	OS_INT_EXIT();
	// ************************  
}
示例#21
0
void serial_api_rx_helloresponse(INT8U* payload, INT8U payloadLen) {
   
   serial_helloresponse_ht* msg;
   
   // drop packet if wrong length
   if (payloadLen!=sizeof(serial_helloresponse_ht)) {
      // print
      dnm_ucli_printf("ERROR: helloresponse wrong length (%d bytes)\r\n",payloadLen);
      // disconnect
      OSSemPost(bridge_app_v.disconnectedSem);
      return;
   }
   
   // cast message
   msg = (serial_helloresponse_ht*)payload;
   
   // store seqNoRx
   bridge_app_v.seqNoRx = msg->mgrSeqNo;
   
#ifdef PRINT_TRACE
   dnm_ucli_printf("      seqNoRx %d\r\n",bridge_app_v.seqNoRx);
#endif
   
   // I'm now connected
   bridge_app_v.connected = 0x01;
}
示例#22
0
/*
 *	timerCancel - Clear the first matching timer for the given function
 *	pointer and argument.
 */
void timerCancel(
	void (* timerHandler)(void *),	/* The timer handler function. */
	void *timerArg					/* Arg passed to handler. */
)
{
	Timer *curTimer;
#ifdef OS_DEPENDENT
    UBYTE err;
	OSSemPend(mutex, 0, &err);
#endif
	for (curTimer = timerHead.timerNext;
		curTimer != &timerHead 
			&& (curTimer->timerHandler != timerHandler
				|| curTimer->timerArg != timerArg);
		curTimer = curTimer->timerNext
	);
	if (curTimer != &timerHead) {
		(curTimer->timerNext)->timerPrev = curTimer->timerPrev;
		(curTimer->timerPrev)->timerNext = curTimer->timerNext;
		curTimer->timerPrev = NULL;
		
		if (curTimer->timerFlags & TIMERFLAG_TEMP) {
			curTimer->timerNext = timerFree;
			timerFree = curTimer;
		}
	}
#ifdef OS_DEPENDENT
	OSSemPost(mutex);
#endif
}
示例#23
0
/** @memo   Signal a semaphore.

    @doc    Signal a semaphore.  An example would be to 
    increment a counting semaphore.

	@precondition Must not call directly. Use the 
	<b>rtp_sig_semaphore_signal</b> macro in rtpsignl.h.

    @return void
 */
void _rtp_sig_semaphore_signal (
  RTP_HANDLE semHandle                  /** Handle to the semaphore to be signaled. */
  )
{
    INT8U err;
    
    err =  OSSemPost ((OS_EVENT *)semHandle);
    
    if(err == OS_NO_ERR)
    {
    	/* success, return */
    	return;
    }

#if(RTP_DEBUG_SIGNAL)
	
    if (err == OS_SEM_OVF)
    {
    	RTP_DEBUG_OUTPUT_STR("If the semaphore count exceeded its limit");
    }
    if (err == OS_ERR_EVENT_TYPE)
    {
    	RTP_DEBUG_OUTPUT_STR("If you didn't pass a pointer to a semaphore");
    }
    if (err == OS_ERR_PEVENT_NULL)  
    {
    	RTP_DEBUG_OUTPUT_STR("If 'pevent' is a NULL pointer");
    }

#endif    

	return;
}
示例#24
0
/*
 * timerClear() - Clear the given timer.
 */
void timerClear
(
	Timer *timerHdr					/* Pointer to timer record. */
)
{
#ifdef OS_DEPENDENT
    UBYTE err;
#endif
	/* 
	 * Since the queue is circular, a null prev link means the timer is not
	 * on the queue (the free list only uses next).  Otherwise we extract it
	 * and if it's a temporary timer, put it back on the free list.
	 */
#ifdef OS_DEPENDENT
	OSSemPend(mutex, 0, &err);
#endif
	if (timerHdr->timerPrev) {
		(timerHdr->timerNext)->timerPrev = timerHdr->timerPrev;
		(timerHdr->timerPrev)->timerNext = timerHdr->timerNext;
		timerHdr->timerPrev = NULL;
		
		if (timerHdr->timerFlags & TIMERFLAG_TEMP) {
			timerHdr->timerNext = timerFree;
			timerFree = timerHdr;
		}
	}
#ifdef OS_DEPENDENT
	OSSemPost(mutex);
#endif
}
示例#25
0
static void info_card_out()
{
	mmcsrc.Src = SRC_MMC;
	mmcsrc.Event = EVENT_MMC_OUT;
	OSQPost(mmcsrc.CurEvent1 , (void *)&mmcid);
	OSSemPost(mmcsrc.CurEvent);
}
示例#26
0
//发生接收中断时调用,基本上是发生8字节中断后调用,或者超时后调用
void UART_IntReceive(void)
{
	uint8_t rlen;//接收数据的长度
	uint8_t chars[16];
	uint8_t index = 0;	
	//接收一个字符
	rlen = UART_Receive((LPC_UART_TypeDef *)_LPC_UART,chars,16,NONE_BLOCKING);
	for(index=0;index<rlen;index++)
	{
		//my_printf("%d ",chars[index]);
		
		if(! ISBufFull(&bufSerialRec))
		{
			//如果缓冲区未满 
			BufPush(&bufSerialRec,chars[index]);
		}
		//获得包结束位
		if(chars[index] == PACKET_EOI)
		{
			//UART_Send((LPC_UART_TypeDef *)_LPC_UART,chars,index,BLOCKING);
			if(!ISBufEmpty(&bufSerialRec))
			{
				OSSemPost(semSerialCommand);
			}
		}
		
	}
}
示例#27
0
void osReleaseSemaphore(OsSemaphore *semaphore)
{
   OS_ERR err;

   //Release the semaphore
   OSSemPost(semaphore, OS_OPT_POST_1, &err);
}
示例#28
0
void  AppTrace (CPU_CHAR *format, ...)
{
    CPU_CHAR  buf_str[80 + 1];
    va_list   v_args;
    OS_ERR    os_err;


    va_start(v_args, format);
   (void)vsnprintf((char       *)&buf_str[0],
                   (size_t      ) sizeof(buf_str),
                   (char const *) format,
                                  v_args);
    va_end(v_args);

    OSSemPend((OS_SEM  *)&AppTraceSem,
              (OS_TICK  )0u,
              (OS_OPT   )OS_OPT_PEND_BLOCKING,
              (CPU_TS  *)0,
              (OS_ERR  *)&os_err);

    printf("%s", buf_str);

   (void)OSSemPost((OS_SEM  *)&AppTraceSem,
                   (OS_OPT   )OS_OPT_POST_1,
                   (OS_ERR  *)&os_err);

}
示例#29
0
void serial_api_tx_subscribe() {
   serial_subscribe_ht     request;
   serial_subscribe_ack_ht response;
   INT8U                   responseLen;
   INT8U                   rc;
   
   // create
   request.filter      = 0xffffffff;
   request.unackFilter = 0xffffffff;
   
   // send
   rc = serial_tx(
      PKT_TYPE_SUBSCRIBE,              // packetType
      (INT8U*)&request,                // txPayload
      sizeof(serial_subscribe_ht),     // txPayloadLen
      &response,                       // rxPayload
      sizeof(serial_subscribe_ack_ht), // rxPayloadMaxLen
      &responseLen                     // rxPayloadLen
   );
   if (
         rc!=RC_OK ||
         responseLen<sizeof(serial_subscribe_ack_ht) ||
         response.rc!=RC_OK
      ) {
          // print
          dnm_ucli_printf("ERROR: subscription error\r\n");
          // disconnect
          OSSemPost(bridge_app_v.disconnectedSem);
      }
}
示例#30
0
/* ethernet buffer */
void eth_tx_thread_entry(void* parameter)
{
	struct eth_tx_msg* msg;
	INT8U err = 0;

	while (1)
	{
		msg = OSQPend( pTxMsgQueue , 0,&err);
		if ( err == OS_NO_ERR)
		{
			struct eth_device* enetif;

			RT_ASSERT(msg->netif != RT_NULL);
			RT_ASSERT(msg->buf   != RT_NULL);
			enetif = (struct eth_device*)msg->netif->state;
			if (enetif != RT_NULL)
			{
				/* call driver's interface */
				if (enetif->eth_tx(enetif, msg->buf) != OS_TRUE)
			 	{
			//		rt_kprintf("transmit eth packet failed\n");
			 	}
			}
			/* send ack */
		//	rt_sem_release(&(enetif->tx_ack));
			OSSemPost(enetif->tx_ack );
		}
	}
}