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


C++ set_bits函数代码示例

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


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

示例1: codec_detect

static int codec_detect(u8 *base)
{
	u32 reg32;

	/* Set bit 0 to 0 to enter reset state (BAR + 0x8)[0]. */
	if (set_bits(base + 0x08, 1, 0) == -1)
		goto no_codec;

	/* Set bit 0 to 1 to exit reset state (BAR + 0x8)[0]. */
	if (set_bits(base + 0x08, 1, 1) == -1)
		goto no_codec;

	/* Read in codec location (BAR + 0xe)[2..0]. */
	reg32 = read32(base + 0xe);
	reg32 &= 0x0f;
	if (!reg32)
		goto no_codec;

	return reg32;

no_codec:
	/* Codec not found. */
	/* Put HDA back in reset (BAR + 0x8)[0]. */
	set_bits(base + 0x08, 1, 0);
	printk(BIOS_DEBUG, "Azalia: No codec!\n");
	return 0;
}
开发者ID:AdriDlu,项目名称:coreboot,代码行数:27,代码来源:azalia.c

示例2: stv6419_set_vsw

inline int stv6419_set_vsw( struct i2c_client *client, int sw, int type )
{
	printk("[AVS]: %s: SET VSW: %d %d\n",__func__, sw, type);

	if (type<0 || type>4)
	{
		return -EINVAL;
	}

	switch(sw)
	{
		case 0:	// VCR video output selection
	        set_bits(regs, cReg2, type, 7, 1);
			break;
		case 1:	// rgb selection
			if (type<0 || type>2)
			{
				return -EINVAL;
			}

			set_bits(regs, cReg2, type, 5, 2);
			break;
		case 2: // TV video output selection
			set_bits(regs, cReg2, type, 3, 2);
			break;
		default:
			return -EINVAL;
	}

	dprintk("[AVS]: %s <\n", __func__);
	return stv6419_set(client);
}
开发者ID:Firmeware,项目名称:max-tdt,代码行数:32,代码来源:stv6419.c

示例3: stv6418_set_vsw

inline int stv6418_set_vsw( struct i2c_client *client, int sw, int type )
{
	printk("[AVS]: %s: SET VSW: %d %d\n",__func__, sw, type);

	if (type<0 || type>4)
	{
		return -EINVAL;
	}

	switch(sw)
	{
		case 0:	// vcr
	        set_bits(regs, cReg2, type, 4, 3);
			break;
		case 1:	// rgb
			if (type<0 || type>2)
			{
				return -EINVAL;
			}

			set_bits(regs, cReg3, type, 2, 2);
			break;
		case 2: // tv
			set_bits(regs, cReg2, type, 0, 3);
			break;
		default:
			return -EINVAL;
	}

	dprintk("[AVS]: %s <\n", __func__);
	return stv6418_set(client);
}
开发者ID:Raxone,项目名称:STB8000_TDT_SH4,代码行数:32,代码来源:stv6418.c

示例4: codec_detect

static u32 codec_detect(u32 base)
{
	u32 dword;

	/* Set Bit0 to 0 to enter reset state (BAR + 0x8)[0] */
	if (set_bits(base + 0x08, 1, 0) == -1)
		goto no_codec;

	/* Set Bit 0 to 1 to exit reset state (BAR + 0x8)[0] */
	if (set_bits(base + 0x08, 1, 1) == -1)
		goto no_codec;

	/* Delay for 1 ms since the BKDG does */
	mdelay(1);

	/* Read in Codec location (BAR + 0xe)[3..0]*/
	dword = read32(base + 0xe);
	dword &= 0x0F;
	if (!dword)
		goto no_codec;

	return dword;

no_codec:
	/* Codec Not found */
	/* Put HDA back in reset (BAR + 0x8) [0] */
	set_bits(base + 0x08, 1, 0);
	printk(BIOS_DEBUG, "No codec!\n");
	return 0;
}
开发者ID:0ida,项目名称:coreboot,代码行数:30,代码来源:hda.c

示例5: set_fmt_bits

