本文整理汇总了C++中BV函数的典型用法代码示例。如果您正苦于以下问题:C++ BV函数的具体用法?C++ BV怎么用?C++ BV使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BV函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cipher16
/* Encrypt at most 16 bytes of data. */
static void
cipher16(uint8_t *data, int len)
{
uint8_t status;
len = MIN(len, MAX_DATALEN);
CC2420_WRITE_RAM(data, CC2420RAM_SABUF, len);
CC2420_STROBE(CC2420_SAES);
/* Wait for the encryption to finish */
do {
CC2420_GET_STATUS(status);
} while(status & BV(CC2420_ENC_BUSY));
CC2420_READ_RAM(data, CC2420RAM_SABUF, len);
}
示例2: phy_hw_read
/*
* \brief Read contents of PHY register.
*
* \param reg PHY register number.
*
* \return Contents of the specified register.
*/
static uint16_t phy_hw_read(uint8_t phy_addr, reg8_t reg)
{
// PHY read command.
EMAC_MAN = EMAC_SOF | EMAC_RW_READ
| ((phy_addr << EMAC_PHYA_SHIFT) & EMAC_PHYA)
| ((reg << EMAC_REGA_SHIFT) & EMAC_REGA)
| EMAC_CODE;
// Wait until PHY logic completed.
while (!(EMAC_NSR & BV(EMAC_IDLE)))
cpu_relax();
// Get data from PHY maintenance register.
return (uint16_t)(EMAC_MAN & EMAC_DATA);
}
示例3: spi_init
/*
* Initialize SPI bus.
*/
void
spi_init(void)
{
static unsigned char spi_inited = 0;
if (spi_inited)
return;
/* Initalize ports for communication with SPI units. */
/* CSN=SS and must be output when master! */
DDRB |= BV(MOSI) | BV(SCK) | BV(CSN);
PORTB |= BV(MOSI) | BV(SCK);
/* Enables SPI, selects "master", clock rate FCK / 2, and SPI mode 0 */
SPCR = BV(SPE) | BV(MSTR);
SPSR = BV(SPI2X);
}
示例4: timer_start_timerEx
/**************************************************************************************************
*
* @fn timer_start_timerEx
*
* @brief Modeled after OSAL_start_timerEx.
* To stop timer call with same threadId, and event, and
* set timeout to 0.
*
* @param threadId - Id of the thread to call at the event.
* @param event - event bitmask
* @param timeout - number of milliseconds to count down
*
* @return void
*/
uint8 timer_start_timerEx(uint8 threadId, uint32 event, uint32 timeout)
{
uint8 i;
if (event == 0)
{
// No event requested, just return
return -1;
}
for (i = 0; i < 32; i++)
{
if (event & BV(i))
break;
}
LOG_DEBUG_TIMER("[TIMER] timer_start_timerEx(%d, 0x%.8X, %d)... \n", threadId, event, timeout);
fflush(LOG_DESTINATION_FP);
// To avoid race conditions we cannot update timerThreadTbl without mutex lock
pthread_mutex_lock(&timerMutex);
LOG_DEBUG_TIMER("lock (line: %d)\n", __LINE__);
// Value is stored in us for better precision
timerThreadTbl[threadId].timeoutValue[i] = timeout * 1000;
// Use a 0 value of timeout to disable timer
if (timeout)
{
// Enable event
timerThreadTbl[threadId].timerEnabled |= event;
// We also need to make sure the timer update does not decrement now.
timerThreadTbl[threadId].justKicked |= event;
}
else
{
timerThreadTbl[threadId].timerEnabled &= ~event;
// Clear event in case it just fired.
timer_clear_event(threadId, event);
}
LOG_DEBUG_TIMER("[TIMER] Timer started for %dus, for event 0x%.8X and thread %d\n",
(int)timerThreadTbl[threadId].timeoutValue[i], event, threadId);
// Unlock mutex before notifying timer thread
pthread_mutex_unlock(&timerMutex);
// Notify timer thread that timer has been set
pthread_cond_signal(&timerSetCond);
return 1;
}
示例5: NRF24L01_Initialize
void NRF24L01_Initialize(uint8_t baseConfig)
{
standbyConfig = BV(NRF24L01_00_CONFIG_PWR_UP) | baseConfig;
NRF24_CE_LO();
// nRF24L01+ needs 100 milliseconds settling time from PowerOnReset to PowerDown mode
static const uint32_t settlingTimeUs = 100000;
const uint32_t currentTimeUs = micros();
if (currentTimeUs < settlingTimeUs) {
delayMicroseconds(settlingTimeUs - currentTimeUs);
}
// now in PowerDown mode
NRF24L01_WriteReg(NRF24L01_00_CONFIG, standbyConfig); // set PWR_UP to enter Standby mode
// nRF24L01+ needs 4500 microseconds from PowerDown mode to Standby mode, for crystal oscillator startup
delayMicroseconds(4500);
// now in Standby mode
}
示例6: cc2420_off
void
cc2420_off(void)
{
u8_t spiStatusByte;
if (receive_on == 0)
return;
receive_on = 0;
/* Wait for transmission to end before turning radio off. */
do {
spiStatusByte = cc2420_status();
} while (spiStatusByte & BV(CC2420_TX_ACTIVE));
cc2420_strobe(CC2420_SRFOFF);
DISABLE_FIFOP_INT();
}
示例7: on
static void
on(void)
{
if(completely_off) {
completely_off = 0;
powerup();
configure();
}
CC2420_ENABLE_FIFOP_INT();
strobe(CC2420_SRXON);
BUSYWAIT_UNTIL(status() & (BV(CC2420_XOSC16M_STABLE)), RTIMER_SECOND / 100);
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
receive_on = 1;
}
示例8: compile_preamble
int
compile_preamble(int *instructions, struct local *s)
{
int *instp;
int len;
int extra_regs, i, j, t, disp;
extra_regs = s->maxreg - INITIAL_NSCRATCHREGS;
if (extra_regs > 0) {
len = extra_regs * 2 + 4;
/* stw rp | (n-1) * stw | bl | stw | ldw rp | (n-1) * ldw | bv | ldw */
} else
return 0;
if (instructions == NULL)
return len;
instp = instructions;
/* Generate a wrapper function to save the callee-saves registers
before invoking the filter code we have generated. It would be
marginally better to have the filter branch directly to the
postamble code on return, but the difference is trivial and it
is easier to have it always branch to (rp). */
#define FRAME_SIZE 128 /* This is plenty without being excessive. */
*instp++ = STW_NEG(REG_RTN, 20, REG_SP); /* stw rp,-20(sp) */
i = INITIAL_NSCRATCHREGS;
t = STWM(scratchregs[i], FRAME_SIZE, REG_SP); /* stwm r3,128(sp) */
j = FRAME_SIZE;
while (++i < s->maxreg) {
*instp++ = t;
j -= sizeof (int);
t = STW_NEG(scratchregs[i], j, REG_SP); /* stw r4,-124(sp) &c */
}
disp = extra_regs + 2; /* n * ldw | bv | ldw rp */
*instp++ = BL(disp, REG_RTN); /* bl filter,rp */
*instp++ = t; /* stw in delay slot */
*instp++ = LDW_NEG(FRAME_SIZE + 20, REG_SP, REG_RTN);
/* ldw -148(sp),rp */
while (--i > INITIAL_NSCRATCHREGS) {
*instp++ = LDW_NEG(j, REG_SP, scratchregs[i]); /* ldw -124(sp),r4 &c */
j += sizeof (int);
}
*instp++ = BV(0, REG_RTN); /* bv (rp) */
*instp++ = LDWM_NEG(FRAME_SIZE, REG_SP, scratchregs[i]);
/* ldwm -128(sp),r3
in delay slot */
assert(instp - instructions == len);
return len;
}
示例9: adc_init
void adc_init (void)
{
adc_ch = 0;
adc_ports[0] = ADC_VOLT;
ADCSRA = BV(ADEN); /* enable ADC conversion */
ADCSRA |= (BV(ADPS2) | BV(ADPS1) | BV(ADPS0)); /* div by 128 presc. */
ADCSRA |= BV(ADIE); /* interrupt enable */
ADMUX = adc_ports[adc_ch]; /* Voltage reference is AREF) */
ADCSRA |= BV(ADSC); /* request ADC conversion */
}
示例10: delegateSetCellStatus
void delegateSetCellStatus(uint8_t xCol){
// Col -> set only one port as output low and all others as input full up
DDRCOLUMNS = BV(xCol); // 해당 col을 출력으로 설정, 나머지 입력
PORTCOLUMNS = ~BV(xCol); // 해당 col output low, 나머지 컬럼을 풀업 저항
/*
DDR을 1로 설정하면 출력, 0이면 입력
입력중, PORT가 1이면 풀업(풀업 상태는 high 상태);
출력 상태의 PORT가 0이면 output low(0v);
스위치를 on하면 0, off하면 1이 PIN에 저장;
row는 내부 풀업 저항 상태 이기 때문에 1값이 기본값
*/
_delay_us(5);
}
示例11: SDR_Init
//.........这里部分代码省略.........
0xef, //Normal maximum
0xab, //Normal minimum
0xff, //Sensor Maximum reading
0x00, //Sensor Minimum reading
0xf7, //Upper non-recoverable Threshold
0xf2, //Upper critical Threshold
0xe9, //Upper non critical Threshold
//Byte 40
0xa2, //Lower non-recoverable Threshold
0xa7, //Lower critical Threshold
0xab, //Lower non-critical Threshold
0x02, //positive going Threshold hysteresis value
0x02, //negative going Threshold hysteresis value
0x00, //reserved
0x00, //reserved
0x00, //OEM reserved
//Byte 48
0xc3, //8 bit ASCII, number of bytes
'1', '2', 'V' //sensor string
};
u08 SDR7[] =
{
//sensor record header
0x05, //record number, LSB - filled by SDR_Init()
0x00, //record number, MSB - filled by SDR_Init()
0x51, //IPMI protocol version
0x02, //record type: compact sensor
0x23, //record length: remaining bytes, SDR_Init
//record key bytes
0x00, //i2c address, filled by SDR_Init
0x00, //sensor owner LUN
FPGA_SLAVE, //sensor number
//record body bytes
//Byte 8
0xc1, //entity id: MCH
0x00, //entity instance, SDR_Init
0x03, //init: events + scanning enabled
0xc2, //capabilities: auto re-arm, global disable
0x07, //type: Power Supply(DC-to-DC converter)
0x0a, //sensor discrete event/read
0x01, //LSB assert event mask: 1 bit value
0x00, //MSB assert event mask
0x01, //LSB deassert event mask: 1 bit value
0x00, //MSB deassert event mask
0x01, //LSB read event mask: 1 bit value
0x00, //MSB read event mask
0xc0, //sensor units 1
0x00, //sensor units 2
0x00, //sensor units 3
0x01, //sharing: 1 sensor
0x00, //no entity instance string
0x00, //no positive threshold hysteresis
0x00, //no negative threshold hysteresis
0x00, //reserved
0x00, //reserved
0x00, //reserved
0x00, //OEM reserved
0xca, //8 bit ASCII, number of bytes
'F', 'P', 'G', 'A', '_', 'S', 'L', 'A', 'V', 'E' //sensor string
};
u08 *sdrPtr[NUM_SDR] = {SDR0, SDR1, SDR2, SDR3, SDR4, SDR5, SDR6, SDR7};
u08 sdrLen[NUM_SDR] = {sizeof(SDR0), sizeof(SDR1), sizeof(SDR2), sizeof(SDR3), sizeof(SDR4), sizeof(SDR5), sizeof(SDR6), sizeof(SDR7)};
sensor_t sens[NUM_SENSOR];
//******************/
void leds_init_user() //Called from leds_init in led.c
//******************/
{
led[USER_LED].local_cntr_fnc = LED_OFF;
led[USER_LED].fnc_off = LED_OFF;
led[USER_LED].on_duration = 0;
led[USER_LED].color = RED;
led[USER_LED].control_state = LOCAL_CONTROL_STATE;
local_led_control_user(USER_LED, LED_OFF);
}
//**************************/
u08 state_led_user(u08 led_n) //Called from state_led in led.c
//**************************/
{
if (led[led_n].control_state == OVERRIDE_STATE)
return (0); //MJ: 0 = LED_OFF. Is this what we want in mmc_main.c? What is OVERRIDE_STATE used for?
switch (led_n)
{
case USER_LED:
if (inb(LED_USER_IN) & BV(LED_USER_PIN)) return LED_OFF;
else return LED_ON;
break;
default:
break;
}
return (0xff); //MJ: mmc_main.c does not process this error. How could it react?
}
示例12: spi_set_speed
void spi_set_speed(spi_speed_t speed) {
/* Wait until TX fifo is empty */
while (!BITBAND(SSP_REGS->SR, 0)) ;
/* Disable SSP (FIXME: Is this required?) */
SSP_REGS->CR1 = 0;
/* Change clock divisor */
if (speed == SPI_SPEED_FAST) {
SSP_REGS->CPSR = SSP_CLK_DIVISOR_FAST;
} else {
SSP_REGS->CPSR = SSP_CLK_DIVISOR_SLOW;
}
/* Enable SSP */
SSP_REGS->CR1 = BV(1);
}
示例13: I2c_Read_Byte
/*************************************************************
* @fn I2c_Read_Byte
*
* @brief This func for read byte
* Make i2c data wire to be input
*
* @param none
*
* @return uint8
*/
uint8 I2c_Read_Byte( void )
{
uint8 Num, Recv = 0;
I2C_DAT = 1;
P0DIR &= ~BV(0); // Make i2c data wire to be input
for(Num = 0; Num < 8; Num++)
{
I2C_CLK = 0;
delay_us(2);
I2C_CLK = 1;
Recv = (Recv << 1) | I2C_DAT;// delay_us(2);
// I2C_CLK = 1;
delay_us(2);
}
P0DIR |= BV(0); // Restore i2c data wire direction
return Recv;
}
示例14: HalSPIWrite
void HalSPIWrite(uint32 addr, uint8 *pBuf, uint16 len)
{
uint8 cnt;
uint8 shdw = P1DIR;
P1DIR |= BV(3);
while (len)
{
XNV_SPI_BEGIN();
do {
xnvSPIWrite(XNV_STAT_CMD);
} while (XNV_SPI_RX() & XNV_STAT_WIP);
XNV_SPI_END();
asm("NOP"); asm("NOP");
XNV_SPI_BEGIN();
xnvSPIWrite(XNV_WREN_CMD);
XNV_SPI_END();
asm("NOP"); asm("NOP");
XNV_SPI_BEGIN();
xnvSPIWrite(XNV_WRPG_CMD);
xnvSPIWrite(addr >> 16);
xnvSPIWrite(addr >> 8);
xnvSPIWrite(addr);
// Can only write within any one page boundary, so prepare for next page write if bytes remain.
cnt = 0 - (uint8)addr;
if (cnt)
{
addr += cnt;
}
else
{
addr += 256;
}
do
{
xnvSPIWrite(*pBuf++);
cnt--;
len--;
} while (len && cnt);
XNV_SPI_END();
}
P1DIR = shdw;
}
示例15: off
static void
off(void)
{
/* PRINTF("off\n");*/
receive_on = 0;
/* Wait for transmission to end before turning radio off. */
BUSYWAIT_UNTIL(!(status() & BV(CC2520_TX_ACTIVE)), RTIMER_SECOND / 10);
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
strobe(CC2520_INS_SRFOFF);
CC2520_DISABLE_FIFOP_INT();
if(!CC2520_FIFOP_IS_1) {
flushrx();
}
}