当前位置: 首页>>代码示例>>C++>>正文


C++ DI函数代码示例

本文整理汇总了C++中DI函数的典型用法代码示例。如果您正苦于以下问题:C++ DI函数的具体用法?C++ DI怎么用?C++ DI使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DI函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: imalloc

/*
 * Get memory 
 */
LOCAL void* imalloc( size_t size, IMACB *imacb )
{
	QUEUE	*q;
	VP	mem;
	UW	imask;

	/* If it is smaller than the minimum fragment size,
	   allocate the minimum size to it. */
	if ( size < MIN_FRAGMENT ) {
		size = MIN_FRAGMENT;
	}
	size = ROUND(size);

	DI(imask);  /* Exclusive control by interrupt disable */
	SpinLock(&MemLockObj);

	/* Search FreeQue */
	q = searchFreeArea(size, imacb);
	if ( q != &imacb->freeque ) {
		/* There is free area: Split from FreeQue once */
		removeFreeQue(q);

		q = q - 1;
	} else {
		/* Reserve new pages because there is no free space */
		QUEUE	*e;
		size_t	n;

		/* Reserve pages */
		SpinUnlock(&MemLockObj);
		EI(imask);
		n = PageCount(size + sizeof(QUEUE) * 2);
		q = GetSysMemBlk(n, imacb->mematr);
		if ( q == NULL ) {
			goto err_ret;  /* Insufficient memory */
		}
		DI(imask);
		SpinLock(&MemLockObj);

		/* Register on AreaQue */
		e = (QUEUE*)((VB*)q + n * pagesz) - 1;
		insertAreaQue(&imacb->areaque, e);
		insertAreaQue(&imacb->areaque, q);
		setAreaFlag(q, AREA_TOP);
		setAreaFlag(e, AREA_END);
	}

	/* Allocate memory */
	mem = mem_alloc(q, size, imacb);

	SpinUnlock(&MemLockObj);
	EI(imask);
	return mem;

err_ret:
	BMS_DEBUG_PRINT(("imalloc error\n"));
	return NULL;
}
开发者ID:kidasan,项目名称:tkernel,代码行数:61,代码来源:imalloc.c

示例2: uart_putchar

int uart_putchar(unsigned char c)
{
    int buffer_loc;

    if(c == '\n') {
        while(uart_putchar('\r')) {
            ;
        }
    }

    if(trans_buffer_size < BUFFER_SIZE) {
        DI();

        buffer_loc = (trans_buffer_current + trans_buffer_size) % BUFFER_SIZE;
        trans_buffer[buffer_loc] = c;
        trans_buffer_size++;

        //trigger the interrupt if already ready to transmit
        if((U0STAT0 & UART_TRAN_RDY) &&
                ((IRQ0SET & UART_IRQ_TRAN) == 0)) {
            IRQ0SET |= UART_IRQ_TRAN;
        }

        EI();
    }
    else {
        return 1;
    }

    return 0;
}
开发者ID:mharlan,项目名称:embedded-labs,代码行数:31,代码来源:uart.c

示例3: led_display_text

void led_display_text(const unsigned char *msg)
{
	char *new_msg;

	msg_size = strlen(msg);
	new_msg = malloc(sizeof(*new_msg) * (msg_size + 2));	//+2 for space pad and null terminator
	if(!new_msg) {
		msg_size = 0;
	}
	else {
		memcpy(new_msg, msg, msg_size);

		//space pads the wrap-around
		if(msg_size > 4) {
			new_msg[msg_size] = ' ';
			++msg_size;
		}
		new_msg[msg_size] = '\0';

		DI();
		
		if(led_msg != NULL) {
			free(led_msg);
		}
		
		led_msg = new_msg;
		msg_pos = 0;
		row_pos = 0;
		led_set_draw_chars();

		EI();
	}
}
开发者ID:mharlan,项目名称:UltrasonicMIDI,代码行数:33,代码来源:LED.c

