当前位置: 首页>>代码示例>>C++>>正文


C++ ENTER_CRITICAL_REGION函数代码示例

本文整理汇总了C++中ENTER_CRITICAL_REGION函数的典型用法代码示例。如果您正苦于以下问题:C++ ENTER_CRITICAL_REGION函数的具体用法?C++ ENTER_CRITICAL_REGION怎么用?C++ ENTER_CRITICAL_REGION使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ENTER_CRITICAL_REGION函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的ENTER_CRITICAL_REGION函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。