static inline void set_fmt_bits(void __iomem *addr, u32 bits)
{
	set_bits(addr + SPIFMT0, bits);
	set_bits(addr + SPIFMT1, bits);
	set_bits(addr + SPIFMT2, bits);
	set_bits(addr + SPIFMT3, bits);
}
开发者ID:mrtos,项目名称:Logitech-Revue,代码行数:7,代码来源:davinci_spi_master.c

示例6: codec_detect

static int codec_detect(u32 base)
{
	u8 reg8;

	/* Set Bit 0 to 1 to exit reset state (BAR + 0x8)[0] */
	if (set_bits(base + 0x08, 1, 1) == -1)
		goto no_codec;

	/* Write back the value once reset bit is set. */
	write16(base + 0x0, read16(base + 0x0));

	/* Read in Codec location (BAR + 0xe)[2..0]*/
	reg8 = read8(base + 0xe);
	reg8 &= 0x0f;
	if (!reg8)
		goto no_codec;

	return reg8;

no_codec:
	/* Codec Not found */
	/* Put HDA back in reset (BAR + 0x8) [0] */
	set_bits(base + 0x08, 1, 0);
	printk(BIOS_DEBUG, "Azalia: No codec!\n");
	return 0;
}
开发者ID:0ida,项目名称:coreboot,代码行数:26,代码来源:azalia.c

示例7: hda_codec_detect

/**
 * Probe for supported codecs
 */
int hda_codec_detect(u32 base)
{
	u8 reg8;

	/* Set Bit 0 to 1 to exit reset state (BAR + 0x8)[0] */
	if (set_bits(base + HDA_GCTL_REG, HDA_GCTL_CRST, HDA_GCTL_CRST) < 0)
		goto no_codec;

	/* Write back the value once reset bit is set. */
	write16(base + HDA_GCAP_REG, read16(base + HDA_GCAP_REG));

	/* Read in Codec location (BAR + 0xe)[2..0]*/
	reg8 = read8(base + HDA_STATESTS_REG);
	reg8 &= 0x0f;
	if (!reg8)
		goto no_codec;

	return reg8;

no_codec:
	/* Codec Not found */
	/* Put HDA back in reset (BAR + 0x8) [0] */
	set_bits(base + HDA_GCTL_REG, HDA_GCTL_CRST, 0);
	printk(BIOS_DEBUG, "HDA: No codec!\n");
	return 0;
}
开发者ID:0ida,项目名称:coreboot,代码行数:29,代码来源:hda_verb.c

示例8: stv6419_set_mute

inline int stv6419_set_mute( struct i2c_client *client, int type )
{
	dprintk("[AVS]: %s >\n", __func__);

	if ((type<0) || (type>1))
	{
		return -EINVAL;
	}
	

	if (type == AVS_MUTE) 
	{
		
		   audio_value = get_bits(regs, cReg0, 0, 2); 
		 

		   set_bits(regs, cReg0, 0, 0, 2); /* audio mute */
		 
		
	}
	else /* unmute with old values */
	{
		
			
			set_bits(regs, cReg0, audio_value, 0, 2); /* audio unmute */
			
			
			audio_value = 0xff;
		
	}
	dprintk("[AVS]: %s <\n", __func__);
	return stv6419_set(client);
}
开发者ID:Firmeware,项目名称:max-tdt,代码行数:33,代码来源:stv6419.c

示例9: d2083_audio_poweron

static inline int d2083_audio_poweron(bool on)
{
	int ret = 0;
	int (*set_bits)(struct d2083 * const d2083, u8 const reg, u8 const mask);

	if(on==true) {
		audio_write(D2083_LDO1_MCTL_REG, 0x54);
		audio_write(D2083_LDO_AUD_MCTL_REG, 0x54);
	}	
	set_bits = (on) ? d2083_set_bits : d2083_clear_bits;

	ret |= set_bits(d2083, D2083_PREAMP_A_CTRL1_REG, D2083_PREAMP_EN);
	ret |= set_bits(d2083, D2083_PREAMP_B_CTRL1_REG, D2083_PREAMP_EN);
	ret |= set_bits(d2083, D2083_MXHPR_CTRL_REG, D2083_MX_EN);
	ret |= set_bits(d2083, D2083_MXHPL_CTRL_REG, D2083_MX_EN);
	ret |= set_bits(d2083, D2083_CP_CTRL_REG, D2083_CP_EN);

	if(on==false){
		audio_write(D2083_CP_CTRL_REG,0xC9);
		audio_write(D2083_LDO1_MCTL_REG, 0x00);
		audio_write(D2083_LDO_AUD_MCTL_REG, 0x00);
	}

	return ret;
}
开发者ID:faizauthar12,项目名称:Hyper_kernel,代码行数:25,代码来源:d2083-audio.c