示例4: SifSetRpcQueue

SifRpcDataQueue_t *
SifSetRpcQueue(SifRpcDataQueue_t *qd, int thread_id)
{
	SifRpcDataQueue_t *queue = NULL;

	DI();

	qd->thread_id = thread_id;
	qd->active = 0;
	qd->link   = NULL;
	qd->start  = NULL;
	qd->end    = NULL;
	qd->next   = NULL;

	if (!_sif_rpc_data.active_queue) {
		_sif_rpc_data.active_queue = qd;
	} else {
		queue = _sif_rpc_data.active_queue;

		while ((queue = queue->next))
			;

		queue->next = qd;
	}

	EI();

	return queue;
}
开发者ID:EvertonSilva,项目名称:ps2sdk,代码行数:29,代码来源:sifrpc.c

示例5: SifRegisterRpc

SifRpcServerData_t *
SifRegisterRpc(SifRpcServerData_t *sd, 
		int sid, SifRpcFunc_t func, void *buff, SifRpcFunc_t cfunc,
		void *cbuff, SifRpcDataQueue_t *qd)
{
	SifRpcServerData_t *server;

	DI();

	sd->link  = NULL;
	sd->next  = NULL;
	sd->sid   = sid;
	sd->func  = func;
	sd->buff  = buff;
	sd->cfunc = cfunc;
	sd->cbuff = cbuff;
	sd->base  = qd;

	if (!(server = qd->link)) {
		qd->link = sd;
	} else {
		while ((server = server->next))
			;

		server->next = sd;
	}

	EI();

	return server;
}
开发者ID:EvertonSilva,项目名称:ps2sdk,代码行数:31,代码来源:sifrpc.c

示例6: buscarIzquierdaAVL

int buscarIzquierdaAVL( AVL *a, int dato, int *band )
{
   int retAux;
   
   retAux = eliminaAVL( &(*a)->izq, dato, band );
   
   if( *band )
   {
      if( (*a) -> fe == 0 )
      {
         (*a) -> fe = 1;
         *band = 0;
      }else
          if( (*a) -> fe == -1 )
               (*a) -> fe = 0;
          else
             {
               if( (*a) -> der -> fe >= 0 )
               {
                  if( (*a) -> der -> fe == 0 )
                      *band = 0;
                  
                   DD( a );
               }else
                   DI( a );   
             }
   }
   
   return( retAux );
}
开发者ID:miguellgt,项目名称:C-Dynamic-Data-Structures,代码行数:30,代码来源:Arboles+AVL.cpp

示例7: eliminaAVL

int eliminaAVL( AVL *a, int dato, int *band )
{
 int ret;
 AVL aux;
 
 if( !*a )
   *band = ret = 0;
 else
    {
      if( dato == (*a) -> info )
      {
        ret = *band = 1;
        aux = *a;
        
        if( !(*a) -> izq )
           *a = (*a)-> der;
        else
          if( !(*a) -> der )
            *a = (*a) -> izq;
          else
             {
               recorreIzqDerAVL( &(*a) -> izq, &aux, band );
               (*a) -> info = aux -> info;
               
               if( *band )
               {
                 if( (*a) -> fe == 0 )
                 {
                   (*a) -> fe = 1;
                   *band = 0;
                 }else
                     if( (*a) -> fe == -1 )
                        (*a) -> fe = 0;
                     else
                        {
                          if( (*a) -> der -> fe >= 0 )
                          {
                            if( (*a) -> der -> fe == 0 )
                              *band = 0;
                       
                               DD( a );
                    
                          }else
                               DI( a );   
                        } 
                }
            }  
        
        free( aux );
        
       }else
           if( dato < (*a) -> info )
              ret = buscarIzquierdaAVL( a, dato, band );
            else
              if( dato > (*a) -> info )
                 ret=  buscarDerechaAVL( a, dato, band );
    }
   
   return( ret ); 
}
开发者ID:miguellgt,项目名称:C-Dynamic-Data-Structures,代码行数:60,代码来源:Arboles+AVL.cpp

