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


C++ CHECK_BIT函数代码示例

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


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

示例1: macaddr_init

/*
 * Reads MAC address if available or uses fixed one
 */
void macaddr_init(u8 *mac_addr)
{
	u8 buffer[6];
	u8 fixed_mac[6] = {0x00, 0x03, 0x7F, 0x09, 0x0B, 0xAD};

#if defined(OFFSET_MAC_ADDRESS)
	memcpy(buffer, (void *)(CFG_FLASH_BASE
		+ OFFSET_MAC_DATA_BLOCK + OFFSET_MAC_ADDRESS), 6);

	/*
	 * Check first LSBit (I/G bit) and second LSBit (U/L bit) in MSByte of vendor part
	 * both of them should be 0:
	 * I/G bit == 0 -> Individual MAC address (unicast address)
	 * U/L bit == 0 -> Burned-In-Address (BIA) MAC address
	 */
	if (CHECK_BIT((buffer[0] & 0xFF), 0) != 0 ||
	    CHECK_BIT((buffer[0] & 0xFF), 1) != 0) {
		memcpy(buffer, fixed_mac, 6);
		mac_is_not_valid = 1;
	}
#else
	memcpy(buffer, fixed_mac, 6);
	mac_is_not_valid = 1;
#endif

	memcpy(mac_addr, buffer, 6);
}
开发者ID:KAPMA,项目名称:u-boot_mod,代码行数:30,代码来源:common.c

示例2: SoundPlayer_SendCommand

void SoundPlayer_SendCommand(SoundPlayer *sp, uint16_t command) {
	int8_t bit;
	
	CLEAR_BIT(sp->port, sp->clockPin);
	
	Util_WaitMicros(1000);
	
	if(CHECK_BIT(command, 15))
		SET_BIT(sp->port, sp->dataPin);
	else
		CLEAR_BIT(sp->port, sp->dataPin);
	
	Util_WaitMicros(1000);
	
	SET_BIT(sp->port, sp->clockPin);
	
	for(bit = 14; bit >= 0; bit--) {
		Util_WaitMicros(200);
		
		CLEAR_BIT(sp->port, sp->clockPin);
		
		if(CHECK_BIT(command, bit))
			SET_BIT(sp->port, sp->dataPin);
		else
			CLEAR_BIT(sp->port, sp->dataPin);
		
		Util_WaitMicros(200);
		
		SET_BIT(sp->port, sp->clockPin);
	}
}
开发者ID:ISU-ETG,项目名称:Doorbell,代码行数:31,代码来源:SoundPlayer.c

示例3: main

int main(int argc, char* argv[])
{
    //unlock the system level control register
    volatile void *devcfg_ctrl = getvaddr(0xF8007000);
    volatile void *semdev = getvaddr(0x42C00000);


//    printf("\t\tInitial: 0x%x\n", *((volatile unsigned *)(semdev)+0)); 

    *((volatile unsigned *)devcfg_ctrl) = *((volatile unsigned *)devcfg_ctrl) & ~PCAP_PR;
    *((volatile unsigned *)(semdev)+4) = 1; //set icap_grant to 1

    while(!CHECK_BIT(*((volatile unsigned *)(semdev)+0), 2)){ } //Wait till we are in the observation state 
    
//    printf("\t\tObservation: 0x%x\n", *((volatile unsigned *)(semdev)+0)); 

    //Attempting to enter idle state
    *((volatile unsigned*)(semdev)+3) = 224;
    *((volatile unsigned*)(semdev)+1) = 1;
    *((volatile unsigned*)(semdev)+1) = 0;
    while(CHECK_BIT(*((volatile unsigned *)(semdev)+0), 1) || CHECK_BIT(*((volatile unsigned *)(semdev)+0), 2) || CHECK_BIT(*((volatile unsigned *)(semdev)+0), 3) || CHECK_BIT(*((volatile unsigned *)(semdev)+0), 4) || CHECK_BIT(*((volatile unsigned *)(semdev)+0), 5)){} //Wait till we are in the Idle state.
    //while(CHECK_BIT(*((volatile unsigned *)(semdev)+0), 2)){ }  
//    printf("\t\tEntering Idle State: 0x%x\n", *((volatile unsigned *)(semdev)+0)); 
    
//    printf("SEM Core Initialisation completed, and ready for injection.\n");

    return 0;
}
开发者ID:STFleming,项目名称:StitchUp,代码行数:28,代码来源:injectSetup.c

示例4: memtest

