/** * \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 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(); } }