本文整理汇总了C++中process_run函数的典型用法代码示例。如果您正苦于以下问题:C++ process_run函数的具体用法?C++ process_run怎么用?C++ process_run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了process_run函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
/**
* \brief Main function for nRF52dk platform.
* \note This function doesn't return.
*/
int
main(void)
{
board_init();
leds_init();
clock_init();
rtimer_init();
watchdog_init();
process_init();
// Seed value is ignored since hardware RNG is used.
random_init(0);
#ifdef UART0_ENABLED
uart0_init();
#if SLIP_ARCH_CONF_ENABLE
slip_arch_init(0);
#else
uart0_set_input(serial_line_input_byte);
serial_line_init();
#endif
#endif
PRINTF("Starting " CONTIKI_VERSION_STRING "\n");
process_start(&etimer_process, NULL);
ctimer_init();
#if ENERGEST_CONF_ON
energest_init();
ENERGEST_ON(ENERGEST_TYPE_CPU);
#endif
#ifdef SOFTDEVICE_PRESENT
ble_stack_init();
ble_advertising_init(DEVICE_NAME);
#if NETSTACK_CONF_WITH_IPV6
netstack_init();
linkaddr_t linkaddr;
ble_get_mac(linkaddr.u8);
/* Set link layer address */
linkaddr_set_node_addr(&linkaddr);
/* Set device link layer address in uip stack */
memcpy(&uip_lladdr.addr, &linkaddr, sizeof(uip_lladdr.addr));
process_start(&ble_iface_observer, NULL);
process_start(&tcpip_process, NULL);
#endif /* NETSTACK_CONF_WITH_IPV6 */
#endif /* SOFTDEVICE_PRESENT */
process_start(&sensors_process, NULL);
autostart_start(autostart_processes);
watchdog_start();
#ifdef SOFTDEVICE_PRESENT
ble_advertising_start();
PRINTF("Advertising name [%s]\n", DEVICE_NAME);
#endif
while(1) {
uint8_t r;
do {
r = process_run();
watchdog_periodic();
} while(r > 0);
lpm_drop();
}
}
开发者ID:1847123212,项目名称:contiki,代码行数:76,代码来源:contiki-main.c
示例2: main
int
main(int argc, char **argv)
{
#if UIP_CONF_IPV6
#if UIP_CONF_IPV6_RPL
printf(CONTIKI_VERSION_STRING " started with IPV6, RPL\n");
#else
printf(CONTIKI_VERSION_STRING " started with IPV6\n");
#endif
#else
printf(CONTIKI_VERSION_STRING " started\n");
#endif
/* crappy way of remembering and accessing argc/v */
contiki_argc = argc;
contiki_argv = argv;
/* native under windows is hardcoded to use the first one or two args */
/* for wpcap configuration so this needs to be "removed" from */
/* contiki_args (used by the native-border-router) */
#ifdef __CYGWIN__
contiki_argc--;
contiki_argv++;
#ifdef UIP_FALLBACK_INTERFACE
contiki_argc--;
contiki_argv++;
#endif
#endif
process_init();
process_start(&etimer_process, NULL);
ctimer_init();
set_rime_addr();
queuebuf_init();
netstack_init();
printf("MAC %s RDC %s NETWORK %s\n", NETSTACK_MAC.name, NETSTACK_RDC.name, NETSTACK_NETWORK.name);
#if WITH_UIP6
memcpy(&uip_lladdr.addr, serial_id, sizeof(uip_lladdr.addr));
process_start(&tcpip_process, NULL);
#ifdef __CYGWIN__
process_start(&wpcap_process, NULL);
#endif
printf("Tentative link-local IPv6 address ");
{
uip_ds6_addr_t *lladdr;
int i;
lladdr = uip_ds6_get_link_local(-1);
for(i = 0; i < 7; ++i) {
printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],
lladdr->ipaddr.u8[i * 2 + 1]);
}
/* make it hardcoded... */
lladdr->state = ADDR_AUTOCONF;
printf("%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
}
#else
process_start(&tcpip_process, NULL);
#endif
serial_line_init();
autostart_start(autostart_processes);
/* Make standard output unbuffered. */
setvbuf(stdout, (char *)NULL, _IONBF, 0);
select_set_callback(STDIN_FILENO, &stdin_fd);
simple_rpl_init();
ip64_init();
while(1) {
fd_set fdr;
fd_set fdw;
int maxfd;
int i;
int retval;
struct timeval tv;
retval = process_run();
tv.tv_sec = 0;
tv.tv_usec = retval ? 1 : 1000;
FD_ZERO(&fdr);
FD_ZERO(&fdw);
maxfd = 0;
for(i = 0; i <= select_max; i++) {
if(select_callback[i] != NULL && select_callback[i]->set_fd(&fdr, &fdw)) {
maxfd = i;
}
}
retval = select(maxfd + 1, &fdr, &fdw, NULL, &tv);
//.........这里部分代码省略.........
开发者ID:ADVANSEE,项目名称:mist,代码行数:101,代码来源:contiki-main.c
示例3: main
int
main(int argc, char **argv)
{
/*
* Initalize hardware.
*/
msp430_cpu_init();
clock_init();
leds_init();
leds_toggle(LEDS_ALL);
slip_arch_init(BAUD2UBR(115200)); /* Must come before first printf */
printf("Starting %s "
"($Id: dhclient.c,v 1.1 2008/05/27 13:16:34 adamdunkels Exp $)\n", __FILE__);
ds2411_init();
sensors_light_init();
cc2420_init();
xmem_init();
button_init(&button_process);
leds_toggle(LEDS_ALL);
/*
* Hardware initialization done!
*/
printf("MAC %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x CHANNEL %d\n",
ds2411_id[0], ds2411_id[1], ds2411_id[2], ds2411_id[3],
ds2411_id[4], ds2411_id[5], ds2411_id[6], ds2411_id[7],
RF_CHANNEL);
srand(rand() +
(ds2411_id[3]<<8) + (ds2411_id[4]<<6) + (ds2411_id[5]<<4) +
(ds2411_id[6]<<2) + ds2411_id[7]);
/*
* Initialize Contiki and our processes.
*/
process_init();
process_start(&etimer_process, NULL);
/* Configure IP stack. */
uip_init();
/* Start IP stack. */
process_start(&tcpip_process, NULL);
process_start(&uip_fw_process, NULL); /* Start IP output */
process_start(&cc2420_process, NULL);
cc2420_on();
process_start(&dhclient_process, NULL);
process_start(&button_process, NULL);
process_start(&tcp_loader_process, NULL);
/*
* This is the scheduler loop.
*/
printf("process_run()...\n");
while (1) {
do {
/* Reset watchdog. */
} while(process_run() > 0);
/*
* Idle processing.
*/
int s = splhigh(); /* Disable interrupts. */
if(process_nevents() != 0) {
splx(s); /* Re-enable interrupts. */
} else {
/* Re-enable interrupts and go to sleep atomically. */
_BIS_SR(GIE | SCG0 | CPUOFF); /* LPM1 sleep. */
}
}
return 0;
}
开发者ID:EDAyele,项目名称:ptunes,代码行数:74,代码来源:dhclient.c
示例4: main
//.........这里部分代码省略.........
/*
* Initialize Contiki and our processes.
*/
process_init();
#if WITH_SERIAL_LINE_INPUT
uart1_set_input(serial_line_input_byte);
serial_line_init();
#endif
/* rtimer and ctimer should be initialized before radio duty cycling
layers */
rtimer_init();
/* etimer_process should be initialized before ctimer */
process_start(&etimer_process, NULL);
ctimer_init();
netstack_init();
set_rime_addr();
printf("%s %s, channel check rate %lu Hz\n",
NETSTACK_MAC.name, NETSTACK_RDC.name,
CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
NETSTACK_RDC.channel_check_interval()));
printf("802.15.4 PAN ID 0x%x, EUI-%d:",
IEEE802154_CONF_PANID, UIP_CONF_LL_802154?64:16);
uip_debug_lladdr_print(&linkaddr_node_addr);
printf(", radio channel %u\n", RF_CHANNEL);
procinit_init();
energest_init();
ENERGEST_ON(ENERGEST_TYPE_CPU);
/* Set the Clear Channel Assessment (CCA) threshold of the
radio. The CCA threshold is used both for sending packets and for
waking up ContikiMAC nodes. If the CCA threshold is too high,
ContikiMAC will not wake up from neighbor transmissions. If the
CCA threshold is too low, transmissions will be too restrictive
and no packets will be sent. DEFAULT_RADIO_CCA_THRESHOLD is
defined in this file. */
ST_RadioSetEdCcaThreshold(DEFAULT_RADIO_CCA_THRESHOLD);
autostart_start(autostart_processes);
#if NETSTACK_CONF_WITH_IPV6
printf("Tentative link-local IPv6 address ");
{
uip_ds6_addr_t *lladdr;
int i;
lladdr = uip_ds6_get_link_local(-1);
for(i = 0; i < 7; ++i) {
printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],
lladdr->ipaddr.u8[i * 2 + 1]);
}
printf("%02x%02x\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
}
if(!UIP_CONF_IPV6_RPL) {
uip_ipaddr_t ipaddr;
int i;
uip_ip6addr(&ipaddr, 0xaaaa, 0, 0, 0, 0, 0, 0, 0);
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);
printf("Tentative global IPv6 address ");
for(i = 0; i < 7; ++i) {
printf("%02x%02x:",
ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
}
printf("%02x%02x\n",
ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
}
#endif /* NETSTACK_CONF_WITH_IPV6 */
watchdog_start();
while(1) {
int r;
do {
/* Reset watchdog. */
watchdog_periodic();
r = process_run();
} while(r > 0);
/* watchdog_stop(); */
ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);
/* Go to idle mode. */
halSleepWithOptions(SLEEPMODE_IDLE,0);
/* We are awake. */
/* watchdog_start(); */
ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);
}
}
开发者ID:gnkarn,项目名称:Contiki,代码行数:101,代码来源:contiki-main.c
示例5: main
//.........这里部分代码省略.........
GLCD_Init(); /* Initialize graphical LCD display */
GLCD_Clear(White); /* Clear graphical LCD display */
GLCD_SetBackColor(DarkGreen);
GLCD_SetTextColor(White);
GLCD_DisplayString(0, 0, __FI, " KUSZ - TU Dortmund ");
GLCD_DisplayString(1, 0, __FI, " contiki ");
GLCD_DisplayString(2, 0, __FI, " www.tu-dortmund.de ");
GLCD_SetBackColor(White);
GLCD_SetTextColor(Blue);
watchdog_periodic();
#endif // __USE_LCD
/*
* Initialize Contiki and our processes.
*/
#ifdef WITH_SERIAL_LINE_INPUT
// uart1_set_input(serial_line_input_byte);
// serial_line_init();
#endif
/* rtimer and ctimer should be initialized before radio duty cycling layers*/
rtimer_init();
process_init();
process_start(&sensors_process, NULL);
/* etimers must be started before ctimer_init */
process_start(&etimer_process, NULL);
ctimer_init();
/* Start radio and radio receive process */
NETSTACK_RADIO.init();
/* makes use of cpu-specific RNG peripheral - no seed needed */
random_init(0);
/* Set addresses BEFORE starting tcpip process */
addr.u8[0] = 0x02;
addr.u8[1] = *((uint8_t*)0x1FFF7A10);
addr.u8[2] = *((uint8_t*)0x1FFF7A10+1);
addr.u8[3] = 0xFF;
addr.u8[4] = 0xFE;
addr.u8[5] = *((uint8_t*)0x1FFF7A10+2);
addr.u8[6] = *((uint8_t*)0x1FFF7A10+3);
addr.u8[7] = *((uint8_t*)0x1FFF7A10+4);
memcpy(&uip_lladdr.addr, &addr.u8, sizeof(rimeaddr_t));
rimeaddr_set_node_addr(&addr);
rf230_set_pan_addr(0xabcd,0xbabe,(uint8_t *)&addr.u8);
rf230_set_channel(CHANNEL_802_15_4);
rf230_set_txpower(0); /* max */
PRINTF("EUI-64 MAC: %x-%x-%x-%x-%x-%x-%x-%x\n",addr.u8[0],addr.u8[1],addr.u8[2],addr.u8[3],addr.u8[4],addr.u8[5],addr.u8[6],addr.u8[7]);
/* Initialize stack protocols */
queuebuf_init();
NETSTACK_RDC.init();
NETSTACK_MAC.init();
NETSTACK_NETWORK.init();
#define ANNOUNCE_BOOT 1
#if ANNOUNCE_BOOT
PRINTF("%s %s, channel %u , check rate %u Hz tx power %u\n",NETSTACK_MAC.name, NETSTACK_RDC.name, rf230_get_channel(),
CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:NETSTACK_RDC.channel_check_interval()),
rf230_get_txpower());
#if UIP_CONF_IPV6_RPL
PRINTF("RPL Enabled\n");
#endif
#if UIP_CONF_ROUTER
PRINTF("Routing Enabled\n");
#endif
#endif /* ANNOUNCE_BOOT */
process_start(&tcpip_process, NULL);
/* Autostart other processes */
autostart_start(autostart_processes);
#if ANNOUNCE_BOOT
PRINTF("Online\n");
#endif /* ANNOUNCE_BOOT */
energest_init();
ENERGEST_ON(ENERGEST_TYPE_CPU);
watchdog_start();
while (1) { /* Loop forever */
watchdog_periodic();
process_run();
}
}
开发者ID:tdautc19841202,项目名称:tdma_demo,代码行数:101,代码来源:contiki-main.c
示例6: main
//.........这里部分代码省略.........
#endif
leds_off(LEDS_GREEN);
#if TIMESYNCH_CONF_ENABLED
timesynch_init();
timesynch_set_authority_level((linkaddr_node_addr.u8[0] << 4) + 16);
#endif /* TIMESYNCH_CONF_ENABLED */
#if NETSTACK_CONF_WITH_IPV4
process_start(&tcpip_process, NULL);
process_start(&uip_fw_process, NULL); /* Start IP output */
process_start(&slip_process, NULL);
slip_set_input_callback(set_gateway);
{
uip_ipaddr_t hostaddr, netmask;
uip_init();
uip_ipaddr(&hostaddr, 172,16,
linkaddr_node_addr.u8[0],linkaddr_node_addr.u8[1]);
uip_ipaddr(&netmask, 255,255,0,0);
uip_ipaddr_copy(&meshif.ipaddr, &hostaddr);
uip_sethostaddr(&hostaddr);
uip_setnetmask(&netmask);
uip_over_mesh_set_net(&hostaddr, &netmask);
/* uip_fw_register(&slipif);*/
uip_over_mesh_set_gateway_netif(&slipif);
uip_fw_default(&meshif);
uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);
printf("uIP started with IP address %d.%d.%d.%d\n",
uip_ipaddr_to_quad(&hostaddr));
}
#endif /* NETSTACK_CONF_WITH_IPV4 */
energest_init();
ENERGEST_ON(ENERGEST_TYPE_CPU);
watchdog_start();
/* Stop the watchdog */
watchdog_stop();
#if !PROCESS_CONF_NO_PROCESS_NAMES
print_processes(autostart_processes);
#else /* !PROCESS_CONF_NO_PROCESS_NAMES */
putchar('\n'); /* include putchar() */
#endif /* !PROCESS_CONF_NO_PROCESS_NAMES */
autostart_start(autostart_processes);
/*
* This is the scheduler loop.
*/
while(1) {
int r;
do {
/* Reset watchdog. */
watchdog_periodic();
r = process_run();
} while(r > 0);
/*
* Idle processing.
*/
int s = splhigh(); /* Disable interrupts. */
/* uart1_active is for avoiding LPM3 when still sending or receiving */
if(process_nevents() != 0 || uart1_active()) {
splx(s); /* Re-enable interrupts. */
} else {
static unsigned long irq_energest = 0;
/* Re-enable interrupts and go to sleep atomically. */
ENERGEST_OFF(ENERGEST_TYPE_CPU);
ENERGEST_ON(ENERGEST_TYPE_LPM);
/* We only want to measure the processing done in IRQs when we
are asleep, so we discard the processing time done when we
were awake. */
energest_type_set(ENERGEST_TYPE_IRQ, irq_energest);
watchdog_stop();
_BIS_SR(GIE | SCG0 | SCG1 | CPUOFF); /* LPM3 sleep. This
statement will block
until the CPU is
woken up by an
interrupt that sets
the wake up flag. */
/* We get the current processing time for interrupts that was
done during the LPM and store it for next time around. */
dint();
irq_energest = energest_type_time(ENERGEST_TYPE_IRQ);
eint();
watchdog_start();
ENERGEST_OFF(ENERGEST_TYPE_LPM);
ENERGEST_ON(ENERGEST_TYPE_CPU);
}
}
}
开发者ID:Abdellazizhammami,项目名称:contiki,代码行数:101,代码来源:contiki-wismote-main.c
示例7: main
//.........这里部分代码省略.........
*
* We don't need it. by MW
*/
// model_uart_intr_en();
energest_init();
ENERGEST_ON(ENERGEST_TYPE_CPU);
fade(LEDS_RED);
#if BATMON_CONF_ON
process_start(&batmon_process, NULL);
#endif
autostart_start(autostart_processes);
watchdog_start();
while(1) {
do {
/* Reset watchdog and handle polls and events */
watchdog_periodic();
/**/
#if !CLOCK_CONF_ACCURATE
if(sleep_flag) {
if(etimer_pending() &&
(etimer_next_expiration_time() - count - 1) > MAX_TICKS) { /*core/sys/etimer.c*/
etimer_request_poll();
}
sleep_flag = 0;
}
#endif
r = process_run();
} while(r > 0);
#if SHORTCUTS_CONF_NETSTACK
len = NETSTACK_RADIO.pending_packet();
if(len) {
packetbuf_clear();
len = NETSTACK_RADIO.read(packetbuf_dataptr(), PACKETBUF_SIZE);
if(len > 0) {
packetbuf_set_datalen(len);
NETSTACK_RDC.input();
}
}
#endif
#if LPM_MODE
#if (LPM_MODE==LPM_MODE_PM2)
SLEEP &= ~OSC_PD; /* Make sure both HS OSCs are on */
while(!(SLEEP & HFRC_STB)); /* Wait for RCOSC to be stable */
CLKCON |= OSC; /* Switch to the RCOSC */
while(!(CLKCON & OSC)); /* Wait till it's happened */
SLEEP |= OSC_PD; /* Turn the other one off */
#endif /* LPM_MODE==LPM_MODE_PM2 */
/*
* Set MCU IDLE or Drop to PM1. Any interrupt will take us out of LPM
* Sleep Timer will wake us up in no more than 7.8ms (max idle interval)
*/
SLEEP = (SLEEP & 0xFC) | (LPM_MODE - 1);
#if (LPM_MODE==LPM_MODE_PM2)
/*
* Wait 3 NOPs. Either an interrupt occurred and SLEEP.MODE was cleared or
* no interrupt occurred and we can safely power down
开发者ID:mw5945,项目名称:contiki-ejoy-cc2430,代码行数:67,代码来源:contiki-sensinode-main.c
示例8: main
int
main(int argc, char **argv)
{
/* crappy way of remembering and accessing argc/v */
contiki_argc = argc;
contiki_argv = argv;
/* native under windows is hardcoded to use the first one or two args */
/* for wpcap configuration so this needs to be "removed" from */
/* contiki_args (used by the native-border-router) */
//printf("Cgroups -timer\n");
/*Initalize "hardware".*/
init_timer();
clock_init();
rtimer_init();
//printf("Hello glorious world of cheese\n");
/*
* Hardware initialization done!
*/
process_init();
process_start(&etimer_process, NULL);
ctimer_init();
set_rime_addr();
queuebuf_init();
netstack_init();
//printf("MAC %s RDC %s NETWORK %s\n", NETSTACK_MAC.name, NETSTACK_RDC.name, NETSTACK_NETWORK.name);
printf("Hello Rika, I am cgroups in contiki!\n");
serial_line_init();
autostart_start(autostart_processes);
/* Make standard output unbuffered. */
setvbuf(stdout, (char *)NULL, _IONBF, 0);
select_set_callback(STDIN_FILENO, &stdin_fd);
/*
* This is the scheduler loop.
*/
while(1) {
fd_set fdr;
fd_set fdw;
int maxfd;
int i;
int retval;
struct timeval tv;
retval = process_run();
tv.tv_sec = 0;
tv.tv_usec = retval ? 1 : 1000;
FD_ZERO(&fdr);
FD_ZERO(&fdw);
maxfd = 0;
for(i = 0; i <= select_max; i++) {
if(select_callback[i] != NULL && select_callback[i]->set_fd(&fdr, &fdw)) {
maxfd = i;
}
}
retval = select(maxfd + 1, &fdr, &fdw, NULL, &tv);
if(retval < 0) {
perror("select");
} else if(retval > 0) {
/* timeout => retval == 0 */
for(i = 0; i <= maxfd; i++) {
if(select_callback[i] != NULL) {
select_callback[i]->handle_fd(&fdr, &fdw);
}
}
}
etimer_request_poll();
}
return 0;
}
开发者ID:janerikazhang,项目名称:project,代码行数:88,代码来源:contiki-cgroups-main.c
示例9: main
//.........这里部分代码省略.........
int qrpsize = strlen(rp) + 3;
qrp = malloc(qrpsize);
qrp[0] = '"';
strcpy(&qrp[1], rp);
qrp[qrpsize-2] = '"';
qrp[qrpsize-1] = '\0';
#endif
int index = 0;
args[index++] = shell;
if (dotagging) /* don't do bash -x for non-tagged commands e.g. $(shell output) */
args[index++] = "-x";
args[index++] = "-c";
args[index++] = qrp;
args[index++] = NULL;
/* get the semaphore ready */
talon_sem.name = buildid;
talon_sem.timeout = timeout;
do
{
char talon_attempt[TALON_ATTEMPT_STRMAX];
double start_time = getseconds();
attempt++;
snprintf(talon_attempt, TALON_ATTEMPT_STRMAX-1, "%d", attempt);
talon_attempt[TALON_ATTEMPT_STRMAX - 1] = '\0';
talon_setenv("TALON_ATTEMPT", talon_attempt);
p = process_run(shell, args, timeout);
double end_time = getseconds();
if (p)
{
talon_returncode = p->returncode;
if (dotagging)
{
char status[STATUS_STRMAX];
char timestat[STATUS_STRMAX];
char warning[WARNING_STRMAX];
warning[0] = '\0';
if (shell_cl_max)
{
int cl_actual = strlen(qrp);
if (cl_actual > shell_cl_max)
{
snprintf(warning, WARNING_STRMAX-1, \
"\n<warning>Command line length '%d' exceeds the shell limit on this system of '%d'. " \
"If this recipe is a compile, try using the '.use_compilation_command_file' variant to reduce overall command line length.</warning>", \
cl_actual, shell_cl_max);
warning[WARNING_STRMAX-1] = '\0';
}
}
char *flagsstr = force_success == 0 ? "" : " flags='FORCESUCCESS'";
char *reasonstr = "" ;
if (p->causeofdeath == PROC_TIMEOUTDEATH)
reasonstr = " reason='timeout'";
开发者ID:RomanSaveljev,项目名称:raptor,代码行数:67,代码来源:talon.c
示例10: main
int main(void) {
mc1322x_init();
/* m12_init() flips the mux switch */
/* trims the main crystal load capacitance */
if (!FORCE_ECONOTAG_I && CRM->SYS_CNTLbits.XTAL32_EXISTS) {
/* M12 based econotag */
PRINTF("trim xtal for M12\n\r");
CRM->XTAL_CNTLbits.XTAL_CTUNE = (M12_CTUNE_4PF << 4) | M12_CTUNE;
CRM->XTAL_CNTLbits.XTAL_FTUNE = M12_FTUNE;
} else {
/* econotag I */
PRINTF("trim xtal for Econotag I\n\r");
CRM->XTAL_CNTLbits.XTAL_CTUNE = (ECONOTAG_CTUNE_4PF << 4) | ECONOTAG_CTUNE;
CRM->XTAL_CNTLbits.XTAL_FTUNE = ECONOTAG_FTUNE;
}
/* create mac address if blank*/
if (mc1322x_config.eui == 0) {
/* mac address is blank */
/* construct a new mac address based on IAB or OUI definitions */
/* if an M12_SERIAL number is not defined */
/* generate a random extension in the Redwire experimental IAB */
/* The Redwire IAB (for development only) is: */
/* OUI: 0x0050C2 IAB: 0xA8C */
/* plus a random 24-bit extension */
/* Otherwise, construct a mac based on the M12_SERIAL */
/* Owners of an Econotag I (not M12 based) can request a serial number from Redwire */
/* to use here */
/* M12 mac is of the form "EC473C4D12000000" */
/* Redwire's OUI: EC473C */
/* M12: 4D12 */
/* next six nibbles are the M12 serial number as hex */
/* e.g. if the barcode reads: "12440021" = BDD1D5 */
/* full mac is EC473C4D12BDD1D5 */
#if (M12_SERIAL == 0)
/* use random mac from experimental range */
mc1322x_config.eui = (0x0050C2A8Cull << 24) | (*MACA_RANDOM & (0xffffff));
#else
/* construct mac from serial number */
mc1322x_config.eui = (0xEC473C4D12ull << 24) | M12_SERIAL;
#endif
mc1322x_config_save(&mc1322x_config);
}
/* configure address on maca hardware and RIME */
contiki_maca_set_mac_address(mc1322x_config.eui);
#if WITH_UIP6
memcpy(&uip_lladdr.addr, &rimeaddr_node_addr.u8, sizeof(uip_lladdr.addr));
queuebuf_init();
NETSTACK_RDC.init();
NETSTACK_MAC.init();
NETSTACK_NETWORK.init();
#if DEBUG_ANNOTATE
print_netstack();
#endif
#if ! CETIC_6LBR
process_start(&tcpip_process, NULL);
#endif
#if DEBUG_ANNOTATE
print_lladdrs();
#endif
#endif /* endif WITH_UIP6 */
process_start(&sensors_process, NULL);
print_processes(autostart_processes);
autostart_start(autostart_processes);
/* Main scheduler loop */
while(1) {
check_maca();
if(uart1_input_handler != NULL) {
if(uart1_can_get()) {
uart1_input_handler(uart1_getc());
}
}
process_run();
}
return 0;
}
开发者ID:denghongcai,项目名称:6lbr,代码行数:90,代码来源:main.c
示例11: main
/*---------------------------------------------------------------------------*/
int
main(void)
{
/*
* Initialize hardware.
*/
halInit();
clock_init();
uart1_init(115200);
// Led initialization
leds_init();
INTERRUPTS_ON();
PRINTF("\r\nStarting ");
PRINTF(CONTIKI_VERSION_STRING);
PRINTF(" on %s\r\n",boardDescription->name);
/*
* Initialize Contiki and our processes.
*/
process_init();
#if WITH_SERIAL_LINE_INPUT
uart1_set_input(serial_line_input_byte);
serial_line_init();
#endif
process_start(&etimer_process, NULL);
ctimer_init();
rtimer_init();
netstack_init();
set_rime_addr();
PRINTF("ACK enable=%u %s %s, channel check rate=%luHz, check interval %ums, clock second=%u, radio channel %u\r\n",
ST_RadioAutoAckEnabled(), NETSTACK_MAC.name, NETSTACK_RDC.name,
CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1:
NETSTACK_RDC.channel_check_interval()), NETSTACK_RDC.channel_check_interval(), CLOCK_SECOND,
RF_CHANNEL);
#if !UIP_CONF_IPV6
ST_RadioEnableAutoAck(FALSE); // Because frames are not 802.15.4 compatible.
ST_RadioEnableAddressFiltering(FALSE);
#endif
ST_RadioEnableAutoAck(TRUE);
procinit_init();
energest_init();
ENERGEST_ON(ENERGEST_TYPE_CPU);
autostart_start(autostart_processes);
watchdog_start();
while(1){
int r;
do {
/* Reset watchdog. */
watchdog_periodic();
r = process_run();
} while(r > 0);
ENERGEST_OFF(ENERGEST_TYPE_CPU);
//watchdog_stop();
ENERGEST_ON(ENERGEST_TYPE_LPM);
/* Go to idle mode. */
halSleepWithOptions(SLEEPMODE_IDLE,0);
/* We are awake. */
//watchdog_start();
ENERGEST_OFF(ENERGEST_TYPE_LPM);
ENERGEST_ON(ENERGEST_TYPE_CPU);
}
}
开发者ID:chianhla,项目名称:sandbox,代码行数:92,代码来源:contiki-main.c
示例12: main
int
main(int argc, char **argv)
{
contiki_argc = argc;
contiki_argv = argv;
/* The first one or two args are used for wpcap configuration */
/* so this needs to be "removed" from contiki_args. */
contiki_argc--;
contiki_argv++;
#ifdef UIP_FALLBACK_INTERFACE
contiki_argc--;
contiki_argv++;
#endif
process_init();
procinit_init();
#ifdef PLATFORM_BUILD
program_handler_add(&directory_dsc, "Directory", 1);
program_handler_add(&www_dsc, "Web browser", 1);
#endif /* PLATFORM_BUILD */
autostart_start(autostart_processes);
#if !NETSTACK_CONF_WITH_IPV6
{
uip_ipaddr_t addr;
uip_ipaddr(&addr, 192,168,0,111);
uip_sethostaddr(&addr);
log_message("IP Address: ", inet_ntoa(*(struct in_addr*)&addr));
uip_ipaddr(&addr, 255,255,255,0);
uip_setnetmask(&addr);
log_message("Subnet Mask: ", inet_ntoa(*(struct in_addr*)&addr));
uip_ipaddr(&addr, 192,168,0,1);
uip_setdraddr(&addr);
log_message("Def. Router: ", inet_ntoa(*(struct in_addr*)&addr));
uip_ipaddr(&addr, 192,168,0,1);
uip_nameserver_update(&addr, UIP_NAMESERVER_INFINITE_LIFETIME);
log_message("DNS Server: ", inet_ntoa(*(struct in_addr*)&addr));
}
#else /* NETSTACK_CONF_WITH_IPV6 */
#if !UIP_CONF_IPV6_RPL
#ifdef HARD_CODED_ADDRESS
uip_ipaddr_t ipaddr;
uiplib_ipaddrconv(HARD_CODED_ADDRESS, &ipaddr);
if ((ipaddr.u16[0]!=0) || (ipaddr.u16[1]!=0) || (ipaddr.u16[2]!=0) || (ipaddr.u16[3]!=0)) {
#if UIP_CONF_ROUTER
uip_ds6_prefix_add(&ipaddr, UIP_DEFAULT_PREFIX_LEN, 0, 0, 0, 0);
#else /* UIP_CONF_ROUTER */
uip_ds6_prefix_add(&ipaddr, UIP_DEFAULT_PREFIX_LEN, 0);
#endif /* UIP_CONF_ROUTER */
#if !UIP_CONF_IPV6_RPL
uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
uip_ds6_addr_add(&ipaddr, 0, ADDR_AUTOCONF);
#endif
}
#endif /* HARD_CODED_ADDRESS */
#endif
#endif
while(1) {
process_run();
etimer_request_poll();
/* Allow user-mode APC to execute. */
SleepEx(10, TRUE);
#ifdef PLATFORM_BUILD
if(console_resize()) {
ctk_restore();
}
#endif /* PLATFORM_BUILD */
}
}
开发者ID:kerlyn-bsd3,项目名称:contiki,代码行数:83,代码来源:contiki-main.c
示例13: main
//#pragma FUNC_NEVER_RETURNS(main);
void
main(void)
{
_disable_interrupts();
msp430_init();
clock_init();
// initialize uip_variables
memset(uip_buf, 0, UIP_CONF_BUFFER_SIZE);
uip_len = 0;
leds_init();
buttons_init();
usb_init_proc();
/* Create MAC addresses based on a hash of the unique id (wafle id + x-pos
* in wafel + y-pos in wafel).
* We use rime addresses in order to use useful rime address handling
* functions.
*/
/* The sicslowmac layer requires the mac address to be placed in the global
* (extern) variable rimeaddr_node_addr (declared rimeaddr.h).
*/
rimeaddr_node_addr.u8[0] = NODE_BASE_ADDR0;
rimeaddr_node_addr.u8[1] = NODE_BASE_ADDR1;
rimeaddr_node_addr.u8[2] = NODE_BASE_ADDR2;
rimeaddr_node_addr.u8[3] = NODE_BASE_ADDR3;
rimeaddr_node_addr.u8[4] = NODE_BASE_ADDR4;
rimeaddr_node_addr.u8[5] = *((unsigned char*)(WAFERID+2)); // lowest byte of wafer id
rimeaddr_node_addr.u8[6] = *((unsigned char*)(WAFERIPOSX)); // lowest byte of x-pos in wafer
rimeaddr_node_addr.u8[7] = *((unsigned char*)(WAFERIPOSY)); // lowest byte of y-pos in wafer
/* The following line sets the link layer address. This must be done
* before the tcpip_process is started since in its initialization
* routine the function uip_netif_init() will be called from inside
* uip_init()and there the default IPv6 address will be set by combining
* the link local prefix (fe80::/64)and the link layer address.
*/
rimeaddr_copy((rimeaddr_t*)&uip_lladdr.addr, &rimeaddr_node_addr);
/* Initialize the process module */
process_init();
/* etimers must be started before ctimer_init */
// clock_init();
process_start(&etimer_process, NULL);
/* Start radio and radio receive process */
if (NETSTACK_RADIO.init() == FAILED) {
led_on(LED_RED);
_disable_interrupts();
LPM4; // die
}
/* Initialize stack protocols */
queuebuf_init();
NETSTACK_RDC.init();
NETSTACK_MAC.init();
NETSTACK_NETWORK.init();
/* Initialize tcpip process */
process_start(&tcpip_process, NULL);
/* Initialize our application(s) */
process_start(&rfid_find_tags, NULL);
process_start(&usb_input_process, NULL);
process_start(&coap_app_client, NULL);
//process_start(&coap_app, NULL);
/* Enter main loop */
while(1) {
/* poll every running process which has requested to be polled */
process_run();
/*
* Enter low power mode 3 safely. The CPU will wake up in the timer
* interrupt or whenever a packet arrives. In the timer interrupt
* routine, we check wether an etimer has expired and, if so,
* we call the etimer_request_poll() function
*/
//LPM3;
}
}
开发者ID:serflosa,项目名称:torrija_gateway,代码行数:83,代码来源:contiki-torrija-host-main.c
示例14: main
//.........这里部分代码省略.........
/* initialize the netstack */
netstack_init(); // NET协议栈初始化
set_rime_addr(); // 设置RIME地址,相当于设置IP地址
#if BUTTON_SENSOR_ON || ADC_SENSOR_ON
process_start(&sensors_process, NULL);
BUTTON_SENSOR_ACTIVATE();
ADC_SENSOR_ACTIVATE();
#endif
#if UIP_CONF_IPV6 // 非常重要,启动TCPIP查询任务
memcpy(&uip_lladdr.addr, &rimeaddr_node_addr, sizeof(uip_lladdr.addr));
queuebuf_init();
process_start(&tcpip_process, NULL);
#endif /* UIP_CONF_IPV6 */
#if VIZTOOL_CONF_ON
process_start(&viztool_process, NULL);
#endif
energest_init(); // 能量估计初始化,但是该功能未被打开
ENERGEST_ON(ENERGEST_TYPE_CPU); // 该功能未被打开
autostart_start(autostart_processes); // 启动被定义为自动启动的任务
watchdog_start(); // 看门狗初始化
fade(LEDS_YELLOW); // 黄色LED闪烁,完成所有初始化工作
while(1) {
do {
/* Reset watchdog and handle polls and events */
watchdog_periodic(); // 喂狗操作
r = process_run();
} while(r > 0);
#if SHORTCUTS_CONF_NETSTACK // 循环查询无线输入数据包长度 tcpip_process
len = NETSTACK_RADIO.pending_packet();
if(len) {
packetbuf_clear();
len = NETSTACK_RADIO.read(packetbuf_dataptr(), PACKETBUF_SIZE);
if(len > 0) {
packetbuf_set_datalen(len);
NETSTACK_RDC.input();
}
}
#endif
#if LPM_MODE // 该宏被定义为0,没有休眠功能,以下代码均无效
#if (LPM_MODE==LPM_MODE_PM2)
SLEEP &= ~OSC_PD; /* Make sure both HS OSCs are on */
while(!(SLEEP & HFRC_STB)); /* Wait for RCOSC to be stable */
CLKCON |= OSC; /* Switch to the RCOSC */
while(!(CLKCON & OSC)); /* Wait till it's happened */
SLEEP |= OSC_PD; /* Turn the other one off */
#endif /* LPM_MODE==LPM_MODE_PM2 */
/*
* Set MCU IDLE or Drop to PM1. Any interrupt will take us out of LPM
* Sleep Timer will wake us up in no more than 7.8ms (max idle interval)
*/
SLEEPCMD = (SLEEPCMD & 0xFC) | (LPM_MODE - 1);
#if (LPM_MODE==LPM_MODE_PM2)
/*
* Wait 3 NOPs. Either an interrupt occurred and SLEEP.MODE was cleared or
* no interrupt occurred and we can safely power down
开发者ID:EmuxEvans,项目名称:contiki_cc2530_iar,代码行数:67,代码来源:contiki-main.c
示例15: initialize
/*-----------------------------Low level initialization--------------------*/
static void initialize(void) {
watchdog_init();
watchdog_start();
#if CONFIG_STACK_MONITOR
/* Simple stack pointer highwater monitor. The 'm' command in cdc_task.c
* looks for the first overwritten magic number.
*/
{
extern uint16_t __bss_end;
uint16_t p=(uint16_t)&__bss_end;
do {
*(uint16_t *)p = 0x4242;
p+=100;
} while (p<SP-100); //don't overwrite our own stack
}
#endif
/* Initialize hardware */
// Checks for "finger", jumps to DFU if present.
init_lowlevel();
/* Clock */
clock_init();
/* Leds are referred to by number to prevent any possible confusion :) */
/* Led0 Blue Led1 Red Led2 Green Led3 Yellow */
Leds_init();
Led1_on();
/* Get a random (or probably different) seed for the 802.15.4 packet sequence number.
* Some layers will ignore duplicates found in a history (e.g. Contikimac)
* causing the initial packets to be ignored after a short-cycle restart.
*/
ADMUX =0x1E; //Select AREF as reference, measure 1.1 volt bandgap reference.
ADCSRA=1<<ADEN; //Enable ADC, not free running, interrupt disabled, fastest clock
ADCSRA|=1<<ADSC; //Start conversion
while (ADCSRA&(1<<ADSC)); //Wait till done
PRINTD("ADC=%d\n",ADC);
random_init(ADC);
ADCSRA=0; //Disable ADC
#if USB_CONF_RS232
/* Use rs232 port for serial out (tx, rx, gnd are the three pads behind jackdaw leds */
rs232_init(RS232_PORT_0, USART_BAUD_57600,USART_PARITY_NONE | USART_STOP_BITS_1 | USART_DATA_BITS_8);
/* Redirect stdout to second port */
rs232_redirect_stdout(RS232_PORT_0);
#if ANNOUNCE
PRINTA("\n\n*******Booting %s*******\n",CONTIKI_VERSION_STRING);
#endif
#endif
/* rtimer init needed for low power protocols */
rtimer_init();
/* Process subsystem. */
process_init();
/* etimer process must be started before USB or ctimer init */
process_start(&etimer_process, NULL);
Led2_on();
/* Now we can start USB enumeration */
process_start(&usb_process, NULL);
/* Start CDC enumeration, bearing in mind that it may fail */
/* Hopefully we'll get a stdout for startup messages, if we don't already */
#if USB_CONF_SERIAL
process_start(&cdc_process, NULL);
{unsigned short i;
for (i=0;i<65535;i++) {
process_run();
watchdog_periodic();
if (stdout) break;
}
#if !USB_CONF_RS232
PRINTA("\n\n*******Booting %s*******\n",CONTIKI_VERSION_STRING);
#endif
}
#endif
if (!stdout) Led3_on();
#if RF230BB
#if JACKDAW_CONF_USE_SETTINGS
PRINTA("Settings manager will be used.\n");
#else
{uint8_t x[2];
*(uint16_t *)x = eeprom_read_word((uint16_t *)&eemem_channel);
if((uint8_t)x[0]!=(uint8_t)~x[1]) {
PRINTA("Invalid EEPROM settings detected. Rewriting with default values.\n");
get_channel_from_eeprom();
}
}
#endif
ctimer_init();
/* Start radio and radio receive process */
/* Note this starts RF230 process, so must be done after process_init */
//.........这里部分代码省略.........
开发者ID:SmallLars,项目名称:ba-codtls,代码行数:101,代码来源:contiki-raven-main.c
示例16: main
//.........这里部分代码省略.........
/* Initialize Joystick Inputs: */
PM5 |= BIT(5) | BIT(4) | BIT(3) | BIT(2) | BIT(1); /* Set pins as inputs. */
PU5 |= BIT(5) | BIT(4) | BIT(3) | BIT(2) | BIT(1); /* Enable internal pull-up resistors. */
/* Initialize LED outputs: */
#define BIT(n) (1 << (n))
PM12 &= ~BIT(0); /* LED1 */
PM4 &= ~BIT(3); /* LED2 */
PM1 &= ~BIT(6); /* LED3 */
PM1 &= ~BIT(5); /* LED4 */
PM0 &= ~BIT(6); /* LED5 */
PM0 &= ~BIT(5); /* LED6 */
PM3 &= ~BIT(0); /* LED7 */
PM5 &= ~BIT(0); /* LED8 */
#if UIP_CONF_IPV6
#if UIP_CONF_IPV6_RPL
printf(CONTIKI_VERSION_STRING " started with IPV6, RPL" NEWLINE);
#else
printf(CONTIKI_VERSION_STRING " started with IPV6" NEWLINE);
#endif
#else
printf(CONTIKI_VERSION_STRING " started" NEWLINE);
#endif
/* crappy way of remembering and accessing argc/v */
contiki_argc = argc;
contiki_argv = argv;
process_init();
process_start(&etimer_process, NULL);
ctimer_init();
set_rime_addr();
queuebuf_init();
netstack_init();
printf("MAC %s RDC %s NETWORK %s" NEWLINE, NETSTACK_MAC.name, NETSTACK_RDC.name, NETSTACK_NETWORK.name);
#if WITH_UIP6
memcpy(&uip_lladdr.addr, serial_id, sizeof(uip_lladdr.addr));
process_start(&tcpip_process, NULL);
printf("Tentative link-local IPv6 address ");
{
uip_ds6_addr_t *lladdr;
int i;
lladdr = uip_ds6_get_link_local(-1);
for(i = 0; i < 7; ++i) {
printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],
lladdr->ipaddr.u8[i * 2 + 1]);
}
/* make it hardcoded... */
lladdr->state = ADDR_AUTOCONF;
printf("%02x%02x" NEWLINE, lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
}
#else
process_start(&tcpip_process, NULL);
#endif
serial_line_init();
autostart_start(autostart_processes);
while(1) {
watchdog_periodic();
if(NETSTACK_RADIO.pending_packet()) {
int len;
packetbuf_clear();
len = NETSTACK_RADIO.read(packetbuf_dataptr(), PACKETBUF_SIZE);
if(len > 0) {
packetbuf_set_datalen(len);
NETSTACK_RDC.input();
}
}
while(uart0_can_getchar()) {
char c;
UART_RX_LED = 1;
c = uart0_getchar();
if(uart0_input_handler) {
uart0_input_handler(c);
}
}
UART_RX_LED = 0;
process_run();
etimer_request_poll();
HEARTBEAT_LED1 = flip_flop;
flip_flop = !flip_flop;
HEARTBEAT_LED2 = flip_flop;
}
return 0;
}
开发者ID:ustbgaofan,项目名称:contiki,代码行数:101,代码来源:contiki-main.c
示例17: main
/*---------------------------------Main Routine----------------------------*/
int
main(void)
{
/* GCC depends on register r1 set to 0 (?) */
asm volatile ("clr r1");
/* Initialize in a subroutine to maximize stack space */
initialize();
#if DEBUG
{struct process *p;
for(p = PROCESS_LIST();p != NULL; p = ((struct process *)p->next)) {
PRINTA("Process=%p Thread=%p Name=\"%s\" \n",p,p->thread,PROCESS_NAME_STRING(p));
}
}
#endif
while(1) {
process_run();
watchdog_periodic();
/* Print rssi of all received packets, useful for range testing */
#ifdef RF230_MIN_RX_POWER
uint8_t lastprint;
if (rf230_last_rssi != lastprint) { //can be set in halbb.c interrupt routine
PRINTA("%u ",rf230_last_rssi);
lastprint=rf230_last_rssi;
}
#endif
#if 0
/* Clock.c can trigger a periodic PLL calibration in the RF230BB driver.
* This can show when that happens.
*/
extern uint8_t rf230_calibrated;
if (rf230_calibrated) {
PRINTA("\nRF230 calibrated!\n");
rf230_calibrated=0;
}
#endif
#if TESTRTIMER
/* Timeout can be increased up to 8 seconds maximum.
* A one second cycle is convenient for triggering the various debug printouts.
* The triggers are staggered to avoid printing everything at once.
* My Jackdaw is 4% slow.
*/
if (rtimerflag) {
rtimer_set(&rt, RTIMER_NOW()+ RTIMER_ARCH_SECOND*1UL, 1,(void *) rtimercycle, NULL);
rtimerflag=0;
#if STAMPS
if ((rtime%STAMPS)==0) {
PRINTA("%us ",rtime);
if (rtime%STAMPS*10) PRINTA("\n");
}
#endif
rtime+=1;
#if PINGS && UIP_CONF_IPV6_RPL
extern void raven_ping6(void);
if ((rtime%PINGS)==1) {
PRINTA("**Ping\n");
|
请发表评论