unsigned int memtest(multiboot_info_t* mbd, unsigned int magic)
{

	magic = (int) magic;

	terminal_writestring(MULTIBOOT_TEST);

	if (CHECK_BIT(mbd->flags, 0))
	{
		vgatestok();
		terminal_writestring(MEMORY_MAP_TEST);
		
		if (CHECK_BIT(mbd->flags, 6))
		{
			vgatestok();
			terminal_printf("\nLower memory : %d KB\n", mbd->mem_lower);
			terminal_printf("Upper memory : %d KB\n\n", mbd->mem_upper);
		}

		else
		{
			vgatestko();
			return (1);
		}

		return (0);
	}

	vgatestko();
	return (1);
}
开发者ID:Happykat,项目名称:ATOS,代码行数:31,代码来源:memtest.c

示例5: fpidinlock

int fpidinlock (int pid,int ldes)
{

		struct	pentry	*pptr;
		int bit_s;
		int r=0;
		//unsigned long ctime;
		pptr=&proctab[pid];

#ifdef DEBUGD
		kprintf("\nInside find function ldes=%d, pid=%d, lheld50=%d\n",ldes,pid,pptr->lheld50);
#endif
		if (ldes-100>31)
		{
			bit_s=ldes-132;

			if (r=CHECK_BIT(pptr->lheld50,bit_s))
				CLEAR(pptr->lheld50,bit_s);
			return (r);
		}
		else
		{
			bit_s=ldes-100;

			if  (r=CHECK_BIT(pptr->lheld32,bit_s))
					CLEAR(pptr->lheld32,bit_s);
			return(r);
		}



		//should not come here
		return 0;
}
开发者ID:ananthraghavan,项目名称:csc501-lab3,代码行数:34,代码来源:releaseall.c

示例6: initdata

static WORD initdata()
{
	union 
	{
		WORD tempvar;
		struct 
		{
			BYTE LoByte;
			BYTE HiByte;
		} bytes;
	} TWOBYTES;

	BYTE programflags;

	XEEBeginRead(sizeof(AppConfig)+ 49000); //This is a cheat, needs to fix memory map properly!

	programflags = XEERead();			//ONLY autorun program on first execution
	if (initflag == 0)
	{
		initflag=1;
		runprogram = CHECK_BIT(programflags,0);	
		debugoutput = CHECK_BIT(programflags,1);
	}

	TWOBYTES.bytes.HiByte = XEERead();
	TWOBYTES.bytes.LoByte = XEERead();

	return(TWOBYTES.tempvar);
}
开发者ID:DrAndyArmstrong,项目名称:tl-assembler,代码行数:29,代码来源:tlass.c

示例7: rotary_intr_handler

LOCAL void
rotary_intr_handler(int8_t key)
{
    uint8 direction = 0;
    uint32 inputs;
    
    inputs = PIN_IN; //Read input register

    //Read rotary state
    if (CHECK_BIT(inputs,13) == CHECK_BIT(inputs,12))
        direction = 1;

    //Not that sure what this does yet and where the register is used for
    uint32 gpio_status = GPIO_REG_READ(GPIO_STATUS_ADDRESS);

    //disable interrupt
    gpio_pin_intr_state_set(GPIO_ID_PIN(12), GPIO_PIN_INTR_DISABLE);

    //clear interrupt status
    GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, gpio_status & BIT(12));

    //Disarm timer
    os_timer_disarm(&rotary_debounce_timer);

    //Setup timer
    os_timer_setfn(&rotary_debounce_timer, (os_timer_func_t *)rotary_debounce, direction);

    //Arm the debounce timer
    os_timer_arm(&rotary_debounce_timer, 350, 0);
}
开发者ID:IoT-ESP8266,项目名称:ESP8266,代码行数:30,代码来源:user_buttons.c

示例8: lcdWriteBits

void lcdWriteBits(__s8 bits, __u8 char_mode)
{
	mcpOutput(pin_rs, char_mode);
	bool z;
	int i;
	for(i=7; i>=4; i--)
	{
		z = CHECK_BIT(bits,i);
		if(z)
			mcpOutput(pin_db[i-4], 1);
		else
			mcpOutput(pin_db[i-4], 0);
	}
	lcdPulseEnable();
	
	for(i=3; i>=0; i--)
	{
		z = CHECK_BIT(bits,i);
		if(z)
			mcpOutput(pin_db[i], 1);
		else
			mcpOutput(pin_db[i], 0);
	}
	lcdPulseEnable();
}
开发者ID:dylan32406,项目名称:rpi_lcd,代码行数:25,代码来源:lcd.c

