當前位置: 首頁>>代碼示例>>C++>>正文


C++ CLR_BIT函數代碼示例

本文整理匯總了C++中CLR_BIT函數的典型用法代碼示例。如果您正苦於以下問題:C++ CLR_BIT函數的具體用法?C++ CLR_BIT怎麽用?C++ CLR_BIT使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了CLR_BIT函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: main

int main(void){

	DDRA = 0xFF; //set all pins of port A to output
	DDRC = 0x00; //set all pins of port C to input

	while(1)
	{
		int one = 1;
		int count = 0;
		int i = 0;
		while(i < 8)
		{
			int temp = GET_BIT(PINC,i);
			if(temp != 0)
			{
				count++;
			}
			++i;
		}
		if ((count % 2) != 0)
		{
			CLR_BIT(PORTA, 1);
			one = SET_BIT(PORTA, 0);
		}
		else 
		{
				CLR_BIT(PORTA, 0);
			one = SET_BIT(PORTA, 1);
		}
		count = 0;
	}

return 0;
	
}
開發者ID:redgarthwaite,項目名稱:UCR,代碼行數:35,代碼來源:lab1p2.c

示例2: qat_hal_set_ae_lm_mode

int qat_hal_set_ae_lm_mode(struct icp_qat_fw_loader_handle *handle,
			   unsigned char ae, enum icp_qat_uof_regtype lm_type,
			   unsigned char mode)
{
	unsigned int csr, new_csr;

	qat_hal_rd_ae_csr(handle, ae, CTX_ENABLES, &csr);
	csr &= IGNORE_W1C_MASK;
	switch (lm_type) {
	case ICP_LMEM0:
		new_csr = (mode) ?
			SET_BIT(csr, CE_LMADDR_0_GLOBAL_BITPOS) :
			CLR_BIT(csr, CE_LMADDR_0_GLOBAL_BITPOS);
		break;
	case ICP_LMEM1:
		new_csr = (mode) ?
			SET_BIT(csr, CE_LMADDR_1_GLOBAL_BITPOS) :
			CLR_BIT(csr, CE_LMADDR_1_GLOBAL_BITPOS);
		break;
	default:
		pr_err("QAT: lmType = 0x%x\n", lm_type);
		return -EINVAL;
	}

	if (new_csr != csr)
		qat_hal_wr_ae_csr(handle, ae, CTX_ENABLES, new_csr);
	return 0;
}
開發者ID:GavinHwa,項目名稱:linux,代碼行數:28,代碼來源:qat_hal.c

示例3: Hyperjump

/*
 * Player has used hyperjump item.
 */
static void Hyperjump(player_t *pl)
{
    clpos_t dest;
    int counter;
    hitmask_t hitmask = NONBALL_BIT | HITMASK(pl->team); /* kps - ok ? */

    /* Try to find empty space to hyperjump to. */
    for (counter = 100; counter > 0; counter--) {
	dest = World_get_random_clpos();
	if (shape_is_inside(dest.cx, dest.cy, hitmask, OBJ_PTR(pl),
			    (shape_t *)pl->ship, pl->dir) == NO_GROUP)
	    break;
    }

    /* We can't find an empty space, hyperjump failed. */
    if (!counter) {
	/* need to do something else here ? */
	Set_player_message(pl, "Could not hyperjump. [*Server notice*]");
	CLR_BIT(pl->obj_status, WARPING);
	sound_play_sensors(pl->pos, HYPERJUMP_SOUND);
	return;
    }

    sound_play_sensors(pl->pos, HYPERJUMP_SOUND);

    Warp_balls(pl, dest);

    Object_position_init_clpos(OBJ_PTR(pl), dest);
    pl->forceVisible += 15;

    CLR_BIT(pl->obj_status, WARPING);
}
開發者ID:calumchisholm,項目名稱:XPilotNG-web,代碼行數:35,代碼來源:wormhole.c

示例4: LCD_WriteCommand

