本文整理汇总了C++中enter_state函数的典型用法代码示例。如果您正苦于以下问题:C++ enter_state函数的具体用法?C++ enter_state怎么用?C++ enter_state使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了enter_state函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process
static void process(void)
{
int val;
switch(touch_state)
{
case TOUCH_STATE_WAIT:
/* a touch has happened, check if it's still valid */
if(imx233_lradc_read_touch_detect())
enter_state(TOUCH_STATE_MEASURE_X);
else
{
old_touch_detect = false;
/* clear detect interrupt */
imx233_lradc_clear_touch_detect_irq();
}
break;
case TOUCH_STATE_MEASURE_X:
/* read value */
val = imx233_lradc_read_channel(touch_chan);
/* if value is too far from average, restart */
if(nr_samples > 0 && abs(val - touch_x) > DEBOUNCE_THRESHOLD)
nr_samples = 0;
touch_x = (touch_x * nr_samples + val) / (nr_samples + 1);
nr_samples++;
/* if we have enough samples, measure Y */
if(nr_samples > SAMPLES_THRESHOLD)
enter_state(TOUCH_STATE_MEASURE_Y);
else
imx233_lradc_kick_delay(touch_delay);
break;
case TOUCH_STATE_MEASURE_Y:
/* read value */
val = imx233_lradc_read_channel(touch_chan);
/* if value is too far from average, restart */
if(nr_samples > 0 && abs(val - touch_y) > DEBOUNCE_THRESHOLD)
nr_samples = 0;
touch_y = (touch_y * nr_samples + val) / (nr_samples + 1);
nr_samples++;
/* if we have enough samples, verify touch */
if(nr_samples > SAMPLES_THRESHOLD)
enter_state(TOUCH_STATE_VERIFY);
else
imx233_lradc_kick_delay(touch_delay);
break;
case TOUCH_STATE_VERIFY:
if(imx233_lradc_read_touch_detect())
{
old_touch_detect = true;
old_touch_x = touch_x;
old_touch_y = touch_y;
enter_state(TOUCH_STATE_MEASURE_X);
}
else
{
old_touch_detect = false;
enter_state(TOUCH_STATE_WAIT);
}
break;
}
}
示例2: state_store
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t n)
{
#ifdef CONFIG_SUSPEND
#ifdef CONFIG_EARLYSUSPEND
suspend_state_t state = PM_SUSPEND_ON;
#else
suspend_state_t state = PM_SUSPEND_STANDBY;
#endif
const char * const *s;
#endif
char *p;
int len;
int error = -EINVAL;
p = memchr(buf, '\n', n);
len = p ? p - buf : n;
/* First, check if we are requested to hibernate */
if (len == 4 && !strncmp(buf, "disk", len)) {
error = hibernate();
goto Exit;
}
#if defined(CONFIG_MP_MSTAR_STR_BASE)
// for mstar str, we skip wakelock
// and earlysuspend/lateresume to speedup suspend
if (len == 4 && !strncmp(buf, "mstr", len)) {
state = PM_SUSPEND_MEM;
pm_is_mstar_str = 1;
error = enter_state(state);
pm_is_mstar_str = 0;
goto Exit;
}
#endif
#ifdef CONFIG_SUSPEND
for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {
if (*s && len == strlen(*s) && !strncmp(buf, *s, len))
break;
}
if (state < PM_SUSPEND_MAX && *s)
#ifdef CONFIG_EARLYSUSPEND
if (state == PM_SUSPEND_ON || valid_state(state)) {
error = 0;
request_suspend_state(state);
}
#else
error = enter_state(state);
#endif
#endif
Exit:
return error ? error : n;
}
示例3: path
static void path(parser_context *context)
{
enter_state(context, ST_START);
skip_ws(context);
absolute_path(context);
if(ERR_UNEXPECTED_VALUE == context->result.code && '$' == context->result.expected_char)
{
enter_state(context, ST_START);
context->current_step_kind = SINGLE;
relative_path(context);
}
}
示例4: imx233_touchscreen_enable
void imx233_touchscreen_enable(bool enable)
{
enter_state(TOUCH_STATE_WAIT);
imx233_lradc_set_channel_irq_callback(touch_chan, &touch_channel_irq);
imx233_icoll_enable_interrupt(INT_SRC_LRADC_CHx(touch_chan), enable);
imx233_icoll_enable_interrupt(INT_SRC_TOUCH_DETECT, enable);
}
示例5: step_predicate_parser
static void step_predicate_parser(parser_context *context)
{
enter_state(context, ST_PREDICATE);
skip_ws(context);
if('[' == get_char(context))
{
consume_char(context);
if(!look_for(context, "]"))
{
context->result.code = ERR_UNBALANCED_PRED_DELIM;
return;
}
skip_ws(context);
if(']' == get_char(context))
{
context->result.code = ERR_EMPTY_PREDICATE;
return;
}
try_predicate_parser(wildcard_predicate);
try_predicate_parser(subscript_predicate);
try_predicate_parser(slice_predicate);
if(JSONPATH_SUCCESS != context->result.code && ERR_PARSER_OUT_OF_MEMORY != context->result.code)
{
context->result.code = ERR_UNSUPPORTED_PRED_TYPE;
}
}
else
{
unexpected_value(context, '[');
}
}
示例6: pm_suspend
/**
* pm_suspend - Externally visible function for suspending the system.
* @state: System sleep state to enter.
*
* Check if the value of @state represents one of the supported states,
* execute enter_state() and update system suspend statistics.
*/
int pm_suspend(suspend_state_t state)
{
int error;
int s3_state = mid_state_to_sys_state(MID_S3_STATE);
if (state <= PM_SUSPEND_ON || state >= PM_SUSPEND_MAX)
return -EINVAL;
/* time stamp for start of s3 entry */
if (state == PM_SUSPEND_MEM)
time_stamp_for_sleep_state_latency(s3_state, true, true);
pm_suspend_marker("entry");
error = enter_state(state);
if (error) {
suspend_stats.fail++;
dpm_save_failed_errno(error);
} else {
suspend_stats.success++;
/* time stamp for end of s3 exit */
if (state == PM_SUSPEND_MEM)
time_stamp_for_sleep_state_latency(s3_state,
false, false);
}
pm_suspend_marker("exit");
return error;
}
示例7: step_parser
static void step_parser(parser_context *context)
{
if(look_for(context, "()"))
{
node_type_test(context);
if(JSONPATH_SUCCESS == context->result.code && has_more_input(context))
{
consume_char(context);
consume_char(context);
}
}
else
{
name_test(context);
}
if(JSONPATH_SUCCESS == context->result.code && has_more_input(context))
{
step_predicate_parser(context);
}
if(ERR_UNEXPECTED_VALUE == context->result.code && '[' == context->result.expected_char)
{
enter_state(context, ST_STEP);
context->result.code = JSONPATH_SUCCESS;
}
}
示例8: absolute_path
static void absolute_path(parser_context *context)
{
enter_state(context, ST_ABSOLUTE_PATH);
if('$' == get_char(context))
{
context->result.code = JSONPATH_SUCCESS;
context->path->kind = ABSOLUTE_PATH;
context->current_step_kind = ROOT;
consume_char(context);
step *root = make_root_step();
if(NULL == root)
{
context->result.code = ERR_PARSER_OUT_OF_MEMORY;
return;
}
if(!push_step(context, root))
{
return;
}
if(has_more_input(context))
{
qualified_path(context);
}
}
else
{
unexpected_value(context, '$');
}
}
示例9: to_state
static int to_state(struct state_t* state,void* input)
{
int ret;
do{
ret=enter_state(state,input);
}while( state->owner->isrunning && do_transition(state,input) < 0 );
return exit_state(state,input);
}
示例10: fn_leave_tag
void
fn_leave_tag(char **args)
{
if (binding_state != bs_tag) {
disp_status(DISP_STATUS, "not in <tag> mode");
return;
}
enter_state(leave_tag);
}
示例11: pm_suspend
/**
* pm_suspend - Externally visible function for suspending system.
* @state: Enumerated value of state to enter.
*
* Determine whether or not value is within range, get state
* structure, and enter (above).
*/
int pm_suspend(suspend_state_t state)
{
int error;
if (state <= PM_SUSPEND_ON || state >= PM_SUSPEND_MAX)
return -EINVAL;
pm_suspend_marker("entry");
error = enter_state(state);
pm_suspend_marker("exit");
return error;
}
示例12: TRACE
void DispatcherPrivate::task_main_imp(volatile PROCESS_ENTRY_STATE* process)
{
const PROCESS_ENTRY_DATA* pdata = process->data;
PROCESS_ENTRY* pcb = process->process;
TRACE(("[%s] task_main_imp(): starting\r\n", process->data->name));
process->thread->mutex.lock();
if (pcb->process_start != NULL)
pcb->process_start(pcb);
STATE_ENTRY* state = pdata->initstate;
enter_state(process, state);
process->state = ProcessRunning;
process->thread->mutex.unlock();
osSignalSet(_dispid, SIGNAL_CHANGED);
for (;;)
{
//TRACE(("[%s] task_main_imp(): waiting for signal.\r\n", process->data->name));
process->state = ProcessWaiting;
DelayedThread::signal_wait(SIGNAL_RUN_TASKS);
process->state = ProcessRunning;
//TRACE(("[%s] task_main_imp(): woken up.\r\n", process->data->name));
process->thread->mutex.lock();
//TRACE(("DispatcherPrivate::run_tasks(): locked\r\n"));
do
{
//TRACE(("[%s:%s] task_main_imp(): current state type is %i.\r\n", process->data->name, process->current->data->name, process->current->data->mode));
TRANSITION_ENTRY* transition = find_valid_transition(process);
if (transition != NULL)
{
take_transition(process, transition);
}
else
{
process->stepped = false;
//TRACE(("[%s:%s] task_main_imp(): no transitions found.\r\n", process->data->name, process->current->data->name));
break;
}
} while (process->current->data->mode == StateCommited);
//TRACE(("DispatcherPrivate::run_tasks(): unlocking\r\n"));
process->thread->mutex.unlock();
osSignalSet(_dispid, SIGNAL_CHANGED);
}
}
示例13: state_store
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
const char *buf, size_t n)
{
#ifdef CONFIG_SUSPEND
#ifdef CONFIG_EARLYSUSPEND
suspend_state_t state = PM_SUSPEND_ON;
#else
suspend_state_t state = PM_SUSPEND_STANDBY;
#endif
const char * const *s;
#endif
char *p;
int len;
int error = -EINVAL;
p = memchr(buf, '\n', n);
len = p ? p - buf : n;
/* First, check if we are requested to hibernate */
if (len == 4 && !strncmp(buf, "disk", len)) {
printk(KERN_ERR "entering hibernate");
error = hibernate();
goto Exit;
}
#ifdef CONFIG_SUSPEND
for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {
if (*s && len == strlen(*s) && !strncmp(buf, *s, len))
break;
}
printk(KERN_ERR "entering sleep state = %d\n", state);
if (state < PM_SUSPEND_MAX && *s)
{
#ifdef CONFIG_EARLYSUSPEND
if (state == PM_SUSPEND_ON || valid_state(state)) {
error = 0;
request_suspend_state(state);
} else {
printk(KERN_ERR "not valid state with state = %d", state);
}
#else
error = enter_state(state);
#endif
}
#endif
Exit:
return error ? error : n;
}
示例14: pm_suspend
/**
* pm_suspend - Externally visible function for suspending system.
* @state: Enumerated value of state to enter.
*
* Determine whether or not value is within range, get state
* structure, and enter (above).
*/
int pm_suspend(suspend_state_t state)
{
int ret;
if (state > PM_SUSPEND_ON && state < PM_SUSPEND_MAX) {
ret = enter_state(state);
if (ret) {
suspend_stats.fail++;
dpm_save_failed_errno(ret);
} else
suspend_stats.success++;
return ret;
}
return -EINVAL;
}
示例15: wildcard_name
static void wildcard_name(parser_context *context)
{
enter_state(context, ST_WILDCARD_NAME_TEST);
step *current = make_step(context->current_step_kind, WILDCARD_TEST);
if(NULL == current)
{
context->result.code = ERR_PARSER_OUT_OF_MEMORY;
return;
}
push_step(context, current);
consume_char(context);
context->result.code = JSONPATH_SUCCESS;
}