本文整理汇总了C++中BUSYWAIT_UNTIL函数的典型用法代码示例。如果您正苦于以下问题:C++ BUSYWAIT_UNTIL函数的具体用法?C++ BUSYWAIT_UNTIL怎么用?C++ BUSYWAIT_UNTIL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BUSYWAIT_UNTIL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cc2420_init
/*---------------------------------------------------------------------------*/
int
cc2420_init(void)
{
uint16_t reg;
{
int s = splhigh();
cc2420_arch_init(); /* Initalize ports and SPI. */
CC2420_DISABLE_FIFOP_INT();
CC2420_FIFOP_INT_INIT();
splx(s);
}
/* Turn on voltage regulator and reset. */
SET_VREG_ACTIVE();
BUSYWAIT_UNTIL(0, RTIMER_SECOND / 100);
SET_RESET_ACTIVE();
BUSYWAIT_UNTIL(0, RTIMER_SECOND / 100);
SET_RESET_INACTIVE();
BUSYWAIT_UNTIL(0, RTIMER_SECOND / 100);
pan = 0xffff;
addr = 0x0000;
BUSYWAIT_UNTIL(0, RTIMER_SECOND / 100);
powerup();
configure();
flushrx();
process_start(&cc2420_process, NULL);
return 1;
}
示例2: spirit_radio_off
/*---------------------------------------------------------------------------*/
static int
spirit_radio_off(void)
{
PRINTF("Spirit1: ->off\n");
if(spirit_on == ON) {
/* Disables the mcu to get IRQ from the SPIRIT1 */
IRQ_DISABLE();
/* first stop rx/tx */
spirit1_strobe(SPIRIT1_STROBE_SABORT);
/* Clear any pending irqs */
SpiritIrqClearStatus();
BUSYWAIT_UNTIL(SPIRIT1_STATUS() == SPIRIT1_STATE_READY, 5 * RTIMER_SECOND/1000);
if(SPIRIT1_STATUS() != SPIRIT1_STATE_READY) {
PRINTF("Spirit1: failed off->ready\n");
return 1;
}
/* Puts the SPIRIT1 in STANDBY */
spirit1_strobe(SPIRIT1_STROBE_STANDBY);
BUSYWAIT_UNTIL(SPIRIT1_STATUS() == SPIRIT1_STATE_STANDBY, 5 * RTIMER_SECOND/1000);
if(SPIRIT1_STATUS() != SPIRIT1_STATE_STANDBY) {
PRINTF("Spirit1: failed off->stdby\n");
return 1;
}
spirit_on = OFF;
CLEAR_TXBUF();
CLEAR_RXBUF();
}
PRINTF("Spirit1: off.\n");
return 0;
}
示例3: cc2520_set_channel
/*---------------------------------------------------------------------------*/
int
cc2520_set_channel(int c)
{
uint16_t f;
GET_LOCK();
/*
* Subtract the base channel (11), multiply by 5, which is the
* channel spacing. 357 is 2405-2048 and 0x4000 is LOCK_THR = 1.
*/
channel = c;
f = MIN_CHANNEL + ((channel - MIN_CHANNEL) * CHANNEL_SPACING);
/*
* Writing RAM requires crystal oscillator to be stable.
*/
BUSYWAIT_UNTIL((status() & (BV(CC2520_XOSC16M_STABLE))), RTIMER_SECOND / 10);
/* Wait for any transmission to end. */
BUSYWAIT_UNTIL(!(status() & BV(CC2520_TX_ACTIVE)), RTIMER_SECOND / 10);
/* Define radio channel (between 11 and 25) */
setreg(CC2520_FREQCTRL, f);
/* If we are in receive mode, we issue an SRXON command to ensure
that the VCO is calibrated. */
if(receive_on) {
strobe(CC2520_INS_SRXON);
}
RELEASE_LOCK();
return 1;
}
示例4: cc2420_set_channel
/*---------------------------------------------------------------------------*/
int
cc2420_set_channel(int c)
{
uint16_t f;
GET_LOCK();
/*
* Subtract the base channel (11), multiply by 5, which is the
* channel spacing. 357 is 2405-2048 and 0x4000 is LOCK_THR = 1.
*/
channel = c;
f = 5 * (c - 11) + 357 + 0x4000;
/*
* Writing RAM requires crystal oscillator to be stable.
*/
BUSYWAIT_UNTIL((status() & (BV(CC2420_XOSC16M_STABLE))), RTIMER_SECOND / 10);
/* Wait for any transmission to end. */
BUSYWAIT_UNTIL(!(status() & BV(CC2420_TX_ACTIVE)), RTIMER_SECOND / 10);
setreg(CC2420_FSCTRL, f);
/* If we are in receive mode, we issue an SRXON command to ensure
that the VCO is calibrated. */
if(receive_on) {
strobe(CC2420_SRXON);
}
RELEASE_LOCK();
return 1;
}
示例5: spirit_radio_on
/*---------------------------------------------------------------------------*/
static int
spirit_radio_on(void)
{
PRINTF("Spirit1: on\n");
if(spirit_on == OFF) {
IRQ_DISABLE();
/* ensure we are in READY state as we go from there to Rx */
spirit1_strobe(SPIRIT1_STROBE_READY);
BUSYWAIT_UNTIL(SPIRIT1_STATUS() == SPIRIT1_STATE_READY, 5 * RTIMER_SECOND/1000);
if(SPIRIT1_STATUS() != SPIRIT1_STATE_READY) {
PRINTF("Spirit1: failed to turn on\n");
panic_ra(4);
return 1;
}
/* now we go to Rx */
spirit1_strobe(SPIRIT1_STROBE_RX);
BUSYWAIT_UNTIL(SPIRIT1_STATUS() == SPIRIT1_STATE_RX, 5 * RTIMER_SECOND/1000);
if(SPIRIT1_STATUS() != SPIRIT1_STATE_RX) {
PRINTF("Spirit1: failed to enter rx\n");
panic_ra(5);
return 1;
}
/* Enables the mcu to get IRQ from the SPIRIT1 */
IRQ_ENABLE();
spirit_on = ON;
}
return 0;
}
示例6: transmit
/*---------------------------------------------------------------------------*/
static int
transmit(unsigned short payload_len)
{
if(tx_in_progress) {
return RADIO_TX_COLLISION;
}
tx_in_progress = 1;
/* Energest */
if(listen_on) {
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
}
ENERGEST_ON(ENERGEST_TYPE_TRANSMIT);
/* Transmit and wait */
vMMAC_StartPhyTransmit(&tx_frame_buffer,
E_MMAC_TX_START_NOW |
(send_on_cca ? E_MMAC_TX_USE_CCA : E_MMAC_TX_NO_CCA));
if(poll_mode) {
BUSYWAIT_UNTIL(u32MMAC_PollInterruptSource(E_MMAC_INT_TX_COMPLETE), MAX_PACKET_DURATION);
} else {
if(in_ack_transmission) {
/* as nested interupts are not possible, the tx flag will never be cleared */
BUSYWAIT_UNTIL(FALSE, MAX_ACK_DURATION);
} else {
/* wait until the tx flag is cleared */
BUSYWAIT_UNTIL(!tx_in_progress, MAX_PACKET_DURATION);
}
}
/* Energest */
ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
if(listen_on) {
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
}
tx_in_progress = 0;
/* Check error code */
int ret;
uint32_t tx_error = u32MMAC_GetTxErrors();
if(tx_error == 0) {
ret = RADIO_TX_OK;
RIMESTATS_ADD(acktx);
} else if(tx_error & E_MMAC_TXSTAT_ABORTED) {
ret = RADIO_TX_ERR;
RIMESTATS_ADD(sendingdrop);
} else if(tx_error & E_MMAC_TXSTAT_CCA_BUSY) {
ret = RADIO_TX_COLLISION;
RIMESTATS_ADD(contentiondrop);
} else if(tx_error & E_MMAC_TXSTAT_NO_ACK) {
ret = RADIO_TX_NOACK;
RIMESTATS_ADD(noacktx);
} else {
ret = RADIO_TX_ERR;
}
return ret;
}
示例7: cc2520_set_pan_addr
/*---------------------------------------------------------------------------*/
void
cc2520_set_pan_addr(unsigned pan,
unsigned addr,
const uint8_t *ieee_addr)
{
uint8_t tmp[2];
GET_LOCK();
/*
* Writing RAM requires crystal oscillator to be stable.
*/
BUSYWAIT_UNTIL(status() & (BV(CC2520_XOSC16M_STABLE)), RTIMER_SECOND / 10);
tmp[0] = pan & 0xff;
tmp[1] = pan >> 8;
CC2520_WRITE_RAM(&tmp, CC2520RAM_PANID, 2);
tmp[0] = addr & 0xff;
tmp[1] = addr >> 8;
CC2520_WRITE_RAM(&tmp, CC2520RAM_SHORTADDR, 2);
if(ieee_addr != NULL) {
int f;
uint8_t tmp_addr[8];
// LSB first, MSB last for 802.15.4 addresses in CC2520
for (f = 0; f < 8; f++) {
tmp_addr[7 - f] = ieee_addr[f];
}
CC2520_WRITE_RAM(tmp_addr, CC2520RAM_IEEEADDR, 8);
}
RELEASE_LOCK();
}
示例8: cc1200_arch_init
/*---------------------------------------------------------------------------*/
void
cc1200_arch_init(void)
{
SPI_InitHighFreq(1);
CC1200_CLK_ALT_MODE;
CC1200_MISO_ALT_MODE;
CC1200_MOSI_ALT_MODE;
/* First leave RESET high */
CC1200_RESET_OUTPUT;
CC1200_RESET_SET;
/* Initialize CSn, enable CSn and then wait for MISO to go low*/
SPI_WAITFORTx_BEFORE();
/* Configure GPIOx */
CC1200_GDO2_INPUT_FLOAT;
CC1200_GDO0_INPUT_FLOAT;
/* Leave CSn as default */
cc1200_arch_spi_deselect();
/* Ensure MISO is high */
BUSYWAIT_UNTIL(
CC1200_MISO_GET(),
RTIMER_SECOND / 10);
}
示例9: cc2520_rssi
/*---------------------------------------------------------------------------*/
int
cc2520_rssi(void)
{
int rssi;
int radio_was_off = 0;
if(locked) {
return 0;
}
GET_LOCK();
if(!receive_on) {
radio_was_off = 1;
cc2520_on();
}
BUSYWAIT_UNTIL(status() & BV(CC2520_RSSI_VALID), RTIMER_SECOND / 100);
rssi = (int)((signed char)getreg(CC2520_RSSI));
if(radio_was_off) {
cc2520_off();
}
RELEASE_LOCK();
return rssi;
}
示例10: cc1200_arch_init
/*---------------------------------------------------------------------------*/
void
cc1200_arch_init(void)
{
/* First leave RESET high */
GPIO_SOFTWARE_CONTROL(CC1200_RESET_PORT_BASE, CC1200_RESET_PIN_MASK);
GPIO_SET_OUTPUT(CC1200_RESET_PORT_BASE, CC1200_RESET_PIN_MASK);
ioc_set_over(CC1200_RESET_PORT, CC1200_RESET_PIN, IOC_OVERRIDE_OE);
GPIO_SET_PIN(CC1200_RESET_PORT_BASE, CC1200_RESET_PIN_MASK);
/* Initialize CSn, enable CSn and then wait for MISO to go low*/
spix_cs_init(CC1200_SPI_CSN_PORT, CC1200_SPI_CSN_PIN);
/* Initialize SPI */
spix_init(CC1200_SPI_INSTANCE);
/* Configure GPIOx */
GPIO_SOFTWARE_CONTROL(CC1200_GDO0_PORT_BASE, CC1200_GDO0_PIN_MASK);
GPIO_SET_INPUT(CC1200_GDO0_PORT_BASE, CC1200_GDO0_PIN_MASK);
GPIO_SOFTWARE_CONTROL(CC1200_GDO2_PORT_BASE, CC1200_GDO2_PIN_MASK);
GPIO_SET_INPUT(CC1200_GDO2_PORT_BASE, CC1200_GDO2_PIN_MASK);
/* Leave CSn as default */
cc1200_arch_spi_deselect();
/* Ensure MISO is high */
BUSYWAIT_UNTIL(
GPIO_READ_PIN(CC1200_SPI_MISO_PORT_BASE, CC1200_SPI_MISO_PIN_MASK),
RTIMER_SECOND / 10);
}
示例11: cc1200_arch_spi_select
/*---------------------------------------------------------------------------*/
void
cc1200_arch_spi_select(void)
{
/* Set CSn to low (0) */
GPIO_CLR_PIN(CC1200_SPI_CSN_PORT_BASE, CC1200_SPI_CSN_PIN_MASK);
/* The MISO pin should go low before chip is fully enabled. */
BUSYWAIT_UNTIL(
GPIO_READ_PIN(CC1200_SPI_MISO_PORT_BASE, CC1200_SPI_MISO_PIN_MASK) == 0,
RTIMER_SECOND / 100);
}
示例12: cc1200_arch_spi_select
/*---------------------------------------------------------------------------*/
void
cc1200_arch_spi_select(void)
{
/* Set CSn to low (0) */
CC1200_CSN_CLR;
/* The MISO pin should go low before chip is fully enabled. */
BUSYWAIT_UNTIL(
CC1200_MISO_GET() == 0,
RTIMER_SECOND / 100);
}
示例13: on
static void
on(void)
{
CC2520_ENABLE_FIFOP_INT();
strobe(CC2520_INS_SRXON);
BUSYWAIT_UNTIL(status() & (BV(CC2520_XOSC16M_STABLE)), RTIMER_SECOND / 100);
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
receive_on = 1;
}
示例14: spirit_radio_channel_clear
/*---------------------------------------------------------------------------*/
static int
spirit_radio_channel_clear(void)
{
float rssi_value;
/* Local variable used to memorize the SPIRIT1 state */
uint8_t spirit_state = ON;
PRINTF("CHANNEL CLEAR IN\n");
if(spirit_on == OFF) {
/* Wakes up the SPIRIT1 */
spirit_radio_on();
spirit_state = OFF;
}
/* */
IRQ_DISABLE();
spirit1_strobe(SPIRIT1_STROBE_SABORT);
/* SpiritCmdStrobeSabort();*/
SpiritIrqClearStatus();
IRQ_ENABLE();
{
rtimer_clock_t timeout = RTIMER_NOW() + 5 * RTIMER_SECOND/1000;
do {
SpiritRefreshStatus();
} while((g_xStatus.MC_STATE != MC_STATE_READY) && (RTIMER_NOW() < timeout));
if(RTIMER_NOW() < timeout) {
return 1;
}
}
/* Stores the RSSI value */
rssi_value = SpiritQiGetRssidBm();
/* Puts the SPIRIT1 in its previous state */
if(spirit_state==OFF) {
spirit_radio_off();
} else {
spirit1_strobe(SPIRIT1_STROBE_RX);
/* SpiritCmdStrobeRx();*/
BUSYWAIT_UNTIL(SPIRIT1_STATUS() == SPIRIT1_STATE_RX, 5 * RTIMER_SECOND/1000);
}
PRINTF("CHANNEL CLEAR OUT\n");
/* Checks the RSSI value with the threshold */
if(rssi_value<CCA_THRESHOLD) {
return 0;
} else {
return 1;
}
}
示例15: amb8420SetDstAddress
bool amb8420SetDstAddress(uint8_t dstAddress)
{
bool ok;
Handle_t handle;
RPRINTF("set dst addr to %#02x\n", dstAddress);
// disable radio rx/tx
AMB8420ModeContext_t ctx;
AMB8420_ENTER_STANDBY_MODE(ctx);
// better be safe than sorry - treat 0 as broadcast too
if (dstAddress == 0) dstAddress = 0xff;
// Wait for device to become ready
AMB8420_WAIT_FOR_RTS_READY(ok);
if (!ok) goto end;
// PRINTF("set dst, tar=%u\n", TAR);
// ATOMIC_START_TIMESAVE(handle);
AMB8420_SERIAL_CAPTURE(ok);
commandInProgress = AMB8420_CMD_SET_DESTADDR_REQ;
serialSendByte(AMB8420_UART_ID, AMB8420_START_DELIMITER);
serialSendByte(AMB8420_UART_ID, AMB8420_CMD_SET_DESTADDR_REQ);
serialSendByte(AMB8420_UART_ID, 0x1);
serialSendByte(AMB8420_UART_ID, dstAddress);
serialSendByte(AMB8420_UART_ID, AMB8420_START_DELIMITER
^ AMB8420_CMD_SET_DESTADDR_REQ ^ 0x1 ^ dstAddress);
AMB8420_SERIAL_FREE();
// ATOMIC_END_TIMESAVE(handle);
// PRINTF("end set dst, tar=%u\n", TAR);
// wait for reply
INTERRUPT_ENABLED_START(handle);
BUSYWAIT_UNTIL(!commandInProgress, TIMER_100_MS, ok);
// if (commandInProgress) PRINTF("set dst addr: command wait fail\n");
INTERRUPT_ENABLED_END(handle);
// if (!ok) goto end;
// Wait for device to become ready
AMB8420_WAIT_FOR_RTS_READY(ok);
end:
AMB8420_RESTORE_MODE(ctx);
// PRINTF(" ok = %d\n", (int)ok);
// if (!ok) amb8420Reset();
return ok;
}