示例8: R_Systeminit

/***********************************************************************************************************************
* Function Name: R_Systeminit
* Description  : This function initializes every macro.
* Arguments    : None
* Return Value : None
***********************************************************************************************************************/
void R_Systeminit(void)
{
    DI();

    /* Enable writing to registers related to operating modes, LPC, CGC and ATCM */
    SYSTEM.PRCR.LONG = 0x0000A50BU;

    /* Enable writing to MPC pin function control registers */
    MPC.PWPR.BIT.B0WI = 0U;
    MPC.PWPR.BIT.PFSWE = 1U;

    r_set_exception_handler();

    /* Set peripheral settings */
    R_CGC_Create();
    R_ICU_Create();
    R_PORT_Create();
    R_TPU_Create();
    R_RSPI1_Create();
    R_MPC_Create();
	R_SCIFA2_Create();

    /* Disable writing to MPC pin function control registers */
    MPC.PWPR.BIT.PFSWE = 0U;
    MPC.PWPR.BIT.B0WI = 1U;

    /* Enable protection */
    SYSTEM.PRCR.LONG = 0x0000A500U;
    EI();
}
开发者ID:bleuelotus,项目名称:SweepRobot_Testing_Host,代码行数:36,代码来源:r_cg_systeminit.c

示例9: io_init

int io_init()
{
	int i;
	int res;

	it_g = comedi_open("/dev/comedi0");

	if (it_g == NULL) return -1;

	// init 3 inputs and 3 outputs
	for(i=1; i<4; i++)
	{
		res = comedi_dio_config(it_g, IO_DEV, DI(i), COMEDI_INPUT);
		if (res<0) return res;
		res = comedi_dio_config(it_g, IO_DEV, DO(i), COMEDI_OUTPUT);
		if (res<0) return res;
		res = comedi_dio_write(it_g, IO_DEV, DO(i), 0);
		if (res<0) return res;
	}

	// set outputs to high
	for(i=1; i<4; i++)
	{
		comedi_dio_write(it_g, IO_DEV, DO(i), 1);
	}

	return 1;
}
开发者ID:sigvartmh,项目名称:Xiaomi,代码行数:28,代码来源:io.c

示例10: main

int main(){
	DI();//disable interrupts or hell breaks loose during hardware config
	construct_system();//bind device addresses
	init_system();//init devices
		//clear all interrupts
	clearall_interrupts();
	EI();//enable interrupts: we have UART_recieve
	
	//set the lcd contrast
	//lcd_contrast(0x42);
	lcd_contrast(0x32);
	//clear the lcd
	clearram();
	//show boot up message
	show_bootup();
	//clear boot message
	clearram();
	//screen layout
	screen_layout();
	send(1, 225);
	send(1, 255);
	send(1, 2);
	while(1)
	{
		get_temperature1();
		get_temperature2();
		get_light();
		get_pressure();
		get_humidity();
		get_soilwetness();
		display();
		delay_ms(800);		
	}
	return 0;
}
开发者ID:Muriukidavid,项目名称:z8_64k,代码行数:35,代码来源:main.c

示例11: ki_wait

int
ki_wait (struct k_t *sem, int timeout)
{
// used by msg system
  DI ();

  if (0 < sem->cnt1) {
    //      lucky that we do not need to wait ?
    sem->cnt1--;		// Salute to Dijkstra
    return (0);
  }

  if (timeout == -1) {
    // no luck, dont want to wait so bye bye
    return (-2);
  }

  // from here we want to wait
  pRun->cnt2 = timeout;	// if 0 then wait forever

  if (timeout)
    pRun->cnt3 = (int) sem;	// nasty keep ref to semaphor
  //  so we can be removed if timeout occurs
  sem->cnt1--;		// Salute to Dijkstra

  enQ (sem, deQ (pRun));
  ki_task_shift ();		// call enables NOT interrupt on return

  return ((char) (pRun->cnt2));	// 0: ok, -1: timeout
}
开发者ID:jdn-aau,项目名称:sketchbook,代码行数:30,代码来源:krnl.c