void LCD_WriteCommand (unsigned char Command) {
   CLR_BIT(CONTROL_BUS,RS);
   DATA_BUS = Command;
   SET_BIT(CONTROL_BUS,E);
   asm("nop");
   CLR_BIT(CONTROL_BUS,E);
   delay_ms(2); // ClearScreen requires 1.52ms to execute
}
開發者ID:Martin-Ting,項目名稱:RunningClock,代碼行數:8,代碼來源:io.c

示例5: set_to_NC

void set_to_NC(c) {
	for (int x=4; x < 8; x++) {
		if (x != c) {
			CLR_BIT(DDRC, x);
			CLR_BIT(PORTC, x);
		}
	}
}
開發者ID:eputh,項目名稱:Play-Music,代碼行數:8,代碼來源:keypad.c

示例6: output

static void output(unsigned char d, unsigned char rs) {
  if( rs ) SET_BIT(PORT, RS_PIN); else CLR_BIT(PORT, RS_PIN);
  CLR_BIT(PORT, RW_PIN);
  set_data(d);
  SET_BIT(PORT, EN_PIN);
  sleep_700ns();
  CLR_BIT(PORT, EN_PIN);
}
開發者ID:abdulmajeed90,項目名稱:SixthSense,代碼行數:8,代碼來源:lcd.c

示例7: input

static unsigned char input(unsigned char rs) {
  unsigned char d;
  if( rs ) SET_BIT(PORT, RS_PIN); else CLR_BIT(PORT, RS_PIN);
  SET_BIT(PORT, RW_PIN);
  get_data();
  SET_BIT(PORT, EN_PIN);
  sleep_700ns();
  d = get_data();
  CLR_BIT(PORT, EN_PIN);
  return d;
}
開發者ID:abdulmajeed90,項目名稱:SixthSense,代碼行數:11,代碼來源:lcd.c

示例8: timer1_init

void timer1_init()
{
//	uint16_t count;

	//Timer 1 is used by or for:
	//	a) Control Loop Timing and interrupt
	//	b) Decoding RC reciever pulses

	//With a clock prescale of 8 we get
	//Minimum interrupt time period = 400ns(2.5MHz)
	//Maxiumum interrupt time period = 26.2144ms(38.14Hz)
	
	//With a clock prescale of 64 we get
	//Minimum interrupt time period = 3.2us
	

	//Do not use loop rate greater than 500Hz as that will mess up the RC decoding logic.
	//Safe operating loop rate in terms of not conflicting with RC reciever decoding is from
	//lower than 300Hz.

	TCCR1A = 0;
	TCCR1B = 0;

	// Prescalar 64
	SET_BIT(TCCR1B, CS11);
	SET_BIT(TCCR1B, CS10); 

// 	//CTC (Clear Timer on Compare Match)
// 	CLR_BIT(TCCR1B, WGM13); 
// 	SET_BIT(TCCR1B, WGM12); 
// 	CLR_BIT(TCCR1A, WGM11); 
// 	CLR_BIT(TCCR1A, WGM10); 

	//Normal non PWM mode
 	CLR_BIT(TCCR1B, WGM13); 
 	CLR_BIT(TCCR1B, WGM12); 
 	CLR_BIT(TCCR1A, WGM11); 
 	CLR_BIT(TCCR1A, WGM10); 


// 	//Calculate count value to generate given interrupt rate.
// 	//8 is clock prescale used for Timer 1
// 	count = (F_CPU/(CONTROL_LOOP_RATE*8));
// 	OCR1A = count;

// 	TIMSK1 = 0;
// 	//Enable interrupt on Compare Match A
// 	SET_BIT(TIMSK1, OCIE1A); 
 	SET_BIT(TIMSK1, TOIE1); 

}
開發者ID:liubingzsd,項目名稱:pushpak,代碼行數:51,代碼來源:pushpak.C

示例9: key_pressed

unsigned char key_pressed(unsigned char r, unsigned char c) {
	DDRC = 0;
	PORTC = 0;
	CLR_BIT(DDRC, r);
	SET_BIT(PORTC, r);
	SET_BIT(DDRC, c + 4);
	CLR_BIT(PORTC, c + 4);
	if (!GET_BIT(PINC, r)) {
		return 1;
	}
	else {
		return 0;
	}
}
開發者ID:arashn,項目名稱:obdii-reader,代碼行數:14,代碼來源:main.c

