本文整理汇总了C++中ENTER_CRITICAL_REGION函数的典型用法代码示例。如果您正苦于以下问题:C++ ENTER_CRITICAL_REGION函数的具体用法?C++ ENTER_CRITICAL_REGION怎么用?C++ ENTER_CRITICAL_REGION使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ENTER_CRITICAL_REGION函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: timer_service
/**
* @brief Timer handling services
*
* This Function performs timer handling services.
* It calls functions which are responsible
* 1) to put the expired timer into the expired timer queue, and
* 2) to service expired timers and call the respective callback.
*/
void timer_service(void)
{
ENTER_CRITICAL_REGION();
internal_timer_handler();
LEAVE_CRITICAL_REGION();
/*
* Process expired timers.
* Call the callback functions of the expired timers in the order of their
* expiry.
*/
{
timer_expiry_cb_t callback;
void *callback_param;
uint8_t next_expired_timer;
/* Expired timer if any will be processed here */
while (NO_TIMER != expired_timer_queue_head)
{
ENTER_CRITICAL_REGION();
next_expired_timer = timer_array[expired_timer_queue_head].next_timer_in_queue;
/* Callback is stored */
callback = (timer_expiry_cb_t)timer_array[expired_timer_queue_head].timer_cb;
/* Callback parameter is stored */
callback_param = timer_array[expired_timer_queue_head].param_cb;
/*
* The expired timer's structure elements are updated and the timer
* is taken out of expired timer queue
*/
timer_array[expired_timer_queue_head].next_timer_in_queue = NO_TIMER;
timer_array[expired_timer_queue_head].timer_cb = NULL;
timer_array[expired_timer_queue_head].param_cb = NULL;
/*
* The expired timer queue head is updated with the next timer in the
* expired timer queue.
*/
expired_timer_queue_head = next_expired_timer;
if (NO_TIMER == expired_timer_queue_head)
{
expired_timer_queue_tail = NO_TIMER;
}
LEAVE_CRITICAL_REGION();
if (NULL != callback)
{
/* Callback function is called */
callback(callback_param);
}
}
}
}
开发者ID:nandojve,项目名称:embedded,代码行数:66,代码来源:pal_timer.c
示例2: timer_service
/**
* @brief Timer handling services
*
* This Function performs timer handling services.
* It calls functions which are responsible
* 1) to put the expired timer into the expired timer queue, and
* 2) to service expired timers and call the respective callback.
*/
void timer_service(void)
{
/*Check if any timer has expired. */
ENTER_CRITICAL_REGION();
internal_timer_handler();
LEAVE_CRITICAL_REGION();
/*
* Process expired timers.
* Call the callback functions of the expired timers in the order of their
* expiry.
*/
timer_expiry_cb_t callback;
void *callback_param;
uint8_t next_expired_timer;
/* Expired timer if any will be processed here */
while (NO_TIMER != expired_timer_queue_head)
{
/*Saving the current interrupt status & disabling the global interrupt */
ENTER_CRITICAL_REGION();
next_expired_timer =
timer_array[expired_timer_queue_head].next_timer_in_queue;
/*Callback is stored */
callback = (timer_expiry_cb_t)timer_array[expired_timer_queue_head].timer_cb;
/*Callback parameter is stored */
callback_param = timer_array[expired_timer_queue_head].param_cb;
/*
* The expired timer's structure elements are updated and the timer
* is taken out of expired timer queue
*/
timer_array[expired_timer_queue_head].next_timer_in_queue = NO_TIMER;
timer_array[expired_timer_queue_head].timer_cb = NULL;
timer_array[expired_timer_queue_head].param_cb = NULL;
/*
* Expired timer queue head is updated to point to next timer in the
* expired timer queue
*/
expired_timer_queue_head = next_expired_timer;
if (NO_TIMER == expired_timer_queue_head)
{
expired_timer_queue_tail = NO_TIMER;
}
/*Restoring the interrupt status which was stored & enabling the global interrupt */
LEAVE_CRITICAL_REGION();
if (NULL != callback)
{
/*Callback function is called */
callback(callback_param);
}
}
}
开发者ID:ganeshkumarsw,项目名称:wireshark_cap,代码行数:66,代码来源:pal_timer.c
示例3: mcu_clock_init
/**
* @brief Initialize the system clock
*
* This function sets the system clock by enabling the internal RC oscillator
* with the proper prescaler (if available).
* Ensure that CKDIV8 fuse does not affect the system clock prescaler.
*
*/
static void mcu_clock_init(void)
{
/*
* This is only allowed if the AVR 8-bit MCU already has a clock prescaler.
* For older devices this function does not make sense.
* Therefore the existence of register CLKPR is checked.
*/
//#ifdef CLKPR /* Is clock prescaler existing? */
#if (F_CPU == (8000000UL))
#ifdef __ICCAVR__
ENTER_CRITICAL_REGION();
CLKPR = 0x80;
CLKPR = 0x00;
LEAVE_CRITICAL_REGION();
#else
clock_prescale_set(clock_div_1);
#endif /* __ICCAVR__ */
#endif /* (F_CPU == (8000000UL) */
#if (F_CPU == (4000000UL))
#ifdef __ICCAVR__
ENTER_CRITICAL_REGION();
CLKPR = 0x80;
CLKPR = 0x01;
LEAVE_CRITICAL_REGION();
#else
clock_prescale_set(clock_div_2);
#endif /* __ICCAVR__ */
#endif /* (F_CPU == (4000000UL) */
#if (F_CPU == (2000000UL))
#ifdef __ICCAVR__
ENTER_CRITICAL_REGION();
CLKPR = 0x80;
CLKPR = 0x02;
LEAVE_CRITICAL_REGION();
#else
clock_prescale_set(clock_div_4);
#endif /* __ICCAVR__ */
#endif /* (F_CPU == (2000000UL) */
#if (F_CPU == (1000000UL))
#ifdef __ICCAVR__
ENTER_CRITICAL_REGION();
CLKPR = 0x80;
CLKPR = 0x03;
LEAVE_CRITICAL_REGION();
#else
clock_prescale_set(clock_div_8);
#endif /* __ICCAVR__ */
#endif /* (F_CPU == (1000000UL) */
//#endif /* CLKPR */
}
开发者ID:Blone,项目名称:my-project-hihack,代码行数:63,代码来源:pal.c
示例4: if
ADI_ETHER_BUFFER *EtherRecv ( ADI_ETHER_HANDLE const hDevice )
{
ADI_ETHER_BUFFER *pack = NULL;
int nSelectedDev = 0;
if ( hDevice == g_hDev[0] )
{
nSelectedDev = 0;
}
else if( hDevice == g_hDev[1] )
{
nSelectedDev = 1;
}
else
{
DEBUG_STATEMENT ( " EtherRecv: Can not find the hDev \n\n" );
return NULL;
}
//一次返回一个
ENTER_CRITICAL_REGION();
DeQueue ( &user_net_config_info[nSelectedDev].rx_completed_q, ( QElem * ) &pack ) ;
EXIT_CRITICAL_REGION();
return pack;
}
开发者ID:wjm1262,项目名称:BF609_EMAC_TEST,代码行数:29,代码来源:BF609_EMAC_Test_Core0.c
示例5: pal_stop_high_priority_timer
/**
* @brief Stops a high priority timer
*
* This function stops a high priority timer.
*
* @param timer_id Timer identifier
*
* @return
* - @ref PAL_TMR_NOT_RUNNING if the timer id does not match with the high priority
* timer register, or
* - @ref MAC_SUCCESS otherwise.
*/
retval_t pal_stop_high_priority_timer(uint8_t timer_id)
{
retval_t timer_stop_status = PAL_TMR_NOT_RUNNING;
/*Saving the current interrupt status & disabling the global interrupt */
ENTER_CRITICAL_REGION();
if (timer_id == high_priority_timer_id)
{
/* Turn off timer2/channel1 Outpur compare interrupt */
HIGH_PRIORITY_TIMER_DISABLE_INT = DISABLE_ALL_TIMER_INTERRUPTS;
/*Clear pending output compare matches */
HIGH_PRIORITY_TIMER_ENABLE_INT &= ~AVR32_TC_IER0_CPAS_MASK;
timer_array[high_priority_timer_id].next_timer_in_queue = NO_TIMER;
timer_array[high_priority_timer_id].timer_cb = NULL;
high_priority_timer_id = NO_TIMER;
timer_stop_status = MAC_SUCCESS;
}
/*Restoring the interrupt status which was stored & enabling the global interrupt */
LEAVE_CRITICAL_REGION();
return timer_stop_status;
}
开发者ID:ganeshkumarsw,项目名称:wireshark_cap,代码行数:38,代码来源:pal_timer.c
示例6: rf230_frame_write_P
void rf230_frame_write_P(uint8_t length, PROGMEM_BYTE_ARRAY_T wr_buffer) {
ENTER_CRITICAL_REGION();
RF230_SS_LOW();
/*SEND FRAME WRITE COMMAND AND FRAME LENGTH.*/
RF230_SPI_DATA_REG = RF230_TRX_CMD_FW;
RF230_WAIT_FOR_SPI_TX_COMPLETE();
uint8_t dummy_read = RF230_SPI_DATA_REG;
RF230_SPI_DATA_REG = length;
RF230_WAIT_FOR_SPI_TX_COMPLETE();
dummy_read = RF230_SPI_DATA_REG;
/*Download to the Frame Buffer. */
do {
RF230_SPI_DATA_REG = PROGMEM_READ_BYTE(wr_buffer);
wr_buffer++;
--length;
RF230_WAIT_FOR_SPI_TX_COMPLETE();
dummy_read = RF230_SPI_DATA_REG;
} while (length != 0);
RF230_SS_HIGH();
LEAVE_CRITICAL_REGION();
}
开发者ID:BastilleResearch,项目名称:killerbee,代码行数:30,代码来源:rf230_avr.c
示例7: rf230_register_read
uint8_t rf230_register_read(uint8_t address) {
/*Add the register read command to the register address. */
address |= RF230_TRX_CMD_RR;
ENTER_CRITICAL_REGION();
RF230_SS_LOW();
/*Send Register address and read register content.*/
RF230_SPI_DATA_REG = address;
RF230_WAIT_FOR_SPI_TX_COMPLETE();
address = RF230_SPI_DATA_REG;
uint8_t register_value = 0;
RF230_SPI_DATA_REG = register_value;
RF230_WAIT_FOR_SPI_TX_COMPLETE();
register_value = RF230_SPI_DATA_REG;
RF230_SS_HIGH();
LEAVE_CRITICAL_REGION();
return register_value;
}
开发者ID:BastilleResearch,项目名称:killerbee,代码行数:25,代码来源:rf230_avr.c
示例8: zigbee_init
bool zigbee_init(uint64_t ieee_address) {
/* Set local variables to initial value. */
ENTER_CRITICAL_REGION();
bool init_status = false;
ndi = NULL;
nji = NULL;
nli = NULL;
LEAVE_CRITICAL_REGION();
/* Reset internal variables. */
zigbee_nib_init();
zigbee_neighbor_table_init();
if(true != ieee802_15_4_init(ieee_address)) {
} else {
/* Initialize all necessary callbacks from the IEEE 802.15.4 MAC. */
ieee802_15_4_set_mcps_data_indication(mac_data_indication_callback);
ieee802_15_4_set_mlme_associate_indication(mac_associate_indication_callback);
ieee802_15_4_set_mlme_disassociate_indication(mac_disassociate_indication_callback);
ieee802_15_4_set_mlme_orphan_indication(mac_orphan_indication_callback);
ieee802_15_4_set_mlme_comm_status_indication(mac_comm_status_indication_callback);
ZIGBEE_NWK_SET_STATE(NWK_IDLE);
init_status = true;
} // END: if(ieee802_15_4_init(ieee_address)) ...
return init_status;
}
开发者ID:BastilleResearch,项目名称:killerbee,代码行数:29,代码来源:zigbee.c
示例9: pal_trx_reg_read
/**
* @brief Reads current value from a transceiver register
*
* This function reads the current value from a transceiver register.
*
* @param addr Specifies the address of the trx register from which
* the data shall be read
*
* @return Value of the register read
*/
uint8_t pal_trx_reg_read(uint8_t addr)
{
uint8_t register_value;
ENTER_CRITICAL_REGION();
/* Prepare the command byte */
addr |= READ_ACCESS_COMMAND;
/* Start SPI transaction by pulling SEL low */
SS_LOW();
/* Send the write command byte */
SPI_WRITE(addr);
/*
* Done to clear the RDRF bit in the SPI status register, which will be set
* as a result of reception of some data from the transceiver as a result
* of SPI write operation done above.
*/
SPI_READ(register_value);
/* Do dummy write for initiating SPI read */
SPI_WRITE(SPI_DUMMY_VALUE);
/* Read the byte received */
SPI_READ(register_value);
/* Stop the SPI transaction by setting SEL high */
SS_HIGH();
LEAVE_CRITICAL_REGION();
return register_value;
}
开发者ID:nandojve,项目名称:embedded,代码行数:43,代码来源:pal_trx_access.c
示例10: cleanup_tal
/**
* @brief Cleanup TAL
*
* @param trx_id Transceiver identifier
*/
static void cleanup_tal(trx_id_t trx_id)
{
/* Clear all running TAL timers. */
ENTER_CRITICAL_REGION();
stop_tal_timer(trx_id);
LEAVE_CRITICAL_REGION();
/* Clear TAL Incoming Frame queue and free used buffers. */
while (tal_incoming_frame_queue[trx_id].size > 0) {
buffer_t *frame
= qmm_queue_remove(
&tal_incoming_frame_queue[trx_id], NULL);
if (NULL != frame) {
bmm_buffer_free(frame);
}
}
/* Get new TAL Rx buffer if necessary */
if (tal_rx_buffer[trx_id] == NULL) {
tal_rx_buffer[trx_id] = bmm_buffer_alloc(LARGE_BUFFER_SIZE);
}
/* Handle buffer shortage */
if (tal_rx_buffer[trx_id] == NULL) {
tal_buf_shortage[trx_id] = true;
} else {
tal_buf_shortage[trx_id] = false;
}
}
开发者ID:thegeek82000,项目名称:asf,代码行数:33,代码来源:tal_init.c
示例11: mbox_init
/*========================= IMPLEMENTATION =========================*/
int mbox_init(void)
{
// Init error flag
bool init_error = false;
// If allready initialized, deinitialize first
if (mbox_initalized == true) {
mbox_deinit();
}
// Init mail box buffer pointer
mbox_mail_buffer = NULL;
// mbox_mail_numb_get() and mbox_mail_numb_create() needs interrupts enabled
ENTER_CRITICAL_REGION();
sei();
// If "name number file" does not exist, create it
if (mbox_mail_numb_get() == EOF) {
if (mbox_mail_numb_create() == EOF) {
init_error = true;
}
}
// Restore interrupt state
LEAVE_CRITICAL_REGION();
// Indicate successful initialization
mbox_initalized = init_error ? false : true;
// Return EOF on error
return init_error ? EOF : 0;
}
开发者ID:BastilleResearch,项目名称:killerbee,代码行数:34,代码来源:mbox.c
示例12: tq_post
// Posts the given function pointer and data on the queue.
// Returns 0 on success, returns -1 if there is no space
// left in the queue.
int tq_post(void (*funct)(void* ), void* data) {
int usage;
int ret_val = 0;
int next_head;
ENTER_CRITICAL_REGION();
next_head = tq_head + 1;
if (next_head >= TASK_QUEUE_SIZE)
next_head -= TASK_QUEUE_SIZE;
if (next_head != tq_tail) {
task_queue_buf[tq_head].funct = funct;
task_queue_buf[tq_head].data = data;
} else {
ret_val = -1;
}
tq_head = next_head;
//record max usage
usage = buf_get_used(tq_head, tq_tail, TASK_QUEUE_SIZE);
if (usage > max_task_queue_size) max_task_queue_size = usage;
LEAVE_CRITICAL_REGION();
return ret_val;
}
开发者ID:c1728p9,项目名称:FreedomBoard,代码行数:31,代码来源:utilities.c
示例13: usb0_rx_complete_handler
/*
* This function is called when the USB transfer from the host to the
* device is finished
*/
static void usb0_rx_complete_handler( unsigned int unused,
unsigned char status,
unsigned int received,
unsigned int remaining)
{
uint8_t tail = usb_0_buffer.rx_buf_tail;
uint8_t i = 0;
ENTER_CRITICAL_REGION();
while (received--)
{
/* Count of bytes received through USB 0 channel is incremented. */
usb_0_buffer.rx_count++;
usb_0_buffer.rx_buf[tail] = usb_0_rx_temp_buf[i];
i++;
if ((USB_RX_BUF_MAX_SIZE - 1) == usb_0_buffer.rx_buf_tail)
{
/* Revert back to beginning of buffer after reaching end of buffer. */
usb_0_buffer.rx_buf_tail = 0;
tail = 0;
}
else
{
usb_0_buffer.rx_buf_tail++;
tail++;
}
}
LEAVE_CRITICAL_REGION();
}
开发者ID:mknapik,项目名称:avr-MAC,代码行数:33,代码来源:pal_usb.c
示例14: chip_init
/*============================ IMPLEMENTATION ================================*/
void chip_init(void)
{
/*
* Disable all modules except the 32-bit RTC to minimise power
* consumption
*/
PR.PRGEN = PR_AES_bm | PR_EBI_bm | PR_EVSYS_bm | PR_DMA_bm;
PR.PRPA = PR_ADC_bm | PR_AC_bm;
PR.PRPB = PR_DAC_bm | PR_ADC_bm | PR_AC_bm;
PR.PRPC = PR_TWI_bm | PR_USART0_bm | PR_USART1_bm | PR_SPI_bm
| PR_HIRES_bm | PR_TC0_bm | PR_TC1_bm;
PR.PRPD = PR_USART0_bm | PR_USART1_bm | PR_SPI_bm | PR_HIRES_bm
| PR_TC0_bm | PR_TC1_bm;
PR.PRPE = PR_TWI_bm | PR_USART0_bm | PR_HIRES_bm | PR_TC0_bm | PR_TC1_bm;
PR.PRPF = PR_USART0_bm | PR_HIRES_bm | PR_TC0_bm;
PORTA.DIR = 0x02;
PORTA.OUTCLR = 0x02;
/* Configure system clock to use 32 MHz internal RC oscillator */
OSC.CTRL |= OSC_RC32MEN_bm;
ENTER_CRITICAL_REGION( );
CCP = 0xD8;
CLK.PSCTRL = (uint8_t)CLK_PSADIV_1_gc | (uint8_t)CLK_PSBCDIV_1_1_gc;
while ( (OSC.STATUS & OSC_RC32MRDY_bm) == 0 );
CCP = 0xD8;
CLK.CTRL = CLK_SCLKSEL_RC32M_gc;
LEAVE_CRITICAL_REGION();
/* Configure the interrupt system */
PMIC.CTRL |= PMIC_LOLVLEN_bm;
}
开发者ID:LaneTee,项目名称:xmega-intro,代码行数:34,代码来源:rtc32_example1.c
示例15: hal_frame_write
/** \brief This function will download a frame to the radio transceiver's frame
* buffer.
*
* \param write_buffer Pointer to data that is to be written to frame buffer.
* \param length Length of data. The maximum length is 127 bytes.
*/
void
hal_frame_write( uint8_t *write_buffer, uint8_t length )
{
uint8_t tmp;
ENTER_CRITICAL_REGION();
/* Start SPI transaction by pulling SEL low */
hal_set_ss_low();
/* Download to the Frame Buffer.
* When the FCS is autogenerated there is no need to transfer the last two bytes
* since they will be overwritten.
*/
#if !RF231_CONF_CHECKSUM
length -= 2;
#endif
/* Send the command byte */
spi_readwrite(RF_SPI,HAL_TRX_CMD_FW);
/* Length */
spi_readwrite(RF_SPI,length);
do {
tmp = *write_buffer++;
spi_readwrite(RF_SPI, tmp);
--length;
} while (length > 0);
/* Stop the SPI transaction by setting SEL high. */
hal_set_ss_high();
LEAVE_CRITICAL_REGION();
}
开发者ID:zachary0101,项目名称:6lbr,代码行数:34,代码来源:rf231hal.c
示例16: hal_frame_read
/** \brief This function will upload a frame from the radio transceiver's frame
* buffer.
*
* If the frame currently available in the radio transceiver's frame buffer
* is out of the defined bounds. Then the frame length, lqi value and crc
* be set to zero. This is done to indicate an error.
* This version is optimized for use with contiki RF230BB driver.
* The callback routine and CRC are left out for speed in reading the rx buffer.
* Any delays here can lead to overwrites by the next packet!
*
* \param rx_frame Pointer to the data structure where the frame is stored.
* \param rx_callback Pointer to callback function for receiving one byte at a time.
*/
void
hal_frame_read( hal_rx_frame_t *rx_frame)
{
uint8_t dummy_rx_data;
uint8_t phy_status;
uint8_t frame_length;
uint8_t *rx_data;
ENTER_CRITICAL_REGION();
/* Start SPI transaction by pulling SEL low */
hal_set_ss_low();
/* Send the command byte */
phy_status = spi_readwrite(RF_SPI,HAL_TRX_CMD_FR);
frame_length = spi_readwrite(RF_SPI,0);
/*Check for correct frame length.*/
if ((frame_length >= HAL_MIN_FRAME_LENGTH) &&
(frame_length <= HAL_MAX_FRAME_LENGTH)){
rx_data = rx_frame->data;
rx_frame->length = frame_length;
do {
*rx_data++ = spi_readwrite(RF_SPI,0);
} while (--frame_length > 0);
rx_frame->lqi = spi_readwrite(RF_SPI,0);
rx_frame->crc = 1;
} else {
rx_frame->length = 0;
rx_frame->lqi = 0;
rx_frame->crc = 0;
}
/* Stop the SPI transaction by setting SEL high. */
hal_set_ss_high();
LEAVE_CRITICAL_REGION();
}
开发者ID:zachary0101,项目名称:6lbr,代码行数:47,代码来源:rf231hal.c
示例17: pal_start_high_priority_timer
/**
* @brief Starts high priority timer
*
* This function starts a high priority timer for the specified timeout.
*
* @param timer_id Timer identifier
* @param timer_count Timeout in microseconds
* @param timer_cb Callback handler invoked upon timer expiry
* @param param_cb Argument for the callback handler
*
* @return
* - @ref PAL_TMR_INVALID_ID if the identifier is undefined,
* - @ref MAC_INVALID_PARAMETER if the callback function for this timer is NULL,
* - @ref PAL_TMR_ALREADY_RUNNING if the timer is already running, or
* - @ref MAC_SUCCESS if timer is started successfully.
*/
retval_t pal_start_high_priority_timer(uint8_t timer_id,
uint16_t timer_count,
FUNC_PTR timer_cb,
void *param_cb)
{
uint32_t timer_ocr = INTIALIZE_TO_ZERO;
if (TOTAL_NUMBER_OF_TIMERS <= timer_id)
{
return PAL_TMR_INVALID_ID;
}
if (NULL == timer_cb)
{
return MAC_INVALID_PARAMETER;
}
if (NULL != timer_array[timer_id].timer_cb)
{
/*
* Irrespective of the type, the timer is already running if the
* callback function of the corresponding timer index in the timer
* array is not NULL.
*/
return PAL_TMR_ALREADY_RUNNING;
}
/*
* A high priority timer can be started, as currently
* there is no high priority timer running.
*/
{
/*Saving the current interrupt status & disabling the global interrupt */
ENTER_CRITICAL_REGION();
high_priority_timer_id = timer_id;
/*
* The corresponding running timer queue's timer index is updated
* with the new values.
*/
timer_array[timer_id].timer_cb = timer_cb;
timer_array[timer_id].param_cb = param_cb;
timer_array[timer_id].next_timer_in_queue = NO_TIMER;
timer_ocr = timer_count;
timer_array[timer_id].abs_exp_timer = timer_ocr;
/* Program output compare match */
HIGH_PRIORITY_TIMER_COMP = timer_ocr;
/*Clear pending output compare matches */
HIGH_PRIORITY_TIMER_DISABLE_INT = DISABLE_ALL_TIMER_INTERRUPTS;
/* Enable output compare match interrupt */
HIGH_PRIORITY_TIMER_ENABLE_INT |= AVR32_TC_IER0_CPAS_MASK;
/*Restoring the interrupt status which was stored & enabling the global interrupt */
LEAVE_CRITICAL_REGION();
}
return MAC_SUCCESS;
}
开发者ID:ganeshkumarsw,项目名称:wireshark_cap,代码行数:75,代码来源:pal_timer.c
示例18: pal_trx_aes_wrrd
/**
* @brief Writes and reads data into/from SRAM of the transceiver
*
* This function writes data into the SRAM of the transceiver and
* simultaneously reads the bytes.
*
* @param addr Start address in the SRAM for the write operation
* @param idata Pointer to the data written/read into/from SRAM
* @param length Number of bytes written/read into/from SRAM
*/
void pal_trx_aes_wrrd(uint8_t addr, uint8_t *idata, uint8_t length)
{
uint8_t dummy_rx_data;
uint8_t *odata;
PAL_WAIT_500_NS();
ENTER_CRITICAL_REGION();
/* Start SPI transaction by pulling SEL low */
SS_LOW();
/* Send the command byte */
SPI_WRITE(TRX_CMD_SW);
/*
* Done to clear the RDRF bit in the SPI status register, which will be set
* as a result of reception of some data from the transceiver as a result
* of SPI write operation done above.
*/
SPI_READ(dummy_rx_data);
/* Write SRAM start address, clear the RDRF bit */
SPI_WRITE(addr);
SPI_READ(dummy_rx_data);
/* Now transfer data */
odata = idata;
/* Write data byte 0 - the obtained value in SPDR is meaningless */
SPI_WRITE(*idata++);
SPI_READ(dummy_rx_data);
/*
* Done to avoid compiler warning about variable being not used after
* setting.
*/
dummy_rx_data = dummy_rx_data;
/* Process data bytes 1...length-1: write and read */
do
{
SPI_WRITE(*idata++);
/* Upload the received byte in the user provided location */
SPI_READ(*odata++);
}
while (--length > 0);
/* To get the last data byte, write some dummy byte */
SPI_WRITE(SPI_DUMMY_VALUE);
SPI_READ(*odata);
/* Stop the SPI transaction by setting SEL high */
SS_HIGH();
LEAVE_CRITICAL_REGION();
}
开发者ID:nandojve,项目名称:embedded,代码行数:69,代码来源:pal_trx_access.c
示例19: qmm_queue_append
void qmm_queue_append(queue_t *q, buffer_t *buf)
#endif /* ENABLE_QUEUE_CAPACITY */
{
#ifdef ENABLE_QUEUE_CAPACITY
retval_t status;
#endif /* ENABLE_QUEUE_CAPACITY */
ENTER_CRITICAL_REGION();
#ifdef ENABLE_QUEUE_CAPACITY
/* Check if queue is full */
if (q->size == q->capacity)
{
/* Buffer cannot be appended as queue is full */
status = QUEUE_FULL;
}
else
#endif /* ENABLE_QUEUE_CAPACITY */
{
/* Check whether queue is empty */
if (q->size == 0)
{
/* Add the buffer at the head */
q->head = buf;
}
else
{
/* Add the buffer at the end */
q->tail->next = buf;
}
/* Update the list */
q->tail = buf;
/* Terminate the list */
buf->next = NULL;
/* Update size */
q->size++;
#if (DEBUG > 1)
if (q->head == NULL)
{
ASSERT("Corrupted queue: Null pointer has been queued" == 0);
}
#endif
#ifdef ENABLE_QUEUE_CAPACITY
status = MAC_SUCCESS;
#endif /* ENABLE_QUEUE_CAPACITY */
}
LEAVE_CRITICAL_REGION();
#ifdef ENABLE_QUEUE_CAPACITY
return (status);
#endif
}/* qmm_queue_append */
开发者ID:johncobb,项目名称:xmega_macless_rtb_demo,代码行数:58,代码来源:qmm.c
示例20: rf230_get_callback_handler
rf230_cb_handler_t rf230_get_callback_handler(void) {
rf230_cb_handler_t handler = NULL;
ENTER_CRITICAL_REGION();
handler = rf230_callback_handler;
LEAVE_CRITICAL_REGION();
return handler;
}
开发者ID:BastilleResearch,项目名称:killerbee,代码行数:9,代码来源:rf230_avr.c
注:本文中的ENTER_CRITICAL_REGION函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论