示例9: main

int main(void) {
  char x = 0x0F, i;
  for (i = 0; i < 8; i++) {
    printf("%d : %d\n", i, CHECK_BIT(x, i) > 0);
    if (!CHECK_BIT(x, i)) SET_BIT(x, i);
    else UNSET_BIT(x, i);
  }
  printf("x: %x\n", x);
}
开发者ID:emancu,项目名称:pso,代码行数:9,代码来源:bit_check-test.c

示例10: SET_BIT

void CLogoState::Update(float fDT)
{
    m_fDT = fDT;
    m_fStateTimer += fDT;

    m_pGUI->Update(fDT);

    if (CHECK_BIT(m_nPhaseCheck, 2) == TRUE)
    {
        return;
    }

    if (m_fStateTimer > IMAGECHANGETIMER)
    {
        if (FadeToWhite(fDT, 1.0f) == TRUE)
        {
            if (FadeToNotBlack(fDT, 0.0f) == TRUE)
            {
                if (CHECK_BIT(m_nPhaseCheck, 0) == FALSE)
                {
                    SET_BIT(m_nPhaseCheck, 0);
                    m_fStateTimer = 0;
                    m_pGPLogo->SetVisible(false);
                    m_pStudioLogo->SetVisible(true);

                    m_fFadeIn = 0;
                    m_fFadeOut = 0;
                }
                else if (CHECK_BIT(m_nPhaseCheck, 1) == FALSE)
                {
                    SET_BIT(m_nPhaseCheck, 1);
                    m_fStateTimer = 0;
                    m_pStudioLogo->SetVisible(false);
                    m_pTeamLogo->SetVisible(true);

                    m_fFadeIn = 0;
                    m_fFadeOut = 0;
                }
                else if (CHECK_BIT(m_nPhaseCheck, 2) == FALSE)
                {
                    SET_BIT(m_nPhaseCheck, 2);
                    m_fStateTimer = 0;
                    m_pTeamLogo->SetVisible(false);
                    m_fFadeIn = 0;
                    m_fFadeOut = 0;

                    QueueStateChange(STATE_CH_MAINMENU);
                }
            }
        }
    }

    if (m_fFadeIn >= 0.0f && FadeToNotBlack(fDT, 0.0f) == FALSE)
    {
        return;
    }
}
开发者ID:jmazzola,项目名称:Damage-Control-FinalProject,代码行数:57,代码来源:LogoState.cpp

示例11: printNode

/* This function reads the memory from <currentPtr> and sets		*
 * a DEntry object's values.  Then prints all the required info		*
 * in the format.  Returns 1 if there are no more entries left		*/
int printNode(void *currentPtr) {
	DEntry Entry; int i;
	/* Get the status byte, no need for ntohs because */
	memcpy(&Entry.status, currentPtr, 1);
	currentPtr++;
	
	if (!CHECK_BIT(Entry.status, 0))						/* checks if the bit in <pos> is 1 */
		return 1;
	
	/* Get the starting block	*/
	memcpy(&Entry.startBlock, currentPtr, 4);
	Entry.startBlock = ntohl(Entry.startBlock);
	currentPtr += 4;
		
	/*	No need for this right now, maybe later 
	 *  memcpy(&Entry.numBlocks, currentPtr, 4);
	 *	Entry.numBlocks = ntohl(Entry.numBlocks);
	 */	
	currentPtr += 4;										/* Don't need the number of blocks	*/
	
	memcpy(&Entry.fileSize, currentPtr, 4);
	Entry.fileSize = ntohl(Entry.fileSize);
	currentPtr += 4;
	currentPtr += 7;										/* Don't need the creation date		*/
	
	memcpy(&Entry.modifyTimeYear, currentPtr, 2);
	Entry.modifyTimeYear = ntohs(Entry.modifyTimeYear);		/* Get the year as a short int		*/
	currentPtr += 2;
	
	for (i = 0;i < 5;i++) {
		memcpy(&Entry.modifyTime[i], currentPtr, 1);		/* store the date as YYYYMMDDHHSS	*/
		currentPtr++;
	}	
	
	memcpy(Entry.fileName, currentPtr, 31);					/* Get filename from 31 bytes, its already  */
	currentPtr += 37;										/* null terminated. skip the unused bytes	*/
	/* Output nicely */
	if (CHECK_BIT(Entry.status, 1))
		printf("F");
	else
		printf("D");
		
	printf("%10d%30s %4d/", Entry.fileSize, Entry.fileName, Entry.modifyTimeYear);
	for (i = 0;i < 4;i++) {
		if (i == 0)
			printf("%.2d/", Entry.modifyTime[i]);
		else if (i == 1)
			printf("%.2d ", Entry.modifyTime[i]);
		else
			printf("%.2d:", Entry.modifyTime[i]);
	}
	printf("%.2d\n", Entry.modifyTime[4]);
	return 0;
}
开发者ID:bradens,项目名称:uvc,代码行数:57,代码来源:disklist.c

