本文整理汇总了C++中GET_LOCK函数的典型用法代码示例。如果您正苦于以下问题:C++ GET_LOCK函数的具体用法?C++ GET_LOCK怎么用?C++ GET_LOCK使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GET_LOCK函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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();
}
示例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;
}
示例4: cc2520_set_cca_threshold
/*---------------------------------------------------------------------------*/
void
cc2520_set_cca_threshold(int value)
{
GET_LOCK();
setreg(CC2520_CCACTRL0, value & 0xff);
RELEASE_LOCK();
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例10: cc2520_set_txpower
/*---------------------------------------------------------------------------*/
void
cc2520_set_txpower(uint8_t power)
{
GET_LOCK();
set_txpower(power);
RELEASE_LOCK();
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}