示例10: stv6419_set_wss

inline int stv6419_set_wss( struct i2c_client *client, int vol )
{
/* fixme: on stv6418 we hav more possibilites here
 * think on this ->see register description below
 */
	dprintk("[AVS]: %s >\n", __func__);

	if (vol == SAA_WSS_43F)
	{
           set_bits(regs, cReg3, 3, 2, 3);
	}
	else if (vol == SAA_WSS_169F)
	{
           set_bits(regs, cReg3, 2, 2, 3);
	}
	else if (vol == SAA_WSS_OFF)
	{
           set_bits(regs, cReg3, 0, 2, 3);
	}
	else
	{
		return  -EINVAL;
	}

	dprintk("[AVS]: %s <\n", __func__);
	return stv6419_set(client);
}
开发者ID:Firmeware,项目名称:max-tdt,代码行数:27,代码来源:stv6419.c

示例11: test_bv_combined_boolean_ops

static void test_bv_combined_boolean_ops(TestCase *tc, void *data)
{
    BitVector *bv1 = bv_new();
    BitVector *bv2 = bv_new();
    BitVector *bv3;
    BitVector *bv4;
    BitVector *bv5;
    BitVector *bv_empty = bv_new();
    (void)data;

    set_bits(bv1, "1, 5, 7");
    set_bits(bv2, "1, 8, 20");

    bv3 = bv_not(bv1);
    Aiequal(bv3->size, bv1->size);

    bv4 = bv_and(bv1, bv3);
    Assert(bv_eq(bv4, bv_empty), "bv & ~bv == empty BitVector");
    bv_destroy(bv4);

    bv4 = bv_and(bv2, bv3);
    bv5 = set_bits(bv_new(), "8, 20");
    Assert(bv_eq(bv4, bv5), "~[1,5,7] & [1,8,20] == [8,20]");
    bv_destroy(bv4);
    bv_destroy(bv5);

    bv4 = bv_or(bv1, bv3);
    bv5 = bv_not(bv_empty);
    Assert(bv_eq(bv4, bv5), "bv | ~bv == all 1s");
    bv_destroy(bv4);
    bv_destroy(bv5);

    bv4 = bv_or(bv2, bv3);
    bv5 = bv_not_x(set_bits(bv_new(), "5, 7"));
    Assert(bv_eq(bv4, bv5), "~[1,5,7] | [1,8,20] == ~[5, 7]");
    bv_destroy(bv4);
    bv_destroy(bv5);

    bv4 = bv_xor(bv1, bv3);
    bv5 = bv_not(bv_empty);
    Assert(bv_eq(bv4, bv5), "bv ^ ~bv == full BitVector");
    bv_destroy(bv4);
    bv_destroy(bv5);

    bv4 = bv_xor(bv2, bv3);
    bv5 = bv_not_x(set_bits(bv_new(), "5, 7, 8, 20"));
    Assert(bv_eq(bv4, bv5), "~[1,5,7] ^ [1,8,20] == ~[5, 7, 8, 20]");
    bv_destroy(bv4);
    bv_destroy(bv5);

    bv_destroy(bv1);
    bv_destroy(bv2);
    bv_destroy(bv3);
    bv_destroy(bv_empty);
}
开发者ID:Bira,项目名称:ferret,代码行数:55,代码来源:test_bitvector.c

示例12: init_accel

