本文整理汇总了C++中GET_LOCK函数的典型用法代码示例。如果您正苦于以下问题:C++ GET_LOCK函数的具体用法?C++ GET_LOCK怎么用?C++ GET_LOCK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GET_LOCK函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: send
/*---------------------------------------------------------------------------*/
static int
send(const void *payload, unsigned short payload_len)
{
int res = 0;
GET_LOCK();
cc2520ll_prepare(payload, payload_len);
RELEASE_LOCK();
GET_LOCK();
res = cc2520ll_transmit();
RELEASE_LOCK();
return res;
}
开发者ID:mikewen,项目名称:virtual-sense,代码行数:14,代码来源:radio-driver.c
示例2: uz2400_set_pan_addr
/*---------------------------------------------------------------------------*/
void
uz2400_set_pan_addr(unsigned pan,
unsigned addr,
const cyg_uint8 *ieee_addr)
{
cyg_uint16 f = 0;
GET_LOCK();
/*
UzSetPanId(pan);
*/ uz_set_panId(pan);
/*
UzSetNwkAddr(addr);
*/ uz_set_nwk_addr(addr);
if(ieee_addr != NULL) {
cyg_uint8 addr[8];
/* LSB first, MSB last for 802.15.4 addresses in UZ2400 */
for (f = 0; f < 8; f++) {
addr[7-f] = ieee_addr[f];
}
/*
UzSetMacAddress(addr);
*/ uz_set_mac_address(addr);
}
RELEASE_LOCK();
}
开发者ID:xdpsee,项目名称:uIP_on_eCos,代码行数:30,代码来源:uz2400_dev.c
示例3: channel_clear
int
channel_clear(void)
{
int cca;
int radio_was_off = 0;
PRINTF("CCA\n");
/* If the radio is locked by an underlying thread (because we are
being invoked through an interrupt), we preted that the coast is
clear (i.e., no packet is currently being transmitted by a
neighbor). */
if(locked) {
return 1;
}
GET_LOCK();
if(!receive_on) {
radio_was_off = 1;
cc2520_on();
}
/* Make sure that the radio really got turned on. */
if(!receive_on) {
RELEASE_LOCK();
if(radio_was_off) {
cc2520_off();
}
return 1;
}
cca = cc2520ll_channel_clear();
if(radio_was_off) {
cc2520_off();
}
RELEASE_LOCK();
return cca;
}
开发者ID:mikewen,项目名称:virtual-sense,代码行数:34,代码来源:radio-driver.c
示例4: cc2520_set_cca_threshold
/*---------------------------------------------------------------------------*/
void
cc2520_set_cca_threshold(int value)
{
GET_LOCK();
setreg(CC2520_CCACTRL0, value & 0xff);
RELEASE_LOCK();
}
开发者ID:1uk3,项目名称:contiki,代码行数:8,代码来源:cc2520.c
示例5: cc2520_off
/*---------------------------------------------------------------------------*/
int
cc2520_off(void)
{
PRINTF("OFF\n");
/* Don't do anything if we are already turned off. */
if(receive_on == 0) {
//PRINTF("DONT CALL OFF WAS OFF\n");
return 1;
}
/* If we are called when the driver is locked, we indicate that the
radio should be turned off when the lock is unlocked. */
if(locked) {
/* PRINTF("Off when locked (%d)\n", locked);*/
lock_off = 1;
//PRINTF("DONT CALL OFF WAS LOCKED SCHEDULE OFF\n");
return 1;
}
GET_LOCK();
/* If we are currently receiving a packet (indicated by SFD == 1),
we don't actually switch the radio off now, but signal that the
driver should switch off the radio once the packet has been
received and processed, by setting the 'lock_off' variable. */
if(cc2520ll_rxtx_packet()) {
//PRINTF("DONT CALL OFF WAS LOCKED SCHEDULE OFF BUSY\n");
lock_off = 1;
} else {
//PRINTF("CALL OFF WAS ON\n");
off();
}
RELEASE_LOCK();
return 1;
}
开发者ID:mikewen,项目名称:virtual-sense,代码行数:35,代码来源:radio-driver.c
示例6: cc2520_off
/*---------------------------------------------------------------------------*/
int
cc2520_off(void)
{
/* Don't do anything if we are already turned off. */
if(receive_on == 0) {
return 1;
}
/* If we are called when the driver is locked, we indicate that the
radio should be turned off when the lock is unlocked. */
if(locked) {
/* printf("Off when locked (%d)\n", locked);*/
lock_off = 1;
return 1;
}
GET_LOCK();
/* If we are currently receiving a packet (indicated by SFD == 1),
we don't actually switch the radio off now, but signal that the
driver should switch off the radio once the packet has been
received and processed, by setting the 'lock_off' variable. */
if(status() & BV(CC2520_TX_ACTIVE)) {
lock_off = 1;
} else {
off();
}
RELEASE_LOCK();
return 1;
}
开发者ID:1uk3,项目名称:contiki,代码行数:30,代码来源:cc2520.c
示例7: cc2520_prepare
/*---------------------------------------------------------------------------*/
static int
cc2520_prepare(const void *payload, unsigned short payload_len)
{
uint8_t total_len;
GET_LOCK();
PRINTF("cc2520: sending %d bytes\n", payload_len);
/*int i;
for(i = 0; i < payload_len;i++)
printf("%x",((uint8_t *) payload)[i]);
printf("\n");*/
RIMESTATS_ADD(lltx);
/* Wait for any previous transmission to finish. */
/* while(status() & BV(CC2520_TX_ACTIVE));*/
/* Write packet to TX FIFO. */
strobe(CC2520_INS_SFLUSHTX);
total_len = payload_len + FOOTER_LEN;
CC2520_WRITE_FIFO_BUF(&total_len, 1);
CC2520_WRITE_FIFO_BUF(payload, payload_len);
RELEASE_LOCK();
return 0;
}
开发者ID:1uk3,项目名称:contiki,代码行数:27,代码来源:cc2520.c
示例8: 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();
}
开发者ID:1uk3,项目名称:contiki,代码行数:34,代码来源:cc2520.c
示例9: 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;
}
开发者ID:1uk3,项目名称:contiki,代码行数:34,代码来源:cc2520.c
示例10: cc2520_set_txpower
/*---------------------------------------------------------------------------*/
void
cc2520_set_txpower(uint8_t power)
{
GET_LOCK();
set_txpower(power);
RELEASE_LOCK();
}
开发者ID:1uk3,项目名称:contiki,代码行数:8,代码来源:cc2520.c
示例11: stm_unit_load
/*
* Called by the CURRENT thread to load a word-sized value in a unit transaction.
*/
stm_word_t stm_unit_load(volatile stm_word_t *addr, stm_word_t *timestamp)
{
volatile stm_word_t *lock;
stm_word_t l, l2, value;
PRINT_DEBUG2("==> stm_unit_load(a=%p)\n", addr);
/* Get reference to lock */
lock = GET_LOCK(addr);
/* Read lock, value, lock */
restart:
l = ATOMIC_LOAD_ACQ(lock);
restart_no_load:
if (LOCK_GET_OWNED(l)) {
/* Locked: wait until lock is free */
sched_yield();
goto restart;
}
/* Not locked */
value = ATOMIC_LOAD_ACQ(addr);
l2 = ATOMIC_LOAD_ACQ(lock);
if (l != l2) {
l = l2;
goto restart_no_load;
}
if (timestamp != NULL)
*timestamp = LOCK_GET_TIMESTAMP(l);
return value;
}
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:35,代码来源:stm.o.c
示例12: 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;
}
开发者ID:1uk3,项目名称:contiki,代码行数:27,代码来源:cc2520.c
示例13: cc2420_prepare
/*---------------------------------------------------------------------------*/
static int
cc2420_prepare(const void *payload, unsigned short payload_len)
{
uint8_t total_len;
#if CC2420_CONF_CHECKSUM
uint16_t checksum;
#endif /* CC2420_CONF_CHECKSUM */
GET_LOCK();
PRINTF("cc2420: sending %d bytes\n", payload_len);
RIMESTATS_ADD(lltx);
/* Wait for any previous transmission to finish. */
/* while(status() & BV(CC2420_TX_ACTIVE));*/
/* Write packet to TX FIFO. */
strobe(CC2420_SFLUSHTX);
#if CC2420_CONF_CHECKSUM
checksum = crc16_data(payload, payload_len, 0);
#endif /* CC2420_CONF_CHECKSUM */
total_len = payload_len + AUX_LEN;
CC2420_WRITE_FIFO_BUF(&total_len, 1);
CC2420_WRITE_FIFO_BUF(payload, payload_len);
#if CC2420_CONF_CHECKSUM
CC2420_WRITE_FIFO_BUF(&checksum, CHECKSUM_LEN);
#endif /* CC2420_CONF_CHECKSUM */
RELEASE_LOCK();
return 0;
}
开发者ID:leoqin,项目名称:Contiki-leo,代码行数:33,代码来源:cc2420.c
示例14: 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;
}
开发者ID:leoqin,项目名称:Contiki-leo,代码行数:33,代码来源:cc2420.c
示例15: cc2420_set_cca_threshold
/*---------------------------------------------------------------------------*/
void
cc2420_set_cca_threshold(int value)
{
uint16_t shifted = value << 8;
GET_LOCK();
setreg(CC2420_RSSI, shifted);
RELEASE_LOCK();
}
开发者ID:leoqin,项目名称:Contiki-leo,代码行数:9,代码来源:cc2420.c
示例16: uz2400_set_txpower
/*---------------------------------------------------------------------------*/
void
uz2400_set_txpower(cyg_uint8 power)
{
GET_LOCK();
/*
UzSetTxPower(power);
*/ uz_set_tx_power(power);
RELEASE_LOCK();
}
开发者ID:xdpsee,项目名称:uIP_on_eCos,代码行数:10,代码来源:uz2400_dev.c
示例17: cc2420_get_txpower
/*---------------------------------------------------------------------------*/
int
cc2420_get_txpower(void)
{
int power;
GET_LOCK();
power = (int)(getreg(CC2420_TXCTRL) & 0x001f);
RELEASE_LOCK();
return power;
}
开发者ID:leoqin,项目名称:Contiki-leo,代码行数:10,代码来源:cc2420.c
示例18: cc2520_get_txpower
/*---------------------------------------------------------------------------*/
int
cc2520_get_txpower(void)
{
uint8_t power;
GET_LOCK();
power = getreg(CC2520_TXPOWER);
RELEASE_LOCK();
return power;
}
开发者ID:1uk3,项目名称:contiki,代码行数:10,代码来源:cc2520.c
示例19: uz2400_set_cca_threshold
/*---------------------------------------------------------------------------*/
void
uz2400_set_cca_threshold(int value)
{
cyg_uint16 shifted = value << 8;
GET_LOCK();
/*
setreg(UZ2400_RSSI, shifted);
*/
RELEASE_LOCK();
}
开发者ID:xdpsee,项目名称:uIP_on_eCos,代码行数:11,代码来源:uz2400_dev.c
示例20: read
static int
read(void *buf, unsigned short buf_len)
{
int res = 0;
PRINTF("READ\n");
GET_LOCK();
res = cc2520ll_packetReceive(buf, buf_len) - 2;
RELEASE_LOCK();
return res;
}
开发者ID:mikewen,项目名称:virtual-sense,代码行数:10,代码来源:radio-driver.c
注:本文中的GET_LOCK函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论