/** * \brief Main function for CC26xx-based platforms * * The same main() is used for all supported boards */ int main(void) { /* Enable flash cache and prefetch. */ ti_lib_vims_mode_set(VIMS_BASE, VIMS_MODE_ENABLED); ti_lib_vims_configure(VIMS_BASE, true, true); ti_lib_int_master_disable(); /* Set the LF XOSC as the LF system clock source */ oscillators_select_lf_xosc(); lpm_init(); board_init(); gpio_interrupt_init(); leds_init(); /* * Disable I/O pad sleep mode and open I/O latches in the AON IOC interface * This is only relevant when returning from shutdown (which is what froze * latches in the first place. Before doing these things though, we should * allow software to first regain control of pins */ ti_lib_pwr_ctrl_io_freeze_disable(); fade(LEDS_RED); ti_lib_int_master_enable(); soc_rtc_init(); clock_init(); rtimer_init(); watchdog_init(); process_init(); random_init(0x1234); /* Character I/O Initialisation */ #if CC26XX_UART_CONF_ENABLE cc26xx_uart_init(); #endif serial_line_init(); printf("Starting " CONTIKI_VERSION_STRING "\n\r"); printf("With DriverLib v%u.%u\n\r", DRIVERLIB_RELEASE_GROUP, DRIVERLIB_RELEASE_BUILD); printf(BOARD_STRING "\n\r"); process_start(&etimer_process, NULL); ctimer_init(); energest_init(); ENERGEST_ON(ENERGEST_TYPE_CPU); fade(LEDS_YELLOW); printf(" Net: "); printf("%s\n\r", NETSTACK_NETWORK.name); printf(" MAC: "); printf("%s\n\r", NETSTACK_MAC.name); printf(" RDC: "); printf("%s", NETSTACK_RDC.name); if(NETSTACK_RDC.channel_check_interval() != 0) { printf(", Channel Check Interval: %u ticks", NETSTACK_RDC.channel_check_interval()); } printf("\n\r"); netstack_init(); set_rf_params(); #if NETSTACK_CONF_WITH_IPV6 memcpy(&uip_lladdr.addr, &linkaddr_node_addr, sizeof(uip_lladdr.addr)); queuebuf_init(); process_start(&tcpip_process, NULL); #endif /* NETSTACK_CONF_WITH_IPV6 */ fade(LEDS_GREEN); process_start(&sensors_process, NULL); autostart_start(autostart_processes); watchdog_start(); fade(LEDS_ORANGE); while(1) { uint8_t r; do { r = process_run(); watchdog_periodic(); } while(r > 0); /* Drop to some low power mode */ lpm_drop(); } }
/** * \brief Main routine for the cc2538dk platform */ int main(void) { nvic_init(); ioc_init(); sys_ctrl_init(); clock_init(); lpm_init(); rtimer_init(); gpio_init(); leds_init(); fade(LEDS_YELLOW); process_init(); watchdog_init(); button_sensor_init(); /* * Character I/O Initialisation. * When the UART receives a character it will call serial_line_input_byte to * notify the core. The same applies for the USB driver. * * If slip-arch is also linked in afterwards (e.g. if we are a border router) * it will overwrite one of the two peripheral input callbacks. Characters * received over the relevant peripheral will be handled by * slip_input_byte instead */ #if UART_CONF_ENABLE uart_init(0); uart_init(1); uart_set_input(SERIAL_LINE_CONF_UART, serial_line_input_byte); #endif #if USB_SERIAL_CONF_ENABLE usb_serial_init(); usb_serial_set_input(serial_line_input_byte); #endif serial_line_init(); INTERRUPTS_ENABLE(); fade(LEDS_GREEN); PUTS(CONTIKI_VERSION_STRING); PUTS(BOARD_STRING); PRINTF(" Net: "); PRINTF("%s\n", NETSTACK_NETWORK.name); PRINTF(" MAC: "); PRINTF("%s\n", NETSTACK_MAC.name); PRINTF(" RDC: "); PRINTF("%s\n", NETSTACK_RDC.name); /* Initialise the H/W RNG engine. */ random_init(0); udma_init(); process_start(&etimer_process, NULL); ctimer_init(); set_rf_params(); #if CRYPTO_CONF_INIT crypto_init(); crypto_disable(); #endif netstack_init(); #if NETSTACK_CONF_WITH_IPV6 memcpy(&uip_lladdr.addr, &linkaddr_node_addr, sizeof(uip_lladdr.addr)); queuebuf_init(); process_start(&tcpip_process, NULL); #endif /* NETSTACK_CONF_WITH_IPV6 */ adc_init(); process_start(&sensors_process, NULL); energest_init(); ENERGEST_ON(ENERGEST_TYPE_CPU); autostart_start(autostart_processes); watchdog_start(); fade(LEDS_ORANGE); while(1) { uint8_t r; do { /* Reset watchdog and handle polls and events */ watchdog_periodic(); r = process_run(); } while(r > 0); /* We have serviced all pending events. Enter a Low-Power mode. */ lpm_enter(); } }
/** * \brief Main function for CC26xx-based platforms * * The same main() is used for both Srf+CC26xxEM as well as for the SensorTag */ int main(void) { /* Set the LF XOSC as the LF system clock source */ select_lf_xosc(); /* * Make sure to open the latches - this will be important when returning * from shutdown */ ti_lib_pwr_ctrl_io_freeze_disable(); /* Use DCDC instead of LDO to save current */ ti_lib_pwr_ctrl_source_set(PWRCTRL_PWRSRC_DCDC); lpm_init(); board_init(); /* Enable flash cache and prefetch. */ ti_lib_vims_mode_set(VIMS_BASE, VIMS_MODE_ENABLED); ti_lib_vims_configure(VIMS_BASE, true, true); gpio_interrupt_init(); /* Clock must always be enabled for the semaphore module */ HWREG(AUX_WUC_BASE + AUX_WUC_O_MODCLKEN1) = AUX_WUC_MODCLKEN1_SMPH; leds_init(); fade(LEDS_RED); cc26xx_rtc_init(); clock_init(); rtimer_init(); watchdog_init(); process_init(); random_init(0x1234); /* Character I/O Initialisation */ #if CC26XX_UART_CONF_ENABLE cc26xx_uart_init(); cc26xx_uart_set_input(serial_line_input_byte); #endif serial_line_init(); printf("Starting " CONTIKI_VERSION_STRING "\n"); printf("With DriverLib v%u.%02u.%02u.%u\n", DRIVERLIB_MAJOR_VER, DRIVERLIB_MINOR_VER, DRIVERLIB_PATCH_VER, DRIVERLIB_BUILD_ID); printf(BOARD_STRING " using CC%u\n", CC26XX_MODEL_CPU_VARIANT); process_start(&etimer_process, NULL); ctimer_init(); energest_init(); ENERGEST_ON(ENERGEST_TYPE_CPU); fade(LEDS_YELLOW); printf(" Net: "); printf("%s\n", NETSTACK_NETWORK.name); printf(" MAC: "); printf("%s\n", NETSTACK_MAC.name); printf(" RDC: "); printf("%s", NETSTACK_RDC.name); if(NETSTACK_RDC.channel_check_interval() != 0) { printf(", Channel Check Interval: %u ticks", NETSTACK_RDC.channel_check_interval()); } printf("\n"); netstack_init(); set_rf_params(); #if NETSTACK_CONF_WITH_IPV6 memcpy(&uip_lladdr.addr, &linkaddr_node_addr, sizeof(uip_lladdr.addr)); queuebuf_init(); process_start(&tcpip_process, NULL); #endif /* NETSTACK_CONF_WITH_IPV6 */ fade(LEDS_GREEN); process_start(&sensors_process, NULL); autostart_start(autostart_processes); watchdog_start(); fade(LEDS_ORANGE); while(1) { uint8_t r; do { r = process_run(); watchdog_periodic(); } while(r > 0); /* Drop to some low power mode */ lpm_drop(); } }
int main(int argc, char **argv) { watchdog_init(); leds_init(); uart_init(115200); clock_init(); #if NETSTACK_CONF_WITH_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 contiki_argc = argc; contiki_argv = argv; process_init(); process_start(&etimer_process, NULL); ctimer_init(); rtimer_init(); set_rime_addr(); queuebuf_init(); set_rf_params(); netstack_init(); printf("MAC %s RDC %s NETWORK %s\n", NETSTACK_MAC.name, NETSTACK_RDC.name, NETSTACK_NETWORK.name); #if NETSTACK_CONF_WITH_IPV6 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 < 8; i++) { printf("%02x%02x%c", lladdr->ipaddr.u8[i * 2], lladdr->ipaddr.u8[i * 2 + 1], i == 7 ? '\n' : ':'); } /* make it hardcoded... */ lladdr->state = ADDR_AUTOCONF; } #elif NETSTACK_CONF_WITH_IPV4 process_start(&tcpip_process, NULL); #endif serial_line_init(); process_start(&sensors_process, NULL); autostart_start(autostart_processes); while(1) { watchdog_periodic(); process_run(); } return 0; }
/** * \brief Main routine for the OpenMote-CC2538 platforms */ int main(void) { nvic_init(); ioc_init(); sys_ctrl_init(); clock_init(); lpm_init(); rtimer_init(); gpio_init(); leds_init(); fade(LEDS_RED); process_init(); watchdog_init(); #if UART_CONF_ENABLE uart_init(0); uart_init(1); uart_set_input(SERIAL_LINE_CONF_UART, serial_line_input_byte); #endif #if USB_SERIAL_CONF_ENABLE usb_serial_init(); usb_serial_set_input(serial_line_input_byte); #endif i2c_init(I2C_SDA_PORT, I2C_SDA_PIN, I2C_SCL_PORT, I2C_SCL_PIN, I2C_SCL_NORMAL_BUS_SPEED); serial_line_init(); INTERRUPTS_ENABLE(); fade(LEDS_BLUE); PUTS(CONTIKI_VERSION_STRING); PUTS(BOARD_STRING); #if STARTUP_CONF_VERBOSE soc_print_info(); #endif random_init(0); udma_init(); process_start(&etimer_process, NULL); ctimer_init(); board_init(); #if CRYPTO_CONF_INIT crypto_init(); crypto_disable(); #endif netstack_init(); set_rf_params(); PRINTF("Net: "); PRINTF("%s\n", NETSTACK_NETWORK.name); PRINTF("MAC: "); PRINTF("%s\n", NETSTACK_MAC.name); PRINTF("RDC: "); PRINTF("%s\n", NETSTACK_RDC.name); #if NETSTACK_CONF_WITH_IPV6 memcpy(&uip_lladdr.addr, &linkaddr_node_addr, sizeof(uip_lladdr.addr)); queuebuf_init(); process_start(&tcpip_process, NULL); #endif /* NETSTACK_CONF_WITH_IPV6 */ process_start(&sensors_process, NULL); SENSORS_ACTIVATE(button_sensor); energest_init(); ENERGEST_ON(ENERGEST_TYPE_CPU); autostart_start(autostart_processes); watchdog_start(); fade(LEDS_GREEN); while(1) { uint8_t r; do { watchdog_periodic(); r = process_run(); } while(r > 0); lpm_enter(); } }