本文整理汇总了C++中CRITICAL_REGION_EXIT函数的典型用法代码示例。如果您正苦于以下问题:C++ CRITICAL_REGION_EXIT函数的具体用法?C++ CRITICAL_REGION_EXIT怎么用?C++ CRITICAL_REGION_EXIT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CRITICAL_REGION_EXIT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: nrf_drv_clock_hfclk_request
void nrf_drv_clock_hfclk_request(nrf_drv_clock_handler_item_t * p_handler_item)
{
ASSERT(m_clock_cb.module_initialized);
if (m_clock_cb.hfclk_on)
{
if (p_handler_item)
{
p_handler_item->event_handler(NRF_DRV_CLOCK_EVT_HFCLK_STARTED);
}
CRITICAL_REGION_ENTER();
++(m_clock_cb.hfclk_requests);
CRITICAL_REGION_EXIT();
}
else
{
CRITICAL_REGION_ENTER();
if (p_handler_item)
{
item_enqueue((nrf_drv_clock_handler_item_t **)&m_clock_cb.p_hf_head,
p_handler_item);
}
if (m_clock_cb.hfclk_requests == 0)
{
hfclk_start();
}
++(m_clock_cb.hfclk_requests);
CRITICAL_REGION_EXIT();
}
ASSERT(m_clock_cb.hfclk_requests > 0);
}
开发者ID:CWBudde,项目名称:Espruino,代码行数:32,代码来源:nrf_drv_clock.c
示例2: nrf_drv_ppi_channel_include_in_group
uint32_t nrf_drv_ppi_channel_include_in_group(nrf_ppi_channel_t channel,
nrf_ppi_channel_group_t group)
{
uint32_t err_code;
#if (NRF_PPI_RESTRICTED > 0)
uint32_t ch_mask;
#endif
if (!is_app_group(group))
{
err_code = NRF_ERROR_INVALID_PARAM;
}
else if (!is_allocated_group(group))
{
err_code = NRF_ERROR_INVALID_STATE;
}
else if (!is_app_channel(channel))
{
err_code = NRF_ERROR_INVALID_PARAM;
}
else
{
#if (NRF_PPI_RESTRICTED > 0)
CRITICAL_REGION_ENTER();
err_code = sd_ppi_group_get((uint8_t) group, &ch_mask);
if (err_code != NRF_SUCCESS)
{
err_code = NRF_ERROR_INVALID_PARAM;
}
else
{
ch_mask |= channel_to_mask(channel);
err_code = sd_ppi_group_assign((uint8_t) group, ch_mask);
if (err_code != NRF_SUCCESS)
{
err_code = NRF_ERROR_INVALID_PARAM;
}
}
CRITICAL_REGION_EXIT();
#else
CRITICAL_REGION_ENTER();
nrf_ppi_channel_include_in_group(channel, group);
CRITICAL_REGION_EXIT();
err_code = NRF_SUCCESS;
#endif
}
return err_code;
}
开发者ID:dhruvkakadiya,项目名称:OpenSJ_Bluz,代码行数:53,代码来源:nrf_drv_ppi.c
示例3: nrf_drv_ppi_channels_remove_from_group
uint32_t nrf_drv_ppi_channels_remove_from_group(uint32_t channel_mask,
nrf_ppi_channel_group_t group)
{
uint32_t err_code;
if (!is_app_group(group))
{
err_code = NRF_ERROR_INVALID_PARAM;
}
else if (!is_allocated_group(group))
{
err_code = NRF_ERROR_INVALID_STATE;
}
else if (!are_app_channels(channel_mask))
{
err_code = NRF_ERROR_INVALID_PARAM;
}
else
{
#if (NRF_PPI_RESTRICTED > 0)
uint32_t channels_in_group = 0;
CRITICAL_REGION_ENTER();
err_code = sd_ppi_group_get((uint8_t) group, &channels_in_group);
if (err_code != NRF_SUCCESS)
{
err_code = NRF_ERROR_INVALID_PARAM;
}
else
{
channels_in_group &= ~channel_mask;
err_code = sd_ppi_group_assign((uint8_t) group, channels_in_group);
if (err_code != NRF_SUCCESS)
{
err_code = NRF_ERROR_INVALID_PARAM;
}
}
CRITICAL_REGION_EXIT();
#else
CRITICAL_REGION_ENTER();
nrf_ppi_channels_remove_from_group(channel_mask, group);
CRITICAL_REGION_EXIT();
err_code = NRF_SUCCESS;
#endif
}
return err_code;
}
开发者ID:BlueSkyGjj,项目名称:nRF52,代码行数:51,代码来源:nrf_drv_ppi.c
示例4: nrf_drv_clock_calibration_abort
ret_code_t nrf_drv_clock_calibration_abort(void)
{
#if CALIBRATION_SUPPORT
CRITICAL_REGION_ENTER();
switch(m_clock_cb.cal_state)
{
case CAL_STATE_CT:
nrf_clock_int_disable(NRF_CLOCK_INT_CTTO_MASK);
nrf_clock_task_trigger(NRF_CLOCK_TASK_CTSTOP);
m_clock_cb.cal_state = CAL_STATE_IDLE;
if (m_clock_cb.cal_done_handler)
{
m_clock_cb.cal_done_handler(NRF_DRV_CLOCK_EVT_CAL_ABORTED);
}
break;
case CAL_STATE_HFCLK_REQ:
/* fall through. */
case CAL_STATE_CAL:
m_clock_cb.cal_state = CAL_STATE_ABORT;
break;
default:
break;
}
CRITICAL_REGION_EXIT();
return NRF_SUCCESS;
#else //CALIBRATION_SUPPORT
return NRF_ERROR_FORBIDDEN;
#endif
}
开发者ID:Hom-Wang,项目名称:NRF5x,代码行数:29,代码来源:nrf_drv_clock.c
示例5: nrf_drv_clock_lfclk_request
void nrf_drv_clock_lfclk_request(nrf_drv_clock_handler_item_t * p_handler_item)
{
ASSERT(m_clock_cb.module_initialized);
#ifndef SOFTDEVICE_PRESENT
ASSERT(m_clock_cb.lfclk_requests != INT_MAX);
CRITICAL_REGION_ENTER();
if (m_clock_cb.lfclk_on)
{
if (p_handler_item)
{
p_handler_item->event_handler(NRF_DRV_CLOCK_EVT_LFCLK_STARTED);
}
}
else
{
if (p_handler_item)
{
item_enqueue((nrf_drv_clock_handler_item_t **)&m_clock_cb.p_lf_head, p_handler_item);
}
if (m_clock_cb.lfclk_requests == 0)
{
lfclk_start();
}
}
m_clock_cb.lfclk_requests++;
CRITICAL_REGION_EXIT();
#else
if (p_handler_item)
{
p_handler_item->event_handler(NRF_DRV_CLOCK_EVT_LFCLK_STARTED);
}
#endif // SOFTDEVICE_PRESENT
}
开发者ID:Hom-Wang,项目名称:NRF5x,代码行数:34,代码来源:nrf_drv_clock.c
示例6: timer_stop_op_schedule
/**@brief Function for scheduling a Timer Stop operation.
*
* @param[in] timer_id Id of timer to stop.
* @param[in] op_type Type of stop operation
*
* @return NRF_SUCCESS on successful scheduling a timer stop operation. NRF_ERROR_NO_MEM when there
* is no memory left to schedule the timer stop operation.
*/
static uint32_t timer_stop_op_schedule(timer_node_t * p_node,
timer_user_op_type_t op_type)
{
uint8_t last_index;
uint32_t err_code = NRF_SUCCESS;
CRITICAL_REGION_ENTER();
timer_user_op_t * p_user_op = user_op_alloc(&last_index);
if (p_user_op == NULL)
{
err_code = NRF_ERROR_NO_MEM;
}
else
{
p_user_op->op_type = op_type;
p_user_op->p_node = p_node;
user_op_enque(last_index);
}
CRITICAL_REGION_EXIT();
if (err_code == NRF_SUCCESS)
{
timer_list_handler_sched();
}
return err_code;
}
开发者ID:CWBudde,项目名称:Espruino,代码行数:36,代码来源:app_timer_ble_gzll.c
示例7: timer_start_op_schedule
static uint32_t timer_start_op_schedule(timer_node_t * p_node,
uint32_t timeout_initial,
uint32_t timeout_periodic,
void * p_context)
{
uint8_t last_index;
uint32_t err_code = NRF_SUCCESS;
CRITICAL_REGION_ENTER();
timer_user_op_t * p_user_op = user_op_alloc(&last_index);
if (p_user_op == NULL)
{
err_code = NRF_ERROR_NO_MEM;
}
else
{
p_user_op->op_type = TIMER_USER_OP_TYPE_START;
p_user_op->p_node = p_node;
p_user_op->params.start.ticks_at_start = rtc1_counter_get();
p_user_op->params.start.ticks_first_interval = timeout_initial;
p_user_op->params.start.ticks_periodic_interval = timeout_periodic;
p_user_op->params.start.p_context = p_context;
user_op_enque(last_index);
}
CRITICAL_REGION_EXIT();
if (err_code == NRF_SUCCESS)
{
timer_list_handler_sched();
}
return err_code;
}
开发者ID:CWBudde,项目名称:Espruino,代码行数:35,代码来源:app_timer_ble_gzll.c
示例8: hid_kbd_on_set_report
/**
* @brief @ref app_usbd_hid_interface_t::hid_kbd_on_set_report
*/
static ret_code_t hid_kbd_on_set_report(app_usbd_class_inst_t const * p_inst,
app_usbd_setup_evt_t const * p_setup_ev)
{
app_usbd_hid_kbd_t const * p_kbd = hid_kbd_get(p_inst);
/*Request setup data*/
app_usbd_hid_report_buffer_t const * p_rep_buff;
p_rep_buff = app_usbd_hid_rep_buff_out_get(&p_kbd->specific.inst.hid_inst);
p_rep_buff->p_buff[0] = 0;
NRF_DRV_USBD_TRANSFER_OUT(transfer, p_rep_buff->p_buff + 1, p_rep_buff->size - 1);
ret_code_t ret;
CRITICAL_REGION_ENTER();
ret = app_usbd_core_setup_data_transfer(NRF_DRV_USBD_EPOUT0, &transfer);
if (ret == NRF_SUCCESS)
{
app_usbd_core_setup_data_handler_desc_t desc = {
.handler = hid_kbd_on_set_report_data_cb,
.p_context = (app_usbd_hid_kbd_t *)p_kbd
};
ret = app_usbd_core_setup_data_handler_set(NRF_DRV_USBD_EPOUT0, &desc);
}
CRITICAL_REGION_EXIT();
return ret;
}
开发者ID:TanekLiang,项目名称:rt-thread,代码行数:31,代码来源:app_usbd_hid_kbd.c
示例9: hid_kbd_transfer_set
/**
* @brief Triggers IN endpoint transfer.
*
* @param[in] p_kbd HID keyboard instance.
*
* @return Standard error code.
*/
static inline ret_code_t hid_kbd_transfer_set(app_usbd_hid_kbd_t const * p_kbd)
{
app_usbd_class_inst_t const * p_inst = (app_usbd_class_inst_t const *)p_kbd;
app_usbd_hid_kbd_ctx_t * p_kbd_ctx = hid_kbd_ctx_get(p_kbd);
nrf_drv_usbd_ep_t ep_addr = app_usbd_hid_epin_addr_get(p_inst);
app_usbd_hid_state_flag_clr(&p_kbd_ctx->hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS);
if (!hid_kbd_transfer_next(p_kbd))
{
/* Transfer buffer hasn't changed since last transfer. No need to setup
* next transfer.
* */
return NRF_SUCCESS;
}
app_usbd_hid_report_buffer_t const * p_rep_buffer = hid_kbd_rep_buffer_get(p_kbd);
NRF_DRV_USBD_TRANSFER_IN(transfer, p_rep_buffer->p_buff, p_rep_buffer->size);
ret_code_t ret;
CRITICAL_REGION_ENTER();
ret = app_usbd_core_ep_transfer(ep_addr, &transfer);
if (ret == NRF_SUCCESS)
{
app_usbd_hid_state_flag_set(&p_kbd_ctx->hid_ctx, APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS);
}
CRITICAL_REGION_EXIT();
return ret;
}
开发者ID:TanekLiang,项目名称:rt-thread,代码行数:38,代码来源:app_usbd_hid_kbd.c
示例10: nrf_drv_clock_calibration_abort
ret_code_t nrf_drv_clock_calibration_abort(void)
{
ret_code_t err_code = NRF_SUCCESS;
#if CALIBRATION_SUPPORT
CRITICAL_REGION_ENTER();
switch (m_clock_cb.cal_state)
{
case CAL_STATE_CT:
nrf_clock_int_disable(NRF_CLOCK_INT_CTTO_MASK);
nrf_clock_task_trigger(NRF_CLOCK_TASK_CTSTOP);
m_clock_cb.cal_state = CAL_STATE_IDLE;
if (m_clock_cb.cal_done_handler)
{
m_clock_cb.cal_done_handler(NRF_DRV_CLOCK_EVT_CAL_ABORTED);
}
break;
case CAL_STATE_HFCLK_REQ:
/* fall through. */
case CAL_STATE_CAL:
m_clock_cb.cal_state = CAL_STATE_ABORT;
break;
default:
break;
}
CRITICAL_REGION_EXIT();
NRF_LOG_INFO("Function: %s, error code: %s.\r\n", (uint32_t)__func__, (uint32_t)ERR_TO_STR(err_code));
return err_code;
#else
err_code = NRF_ERROR_FORBIDDEN;
NRF_LOG_WARNING("Function: %s, error code: %s.\r\n", (uint32_t)__func__, (uint32_t)ERR_TO_STR(err_code));
return err_code;
#endif // CALIBRATION_SUPPORT
}
开发者ID:CWBudde,项目名称:Espruino,代码行数:34,代码来源:nrf_drv_clock.c
示例11: ser_phy_tx_pkt_send
/* ser_phy API function */
uint32_t ser_phy_tx_pkt_send(const uint8_t * p_buffer, uint16_t num_of_bytes)
{
if (p_buffer == NULL)
{
return NRF_ERROR_NULL;
}
if (num_of_bytes == 0)
{
return NRF_ERROR_INVALID_PARAM;
}
if (mp_tx_buffer != NULL)
{
return NRF_ERROR_BUSY;
}
//ser_phy_interrupts_disable();
CRITICAL_REGION_ENTER();
mp_tx_buffer = (uint8_t *)p_buffer;
m_tx_buf_len = num_of_bytes;
m_pend_tx_api_flag = true;
SET_PendSV();
//ser_phy_interrupts_enable();
CRITICAL_REGION_EXIT();
return NRF_SUCCESS;
}
开发者ID:AveryLouie,项目名称:flashware,代码行数:29,代码来源:ser_phy_nrf51_spi_master.c
示例12: nrf_queue_in
size_t nrf_queue_in(nrf_queue_t const * p_queue,
void * p_data,
size_t element_count)
{
ASSERT(p_queue != NULL);
ASSERT(p_data != NULL);
if (element_count == 0)
{
return 0;
}
CRITICAL_REGION_ENTER();
if (p_queue->mode == NRF_QUEUE_MODE_OVERFLOW)
{
element_count = MIN(element_count, p_queue->size);
}
else
{
size_t available = nrf_queue_available_get(p_queue);
element_count = MIN(element_count, available);
}
queue_write(p_queue, p_data, element_count);
CRITICAL_REGION_EXIT();
return element_count;
}
开发者ID:CWBudde,项目名称:Espruino,代码行数:30,代码来源:nrf_queue.c
示例13: buf_prealloc
/**
* @brief Allocates chunk in a buffer for one entry and injects overflow if
* there is no room for requested entry.
*
* @param nargs Number of 32bit arguments. In case of allocating for hex dump it
* is the size of the buffer in 32bit words (ceiled).
* @param p_wr_idx Pointer to write index.
*
* @return True if successful allocation, false otherwise.
*
*/
static inline bool buf_prealloc(uint32_t nargs, uint32_t * p_wr_idx)
{
nargs += HEADER_SIZE;
uint32_t ovflw_tag_size = HEADER_SIZE;
bool ret = true;
CRITICAL_REGION_ENTER();
*p_wr_idx = m_log_data.wr_idx;
uint32_t available_words = (m_log_data.mask + 1) - (m_log_data.wr_idx - m_log_data.rd_idx);
uint32_t required_words = nargs + ovflw_tag_size; // room for current entry and overflow
if (required_words > available_words)
{
if (available_words >= HEADER_SIZE)
{
// Overflow entry is injected
STD_HEADER_DEF(header, m_overflow_info, NRF_LOG_LEVEL_INTERNAL, 0);
m_log_data.buffer[m_log_data.wr_idx++ & m_log_data.mask] =
header.raw;
#if NRF_LOG_USES_TIMESTAMP
m_log_data.buffer[m_log_data.wr_idx++ & m_log_data.mask] =
m_log_data.timestamp_func();
#endif //NRF_LOG_USES_TIMESTAMP
}
// overflow case
ret = false;
}
else
{
m_log_data.wr_idx += nargs;
}
CRITICAL_REGION_EXIT();
return ret;
}
开发者ID:CWBudde,项目名称:Espruino,代码行数:43,代码来源:nrf_log_frontend.c
示例14: nrf_drv_ppi_channel_alloc
uint32_t nrf_drv_ppi_channel_alloc(nrf_ppi_channel_t * p_channel)
{
uint32_t err_code = NRF_SUCCESS;
nrf_ppi_channel_t channel;
uint32_t mask = 0;
err_code = NRF_ERROR_NO_MEM;
mask = NRF_PPI_PROG_APP_CHANNELS_MASK;
for (channel = NRF_PPI_CHANNEL0; mask != 0; mask &= ~nrf_drv_ppi_channel_to_mask(channel), channel++)
{
CRITICAL_REGION_ENTER();
if ((mask & nrf_drv_ppi_channel_to_mask(channel)) && (!is_allocated_channel(channel)))
{
channel_allocated_set(channel);
*p_channel = channel;
err_code = NRF_SUCCESS;
}
CRITICAL_REGION_EXIT();
if (err_code == NRF_SUCCESS)
{
NRF_LOG_INFO("Allocated channel: %d.\r\n", channel);
break;
}
}
NRF_LOG_INFO("Function: %s, error code: %s.\r\n", (uint32_t)__func__, (uint32_t)ERR_TO_STR(err_code));
return err_code;
}
开发者ID:Archcady,项目名称:mbed-os,代码行数:29,代码来源:nrf_drv_ppi.c
示例15: nrf_drv_ppi_group_free
uint32_t nrf_drv_ppi_group_free(nrf_ppi_channel_group_t group)
{
uint32_t err_code;
if (!is_app_group(group))
{
err_code = NRF_ERROR_INVALID_PARAM;
}
else if (!is_allocated_group(group))
{
err_code = NRF_ERROR_INVALID_STATE;
}
else
{
#if (NRF_PPI_RESTRICTED > 0)
err_code = sd_ppi_group_task_disable((uint8_t) group);
#else
nrf_ppi_group_disable(group);
err_code = NRF_SUCCESS;
#endif
CRITICAL_REGION_ENTER();
group_allocated_clr(group);
CRITICAL_REGION_EXIT();
}
return err_code;
}
开发者ID:dhruvkakadiya,项目名称:OpenSJ_Bluz,代码行数:27,代码来源:nrf_drv_ppi.c
示例16: nrf_queue_write
ret_code_t nrf_queue_write(nrf_queue_t const * p_queue,
void const * p_data,
size_t element_count)
{
ret_code_t status = NRF_SUCCESS;
ASSERT(p_queue != NULL);
ASSERT(p_data != NULL);
ASSERT(element_count <= p_queue->size);
if (element_count == 0)
{
return NRF_SUCCESS;
}
CRITICAL_REGION_ENTER();
if ((nrf_queue_available_get(p_queue) >= element_count)
|| (p_queue->mode == NRF_QUEUE_MODE_OVERFLOW))
{
queue_write(p_queue, p_data, element_count);
}
else
{
status = NRF_ERROR_NO_MEM;
}
CRITICAL_REGION_EXIT();
return status;
}
开发者ID:CWBudde,项目名称:Espruino,代码行数:31,代码来源:nrf_queue.c
示例17: nrf_drv_ppi_group_alloc
uint32_t nrf_drv_ppi_group_alloc(nrf_ppi_channel_group_t * p_group)
{
uint32_t err_code;
uint32_t mask = 0;
nrf_ppi_channel_group_t group;
err_code = NRF_ERROR_NO_MEM;
mask = NRF_PPI_ALL_APP_GROUPS_MASK;
for (group = NRF_PPI_CHANNEL_GROUP0; mask != 0; mask &= ~group_to_mask(group), group++)
{
CRITICAL_REGION_ENTER();
if ((mask & group_to_mask(group)) && (!is_allocated_group(group)))
{
group_allocated_set(group);
*p_group = group;
err_code = NRF_SUCCESS;
}
CRITICAL_REGION_EXIT();
if (err_code == NRF_SUCCESS)
{
NRF_LOG_INFO("Allocated group: %d.\r\n", group);
break;
}
}
NRF_LOG_INFO("Function: %s, error code: %s.\r\n", (uint32_t)__func__, (uint32_t)ERR_TO_STR(err_code));
return err_code;
}
开发者ID:Archcady,项目名称:mbed-os,代码行数:29,代码来源:nrf_drv_ppi.c
示例18: nrf_queue_read
ret_code_t nrf_queue_read(nrf_queue_t const * p_queue,
void * p_data,
size_t element_count)
{
ret_code_t status = NRF_SUCCESS;
ASSERT(p_queue != NULL);
ASSERT(p_data != NULL);
if (element_count == 0)
{
return NRF_SUCCESS;
}
CRITICAL_REGION_ENTER();
if (element_count <= queue_utilization_get(p_queue))
{
queue_read(p_queue, p_data, element_count);
}
else
{
status = NRF_ERROR_NOT_FOUND;
}
CRITICAL_REGION_EXIT();
return status;
}
开发者ID:CWBudde,项目名称:Espruino,代码行数:29,代码来源:nrf_queue.c
示例19: nrf_drv_ppi_channels_include_in_group
uint32_t nrf_drv_ppi_channels_include_in_group(uint32_t channel_mask,
nrf_ppi_channel_group_t group)
{
ret_code_t err_code = NRF_SUCCESS;
if (!is_app_group(group))
{
err_code = NRF_ERROR_INVALID_PARAM;
}
else if (!is_allocated_group(group))
{
err_code = NRF_ERROR_INVALID_STATE;
}
else if (!are_app_channels(channel_mask))
{
err_code = NRF_ERROR_INVALID_PARAM;
}
else
{
CRITICAL_REGION_ENTER();
nrf_ppi_channels_include_in_group(channel_mask, group);
CRITICAL_REGION_EXIT();
}
NRF_LOG_INFO("Function: %s, error code: %s.\r\n", (uint32_t)__func__, (uint32_t)ERR_TO_STR(err_code));
return err_code;
}
开发者ID:Archcady,项目名称:mbed-os,代码行数:26,代码来源:nrf_drv_ppi.c
示例20: nrf_drv_ppi_group_alloc
uint32_t nrf_drv_ppi_group_alloc(nrf_ppi_channel_group_t * p_group)
{
uint32_t err_code;
uint32_t mask = 0;
nrf_ppi_channel_group_t group;
err_code = NRF_ERROR_NO_MEM;
mask = NRF_PPI_ALL_APP_GROUPS_MASK;
for (group = NRF_PPI_CHANNEL_GROUP0; mask != 0; mask &= ~group_to_mask(group), group++)
{
CRITICAL_REGION_ENTER();
if ((mask & group_to_mask(group)) && (!is_allocated_group(group)))
{
group_allocated_set(group);
*p_group = group;
err_code = NRF_SUCCESS;
}
CRITICAL_REGION_EXIT();
if (err_code == NRF_SUCCESS)
{
break;
}
}
return err_code;
}
开发者ID:BLEHexapod,项目名称:nrf_sdk,代码行数:27,代码来源:nrf_drv_ppi.c
注:本文中的CRITICAL_REGION_EXIT函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论