//*****************************************************************************
// Initialize Accelerometer
//*****************************************************************************
//  
// This function initializes the accelerometer. Listed Below are the parameters
// that the accelerometer is initialized to.
void init_accel(){
    
    // Enable X,Y and Z accelerometer axes
    set_bits(CTRL9_XL, Xen_XL | Yen_XL | Zen_XL); 

    // Set accelerometer ODR to 1.66KHz and acceleration range to +/- 8G's
    set_bits(CTRL1_XL, ODR_XL2 | FS_XL0 | FS_XL1);

    // Enable data ready interrupt on INT1
    set_bits(INT1_CTRL, INT1_DRDY_XL);

}
开发者ID:keatonunheardof,项目名称:MotionMusic,代码行数:18,代码来源:LSM6DS3.c

示例13: assert

void breakpoint_Relocation::set_enabled(bool b) {
  assert(!is_copy(), "cannot change breakpoint state when working on a copy");

  if (enabled() == b) return;

  if (b) {
    set_bits(bits() | enabled_state);
  } else {
    set_active(false);		// remove the actual breakpoint insn, if any
    set_bits(bits() & ~enabled_state);
  }
}
开发者ID:fatman2021,项目名称:myforthprocessor,代码行数:12,代码来源:relocInfo.cpp

示例14: test01

/* Tests bits set/clear/test functions */
static void test01(struct sb *sb, block_t blocks)
{
	tux3_msg(sb, "---- test bitops ----");
	unsigned char bits[16];
	memset(bits, 0, sizeof(bits));
	/* set some bits */
	set_bits(bits, 6, 20);
	set_bits(bits, 49, 16);
	set_bits(bits, 0x51, 2);
	/* test set bits */
	test_assert(all_set(bits, 6, 20));
	test_assert(all_set(bits, 49, 16));
	test_assert(all_set(bits, 0x51, 2));
	/* test clear bits */
	test_assert(all_clear(bits, 6, 20) == 0);
	test_assert(all_clear(bits, 49, 16) == 0);
	test_assert(all_clear(bits, 0x51, 2) == 0);
	/* should return false */
	test_assert(all_set(bits, 5, 20) == 0);
	test_assert(all_set(bits, 49, 17) == 0);
	test_assert(all_set(bits, 0x51, 3) == 0);
	test_assert(all_clear(bits, 5, 20) == 0);
	test_assert(all_clear(bits, 49, 17) == 0);
	test_assert(all_clear(bits, 0x51, 3) == 0);

	/* all zero now */
	clear_bits(bits, 6, 20);
	clear_bits(bits, 49, 16);
	clear_bits(bits, 0x51, 2);
	test_assert(all_clear(bits, 0, 8 * sizeof(bits)));
	test_assert(all_clear(bits, 6, 20));
	test_assert(all_clear(bits, 49, 16));
	test_assert(all_clear(bits, 0x51, 2));
	test_assert(all_set(bits, 6, 20) == 0);
	test_assert(all_set(bits, 49, 16) == 0);
	test_assert(all_set(bits, 0x51, 2) == 0);

	/* Corner case */
#if 1
	unsigned char *bitmap = malloc(8); /* bitmap must be array of ulong */
#else
	unsigned char *bitmap = malloc(7);
#endif
	set_bits(bitmap, 0, 7 * 8);
	test_assert(all_set(bitmap, 0, 7 * 8));
	test_assert(all_clear(bitmap, 0, 7 * 8) == 0);
	clear_bits(bitmap, 0, 7 * 8);
	test_assert(all_clear(bitmap, 0, 7 * 8));
	test_assert(all_set(bitmap, 0, 7 * 8) == 0);
	free(bitmap);

	clean_main(sb);
}
开发者ID:AbhijeetPawar,项目名称:tux3,代码行数:54,代码来源:balloc.c

示例15: init_gyro

void init_gyro(){

    // Enable X,Y and Z gyroscope axes
    set_bits(CTRL10_C, Xen_G | Yen_G | Zen_G); 

    // Set gyroscope ODR to 1.66KHz angular rate to to 1000 degrees/second
    set_bits(CTRL2_G, ODR_G2 | FS_G1);

    // Enable gyroscope data ready interrupt on INT1
    set_bits(INT2_CTRL, INT2_DRDY_G);   

}
开发者ID:keatonunheardof,项目名称:MotionMusic,代码行数:12,代码来源:LSM6DS3.c


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