示例10: flashSuccess

void flashSuccess(void)
{
	SET_BIT(PORTB, 0);
	wait_avr(150);
	CLR_BIT(PORTB, 0);
	wait_avr(150);
	SET_BIT(PORTB, 0);
	wait_avr(150);
	CLR_BIT(PORTB, 0);
	wait_avr(150);
	SET_BIT(PORTB, 0);
	wait_avr(150);
	CLR_BIT(PORTB, 0);
}
開發者ID:abdulmajeed90,項目名稱:SixthSense,代碼行數:14,代碼來源:i2c.c

示例11: handleDisconnect1

static int handleDisconnect1(struct slice *slice, int clNo)
{    
    if(slice != NULL) {
	if (BIT_ISSET(clNo, slice->sl_reqack.readySet)) {
	    /* avoid counting client both as left and ready */
	    CLR_BIT(clNo, slice->sl_reqack.readySet);
	    slice->nrReady--;
	}
	if (BIT_ISSET(clNo, slice->answeredSet)) {
	    slice->nrAnswered--;
	    CLR_BIT(clNo, slice->answeredSet);
	}
    }
    return 0;
}
開發者ID:elisescu,項目名稱:udpcast,代碼行數:15,代碼來源:senddata.c

示例12: get_key

unsigned char get_key(void) {
	for (int r=0; r < 4; r++) {
		CLR_BIT(DDRC, r);
		SET_BIT(PORTC, r);
		for (int c=4; c < 8; c++) {
			SET_BIT(DDRC, c);
			CLR_BIT(PORTC, c);
			set_to_NC(c);
			if (key_pressed(r,c)) {
				return (r*4) + c - 3;
			}
		}
	}
	return 0;
}
開發者ID:eputh,項目名稱:Play-Music,代碼行數:15,代碼來源:keypad.c

示例13: setPinModeInput

void setPinModeInput(t_SetPortCfg* cfg, uint8_t bit)
{
	t_stPort* stport=(t_stPort *)cfg->pID;  //make the pointer points to the Port Registers in memory
	cfg->Portdir=stport->portDirReg;
    CLR_BIT(cfg->Portdir,bit);
    stport->portDirReg &= cfg->Portdir;
}
開發者ID:Integreight,項目名稱:1Sheeld-Firmware,代碼行數:7,代碼來源:gpio.c

示例14: pressed

_Bool pressed(int col, int row)
{
	CLR_BIT(PORTC, col);
	_Bool buttonPressed = !GET_BIT(PINC, col) && !GET_BIT(PINC, row);
	
	return !GET_BIT(PINC, col) && !GET_BIT(PINC, row);
}
開發者ID:ellenmliu,項目名稱:CS145,代碼行數:7,代碼來源:avr.c

示例15: psivshmem_free_mem

int psivshmem_free_mem(ivshmem_pci_dev_t *dev, char * frame_ptr, size_t size)
{
/*
 * first implementation: just clear corresponding bit in bitmap -> frame is available
 *
 * "a = b/c"  int division round up
 * int a = (b + (c - 1)) / c  <- rounds up for positiv int, e.g. frameIndices
 *
 *
 */
    unsigned long long n;
    unsigned long long index_low, index_high;

    if(!psivshmem_ptr_in_dev(dev, frame_ptr)) return -1;
    if(!psivshmem_ptr_in_dev(dev, frame_ptr + size)) return -1;

    index_low = (frame_ptr - dev->ivshmem_base) / dev->frame_size; //has to be a multiple of it!
    index_high = (frame_ptr - dev->ivshmem_base + size + (dev->frame_size - 1)) / dev->frame_size;

    pthread_spin_lock(dev->spinlock);

        for(n = index_low; n<=index_high;n++) {  //'unlock' all N used frames
	    CLR_BIT(dev->bitmap, n);
	}

    pthread_spin_unlock(dev->spinlock);

return 0;
}
開發者ID:RWTH-OS,項目名稱:pscom,代碼行數:29,代碼來源:psivshmem.c


注:本文中的CLR_BIT函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。