本文整理汇总了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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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 );
}
示例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 );
}
示例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();
}
示例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;
}
示例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;
}
示例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
}
示例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];
}
示例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
}
示例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
}
示例15: ki_semval
int
ki_semval (struct k_t *sem)
{
DI ();
return (sem->cnt1);
}