本文整理汇总了C++中ON函数的典型用法代码示例。如果您正苦于以下问题:C++ ON函数的具体用法?C++ ON怎么用?C++ ON使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ON函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessOption
/****************************************************************************\
Option handler provided when calling ParseCmdLine member function of CGetOptions
\****************************************************************************/
bool ProcessOption(int ch, char *optarg, void* user_ctx)
{
bool bDone = false;
do {
struct USER_SETTINGS* pUsrSet = (struct USER_SETTINGS*)user_ctx;
if(pUsrSet == NULL) {
break;
}
#define ON(msg, fn) case msg: bDone = fn(ch, optarg, pUsrSet); break;
switch(ch) {
ON('h', OnUsage);
ON('c', OnBlockCount);
ON('s', OnBlockSize);
ON('r', OnRunTime);
default:
printf("Try '--help' for more information.\n");
bDone = true;
break;
}
#undef ON
} while(false);
return bDone;
}
示例2: makeTarget
void
makeTarget(
char *s,
BOOL firstTarg,
BUILDBLOCK **block
)
{
BUILDLIST *build;
MAKEOBJECT *object;
if (!*block)
*block = makeNewBuildBlock();
if (firstTarg) {
build = makeNewBldListElement();
build->buildBlock = *block;
} else
build = makeBuildList(*block);
if ((object = findTarget(s))) {
if (ON(object->flags2, F2_DOUBLECOLON) != ON(currentFlags, F2_DOUBLECOLON))
makeError(currentLine, MIXED_SEPARATORS);
appendItem((STRINGLIST**)&(object->buildList), (STRINGLIST*)build);
FREE(s);
} else {
build->next = NULL;
object = makeNewObject();
object->name = s;
object->buildList = build;
object->flags2 = currentFlags;
prependItem((STRINGLIST**)targetTable+hash(s, MAXTARGET, (BOOL)TRUE),
(STRINGLIST*)object);
}
}
示例3: cpld_flash
//# MENU cpld
void cpld_flash() {
SETUPgout(EN_1V8);
ON(EN_1V8);
delay(1000000); /* wait until cpld boot */
cpu_clock_set(204);
lcdPrintln("Program CPLD");
bytes=0;
lcdPrint(IntToStr(bytes,5,F_LONG));
lcdPrint(" bytes...");
lcdNl();
#define WAIT_LOOP_DELAY (6000000)
#define ALL_LEDS (PIN_LED1|PIN_LED2|PIN_LED3)
int i;
int error;
refill_cpld_buffer_fs();
error = cpld_jtag_program(sizeof(cpld_xsvf_buffer),
cpld_xsvf_buffer,
refill_cpld_buffer_fs);
if(error) {
lcdPrintln("Programming failed!");
lcdPrintln(IntToStr(error,5,0));
lcdDisplay();
/* LED3 (Red) steady on error */
ON(LED4);
while (1);
};
lcdPrintln("Success.");
lcdDisplay();
OFF(EN_1V8);
};
示例4: __xmas
static echs_event_t
__xmas(void *UNUSED(clo))
{
DEFSTATE(XMAS);
DEFSTATE(BOXD);
echs_event_t e;
switch (state) {
case BEFORE_XMAS:
e.when = (echs_instant_t){y, 12U, 25U};
e.what = ON(XMAS);
state = ON_XMAS;
break;
case ON_XMAS:
e.when = (echs_instant_t){y, 12U, 26U};
e.what = OFF(XMAS);
state = BEFORE_BOXD;
break;
case BEFORE_BOXD:
e.when = (echs_instant_t){y, 12U, 26U};
e.what = ON(BOXD);
state = ON_BOXD;
break;
case ON_BOXD:
e.when = (echs_instant_t){y, 12U, 27U};
e.what = OFF(BOXD);
state = BEFORE_XMAS;
y++;
break;
default:
abort();
}
return e;
}
示例5: cpld_menu
//# MENU cpld
void cpld_menu(){
getInputWaitRelease();
SETUPgout(EN_1V8);
ON(EN_1V8);
delayNop(1000000); /* wait until cpld boot */
cpu_clock_set(204);
lcdClear();
lcdPrintln("CPLD");
lcdNl();
lcdNl();
bytes=0;
lcdPrint(IntToStr(bytes,5,F_LONG));
lcdPrint(" bytes...");
lcdNl();
#define WAIT_LOOP_DELAY (6000000)
#define ALL_LEDS (PIN_LED1|PIN_LED2|PIN_LED3)
int i;
int error;
FRESULT res;
res=f_open(&file, "cpld.xsv", FA_OPEN_EXISTING|FA_READ);
if(res!=FR_OK){
lcdPrintln("FOPEN ERROR");
lcdPrintln(f_get_rc_string(res));
lcdDisplay();
getInputWait();
return;
};
refill_cpld_buffer_fs();
error = cpld_jtag_program(sizeof(cpld_xsvf_buffer),
cpld_xsvf_buffer,
refill_cpld_buffer_fs);
if(error){
lcdPrintln("Programming failed!");
lcdPrintln(IntToStr(error,5,0));
lcdDisplay();
/* LED3 (Red) steady on error */
ON(LED3);
while (1);
};
lcdPrintln("Success.");
lcdDisplay();
for (res=0;res<10;res++){
/* blink LED1, LED2, and LED3 on success */
TOGGLE(LED1);
TOGGLE(LED2);
TOGGLE(LED3);
for (i = 0; i < WAIT_LOOP_DELAY; i++) /* Wait a bit. */
__asm__("nop");
};
/* XXX: Maybe power toggle needed to start CPLD? */
OFF(EN_1V8);
};
示例6: simple
static int simple(void) {
ne_buffer *s = ne_buffer_create();
ON(s == NULL);
ne_buffer_zappend(s, "abcde");
ONCMP(s->data, "abcde");
ON(ne_buffer_size(s) != 5);
ne_buffer_destroy(s);
return OK;
}
示例7: ON
void Buzzer::target_not_found()
{
ON();
wait(0.1);
OFF();
wait(0.1);
ON();
wait(0.2);
OFF();
}
示例8: buf_concat
static int buf_concat(void)
{
ne_buffer *s = ne_buffer_create();
ON(s == NULL);
ne_buffer_concat(s, "a", "b", "c", "d", "e", "f", "g", NULL);
ONCMP(s->data, "abcdefg");
ON(ne_buffer_size(s) != 7);
ne_buffer_destroy(s);
return OK;
}
示例9: spectrum_menu
//# MENU spectrum
void spectrum_menu()
{
lcdClear();
lcdDisplay();
getInputWaitRelease();
// RF initialization from ppack.c:
dac_init(false);
cpu_clock_set(204); // WARP SPEED! :-)
hackrf_clock_init();
rf_path_pin_setup();
/* Configure external clock in */
scu_pinmux(SCU_PINMUX_GP_CLKIN, SCU_CLK_IN | SCU_CONF_FUNCTION1);
sgpio_configure_pin_functions();
ON(EN_VDD);
ON(EN_1V8);
OFF(MIC_AMP_DIS);
delayms(500); // doesn't work without
cpu_clock_set(204); // WARP SPEED! :-)
si5351_init();
portapack_init();
while(1)
{
switch(getInput())
{
case BTN_UP:
displayMode=MODE_WATERFALL;
break;
case BTN_DOWN:
displayMode=MODE_SPECTRUM;
break;
case BTN_LEFT:
freq -= 2000000;
ssp1_set_mode_max2837();
set_freq(freq);
break;
case BTN_RIGHT:
freq += 2000000;
ssp1_set_mode_max2837();
set_freq(freq);
break;
case BTN_ENTER:
//FIXME: unset the callback, reset the clockspeed, tidy up
nvic_disable_irq(NVIC_DMA_IRQ);
OFF(EN_VDD);
OFF(EN_1V8);
ON(MIC_AMP_DIS);
systick_set_clocksource(0);
systick_set_reload(12e6/SYSTICKSPEED/1000);
return;
}
}
}
示例10: buf_concat3
static int buf_concat3(void)
{
ne_buffer *s = ne_buffer_create();
ON(s == NULL);
ne_buffer_zappend(s, "foobar");
ne_buffer_concat(s, "norman", NULL);
ONCMP(s->data, "foobarnorman");
ON(ne_buffer_size(s) != 12);
ne_buffer_destroy(s);
return OK;
}
示例11: buf_concat2
static int buf_concat2(void)
{
#define RES "alphabetagammadeltaepsilonetatheta"
ne_buffer *s = ne_buffer_create();
ON(s == NULL);
ne_buffer_concat(s, "alpha", "beta", "gamma", "delta", "epsilon",
"eta", "theta", NULL);
ONCMP(s->data, RES);
ON(ne_buffer_size(s) != strlen(RES));
ne_buffer_destroy(s);
return OK;
}
示例12: ppack_menu
//# MENU Apack
void ppack_menu() {
lcdClear();
lcdPrintln("PPack port");
lcdPrintln("");
lcdPrintln("up=enable");
lcdDisplay();
dac_init(false);
cpu_clock_set(204); // WARP SPEED! :-)
hackrf_clock_init();
rf_path_pin_setup();
/* Configure external clock in */
scu_pinmux(SCU_PINMUX_GP_CLKIN, SCU_CLK_IN | SCU_CONF_FUNCTION1);
sgpio_configure_pin_functions();
ON(EN_VDD);
ON(EN_1V8);
OFF(MIC_AMP_DIS);
complex_s8_t * samples;
while(1){
switch(getInputRaw()){
case BTN_UP:
// ON(MIXER_EN); // hackrf does this
cpu_clock_set(204); // WARP SPEED! :-)
si5351_init();
portapack_init();
getInputWaitRelease();
break;
case BTN_DOWN:
lcdPrintln("file");
writeFile("samples.8", (char*)0x20000000,(uintptr_t)s8ram-0x20000000);
break;
case BTN_LEFT:
lcdPrintln("reset");
s8ram=(complex_s8_t*)0x20000000;
break;
case BTN_RIGHT:
break;
case BTN_ENTER:
return;
};
TOGGLE(LED2);
delayms(40);
lcdPrint(IntToStr((uintptr_t)s8ram,8,F_HEX));
lcdPrint(" ");
lcdPrintln(IntToStr(sctr,7,F_LONG));
lcdDisplay();
};
};
示例13: rtsmb_srv_browse_ensure_backup_ratio
/* this makes sure that there aren't too many more normal servers to backup servers.
If there are, it promotes a random potential browser */
RTSMB_STATIC void rtsmb_srv_browse_ensure_backup_ratio (void)
{
int i, num_total = 0, num_backup = 0, num_potentials = 0, backup_server = -1;
for (i = 0; i < prtsmb_srv_ctx->server_table_size; i++)
{
if (prtsmb_srv_ctx->server_table[i].type)
{
num_total ++;
if (ON (prtsmb_srv_ctx->server_table[i].type, SV_TYPE_BACKUP_BROWSER))
{
num_backup ++;
}
else if (ON (prtsmb_srv_ctx->server_table[i].type, SV_TYPE_POTENTIAL_BROWSER))
{
num_potentials ++;
}
}
}
if (num_backup * RTSMB_SRV_BROWSE_NORMALS_TO_BACKUPS < num_total)
{
/* not enough backups, we need to promote someone */
int target = tc_rand () % num_potentials;
for (i = 0; i < prtsmb_srv_ctx->server_table_size; i++)
{
if (prtsmb_srv_ctx->server_table[i].type)
{
if (OFF (prtsmb_srv_ctx->server_table[i].type, SV_TYPE_BACKUP_BROWSER) &&
ON (prtsmb_srv_ctx->server_table[i].type, SV_TYPE_POTENTIAL_BROWSER))
{
if (target == 0)
{
backup_server = i;
break;
}
else
{
target --;
}
}
}
}
}
if (backup_server >= 0)
{
rtsmb_srv_browse_send_become_backup (prtsmb_srv_ctx->server_table[backup_server].name);
}
}
示例14: Send_Byte
void Send_Byte(char byte){
// отправляем байт последовательно по битам , при этом кликая каждый бит и дергая защелку каждый байт
for (char i=0;i<8;i++){
if ((byte&0x80)==0x00) ON(SHIFT_data);
else OFF(SHIFT_data);
byte<<=1;
ON(SHIFT_clk);
OFF(SHIFT_clk);
}
OFF(SHIFT_latch);
ON(SHIFT_latch);
OFF(SHIFT_latch);
}
示例15: tim1_trg_com_irq_handler
/**
* PWM timer commutation event interrupt handler
*/
void tim1_trg_com_irq_handler(void)
{
TIM_ClearITPendingBit(TIM1, TIM_IT_COM);
ON(LED_BLUE);
TIM_SetCompare1(TIM1, pwm_val);
TIM_SetCompare2(TIM1, pwm_val);
TIM_SetCompare3(TIM1, pwm_val);
TIM_SetCompare4(TIM1, pwm_offset);
PWM__SCHEME();
ON(LED_BLUE);
}