示例12: __attribute__

void __attribute__ ((interrupt)) __cs3_isr_wwdg(void) {
	uint32_t msr = PWMSR;
	PWMSR = 0b111000;
	if(CHECK_BIT(msr, 5)) {
//		mb_core_message("COMPARE\n");
	}
	if(CHECK_BIT(msr, 4)) {
//		mb_core_print(msr);
	}
	if(CHECK_BIT(msr, 3)) {
//		mb_core_message("FIFO-EMPTY\n");
		// push a new compare value
		PWMSAR = makeSpeed(pwm_cmp);
	}
}
开发者ID:jonmcdonald,项目名称:VistaModels,代码行数:15,代码来源:motor.c

示例13: SoundPlayer_Play

void SoundPlayer_Play(SoundPlayer *sp) {
	SoundPlayer_SendCommand(sp, SP_PLAY);
	
	//Initialize the blocking timeout of 50ms
	Util_BlockWhile(0, 50);
	
	//PIN is two bytes before the associated PORT
	//Block until the busy pin goes high, or 50ms has passed
	while(Util_BlockWhile( !CHECK_BIT(*(sp->port - 2), sp->busyPin), 0 ));
	
	//Block until the busy signal goes low
	while(CHECK_BIT(*(sp->port - 2), sp->busyPin));
	
	//Wait 10ms. Otherwise the module can get confused with repeated play requests.
	Util_WaitMillis(10);
}
开发者ID:ISU-ETG,项目名称:Doorbell,代码行数:16,代码来源:SoundPlayer.c

示例14: acquire_spinlock_nocheck

static struct smp_msg *smp_check_for_message(int curr_cpu, int *source_mailbox)
{
    struct smp_msg *msg;

    acquire_spinlock_nocheck(&cpu_msg_spinlock[curr_cpu]);
    msg = smp_msgs[curr_cpu];
    if(msg != 0) {
        smp_msgs[curr_cpu] = msg->next;
        release_spinlock(&cpu_msg_spinlock[curr_cpu]);
        //		dprintf(" found msg 0x%x in cpu mailbox\n", msg);
        *source_mailbox = MAILBOX_LOCAL;
    } else {
        // try getting one from the broadcast mailbox

        release_spinlock(&cpu_msg_spinlock[curr_cpu]);
        acquire_spinlock_nocheck(&broadcast_msg_spinlock);

        msg = smp_broadcast_msgs;
        while(msg != 0) {
            if(CHECK_BIT(msg->proc_bitmap, curr_cpu) != 0) {
                // we have handled this one already
                msg = msg->next;
                continue;
            }

            // mark it so we wont try to process this one again
            msg->proc_bitmap = SET_BIT(msg->proc_bitmap, curr_cpu);
            *source_mailbox = MAILBOX_BCAST;
            break;
        }
        release_spinlock(&broadcast_msg_spinlock);
        //		dprintf(" found msg 0x%x in broadcast mailbox\n", msg);
    }
    return msg;
}
开发者ID:NoSuchProcess,项目名称:phantomuserland,代码行数:35,代码来源:smp.c

示例15: test_alloc

static
unsigned long long test_alloc(ivshmem_pci_dev_t *dev, size_t size){
/*
 * first implementation: First Fit
 *
 * param: size = # of needed _frames_
 *
 * returns index of first free frame
 * returns -1 if memory is filled
 *
 * */
    unsigned long long n;
    unsigned long long cnt = 0;

    for(n=0; n< dev->num_of_frames; n++)
    {
	if (!CHECK_BIT(dev->bitmap,n))
	{
	    cnt++;
	} else
	{
	    cnt = 0;
	}

	// return index of first free frame belonging to a block of at least N free frames!
	if (cnt >= size) {
	return (n - cnt + 1); // return index of first free frame belonging to a block of at least N free frames!
	}
    }
    return -1; //not enough memory
}
开发者ID:RWTH-OS,项目名称:pscom,代码行数:31,代码来源:psivshmem.c


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