示例12: PS2CamReadPacket

int PS2CamReadPacket(int handle)
{
	int *ret;
	int *iop_addr;

	WaitSema(sem);

	ret = (int *)&data[0];

	ret[0] = handle;

	SifCallRpc(&cdata, PS2CAM_RPC_READPACKET, 0, (void*)(&data[0]),4,(void*)(&data[0]),4*2,0,0);


	if(ret[0] < 0) return ret[0];


	DI();
	ee_kmode_enter();

	iop_addr = (int *)(0xbc000000+ret[1]);

	memcpy(&campacket[0],iop_addr, ret[0]);

	ee_kmode_exit();
	EI();

	//if i add a printf here, the ps2 will exit to sony's explorer
	SignalSema(sem);
	return ret[0];
}
开发者ID:AKuHAK2,项目名称:ps2sdk,代码行数:31,代码来源:ps2cam_rpc.c

示例13: ki_receive

char
ki_receive (struct k_msg_t *pB, void *el, int *lost_msg)
{
    int i;
    char r, *pSrc, *pDst;

    // can be called from ISR bq no blocking
    DI ();			// just to be sure

    if (0 <= (r = ki_wait (pB->sem, -1))) {

	pDst = (char *) el;
	pB->r++;
	pB->cnt--;		// got one

	if (pB->nr_el <= pB->r) {
	    pB->r = 0;
	}

	pSrc = pB->pBuf + pB->r * pB->el_size;

	for (i = 0; i < pB->el_size; i++) {
	    *(pDst++) = *(pSrc++);
	}
	if (lost_msg) {
	    *lost_msg = pB->lost_msg;
	    pB->lost_msg = 0;
	}
	return (r);		// yes
    }

    return (-1);		// nothing for you my friend
}
开发者ID:jdn-aau,项目名称:krnl,代码行数:33,代码来源:krnl.c

示例14: k_mut_ceil_enter

int
k_mut_ceil_enter (struct k_t *sem, int timeout)
{
    int retval;
    DI ();
    // if ceiling_prio < 0 then its a normal wait call
    if (sem->ceiling_prio < 0) {
	retval = ki_wait (sem, timeout);	// could call k_wait but just extra fct call
	EI ();
	return retval;
    }

    if (pRun->prio < sem->ceiling_prio) {	// I have higher priority than ceiling :-(
	EI ();
	return CEILINGFAIL;
    }
    // now we play imm ceiling protocol
    sem->saved_prio = pRun->prio;	// do im ceiling
    pRun->prio = sem->ceiling_prio;	// dont need to reinsert in AQ bq ceil prio is higher or equal to mine and Im already in front of AQ
    prio_enQ (pAQ, deQ (pRun));	// resinsert me in AQ acc to nwe(old) priority
    retval = ki_wait (sem, timeout);
    // coming back interrupt is still disabled !


    // chk if we did get semaphore
    if (retval < 0) {		// NOPE we did not
	pRun->prio = sem->saved_prio;	// reset to my old priority
	prio_enQ (pAQ, deQ (pRun));	// reinsert me in AQ acc to nwe(old) priority
	ki_task_shift ();	// bq maybe started task has higher prio than me

    }
    EI ();
    return retval;		// 0(has waited),1(straight through) : ok, -1: timeout
}
开发者ID:jdn-aau,项目名称:krnl,代码行数:34,代码来源:krnl.c

示例15: ki_semval

int
ki_semval (struct k_t *sem)
{
    DI ();

    return (sem->cnt1);
}
开发者ID:jdn-aau,项目名称:krnl,代码行数:7,代码来源:krnl.c


注:本文中的DI函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。