示例#1
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);
			}
		}
		
	}
}
示例#2
0
void OptimizeProcInline(Var * proc)
/*
Purpose:
	Replace every call to function that should be inlined with actual code from the function.
*/
{
	Instr * i;	//, * next;
	InstrBlock * blk;
	Var * subproc, * var, * arg;

	for(blk = proc->instr; blk != NULL; blk = blk->next) {
		for(i = blk->first; i != NULL; i = i->next) {
			if (i->op == INSTR_CALL) {
				subproc = i->result;

				// 1. We inline procedures that are called just once
				if (subproc->read == 1) {

					if (subproc->instr != NULL) {
						BufEmpty();
						FOR_EACH_ARG(subproc, arg, SUBMODE_ARG_IN+SUBMODE_ARG_OUT)
							if (arg->adr == NULL) {
								var = VarAllocScopeTmp(proc, INSTR_VAR, arg->type);
							} else {
								var = arg->adr;
							}
							BufPush(var);
							ProcReplaceVar(proc, arg, var);
						NEXT_ARG

						InScope(proc);
						GenSetDestination(blk, i);
						GenMacro(subproc, STACK);
						i = InstrDelete(blk, i);
						subproc->read--;

					}
				}
			}
		}