📄 main.c
字号:
// This file is part of MANTIS OS, Operating System// See http://mantis.cs.colorado.edu///// Copyright (C) 2003,2004,2005 University of Colorado, Boulder//// This program is free software; you can redistribute it and/or// modify it under the terms of the mos license (see file LICENSE)/* Project Mantis File: mantis.c Author: Jeff Rose Date: 1-25-03 This is where it all starts, and ends.*//** @file main.c * @brief This is where it all starts, and ends. * @author Jeff Rose * @date 01/25/2003 */#include "mos.h"#include <stdlib.h>#ifndef PLATFORM_LINUX#if defined(PLATFORM_MICA2) || defined(PLATFORM_MICA2DOT)#include "cc1000_raw.h"#include "cc1000_tdma.h"#include "cc1000_csma.h"#endif#if defined(PLATFORM_MICAZ) || defined(PLATFORM_TELOSB)#include "cc2420.h"#endif#if defined(PLATFORM_TELOSB)#include "telos-flash.h"#endif#if defined(ARCH_AVR)#include "avr-eeprom.h"#include "avr-adc.h"#include "atmel-flash.h"#include "avr-i2c.h"#include "avr-rssi.h"#endif#if defined(PLATFORM_MICA_ANY)#include "mica2-ultrasound.h"#include "mica2-light-temp.h"#include "mica2-sounder.h"#include "mica2-battery.h"#include "mica2-magnet.h"#include "mica2-accel.h"#include "mica2-mic.h"#include "mica2-id.h"#endif#if defined(ARCH_MICRO)#include "adc.h"#endif#include "node_id.h"#include "uart.h"#include "dev.h"#include "printf.h"#include "loopback.h"#include "dev-loopback.h"#endif#ifdef PLATFORM_LINUX#include "arg.h"#include "gevent.h"#include <stdio.h>#define START_STACK_SIZE 0#include "serial.h"#include "terminal.h"//#include "udp.h"#include "xmos_radio.h"#include "xmos-flash.h"#endif#include "led.h"#include "msched.h"#include "com.h"#include "clock.h"/** @brief Application's start function. */extern void start(void);/** @brief preStart() is the function for the startup thread, which is the * one spawned by main(). * * It does all the initialization that needs to happen after the * kernel is up and running, and then it calls the application start function. */void pre_start(void){ //TODO: this should somehow be auto-generated#ifdef PLATFORM_LINUX mos_node_id_init(); // must be called before gevent_init () gevent_init(); serial_init(); terminal_init(); //udp_init(); xmos_radio_init(); // gevent_init() must be called first xmos_flash_init(); // gevent_init() must be called first #elif defined(ARCH_MICRO) adc_init(); #if defined(PLATFORM_MICA2) || defined(PLATFORM_MICA2DOT)#if defined(AVR_RSSI) || !defined(SCONS) avr_rssi_init();#endif#endif //mica2_magnet_init(); printf_init(); //mica2_ultrasound_init(); //dev_loopback_init(); //com_loopback_init(); PLAT_INIT(); uart_init();#if defined(ARCH_AVR) avr_eeprom_init(); avr_i2c_init(); #if defined(PLATFORM_MICA_ANY) #if defined(MICA2_LIGHT_TEMP) || !defined(SCONS) mica2_light_temp_init();#endif#if defined(MICA2_MIC) || !defined(SCONS) mica2_mic_init();#endif#if defined(MICA2_ACCEL) || !defined(SCONS) mica2_accel_init();#endif#if defined(MICA2_BATTERY) || !defined(SCONS) mica2_battery_init();#endif#endif //if platform mica2, mica2dot, micaz #endif //if defined(ARCH_AVR) #if defined(PLATFORM_MICA2) || defined (PLATFORM_MICAZ) atmel_flash_init();#if defined(MICA2_ID) || !defined(SCONS) mica2_id_init(); #endif#if defined(MICA2_SOUNDER) || !defined(SCONS) mica2_sounder_init();#endif mos_node_id_init();#endif // MAC layer //which MAC to use is defined in com.h #if defined(PLATFORM_MICA2) || defined(PLATFORM_MICA2DOT) #ifdef CC1000_RAW cc1000_raw_init();#endif #ifdef CC1000_CSMA cc1000_csma_init();#endif #ifdef CC1000_CSMA_ACK cc1000_csma_ack_init();#endif #ifdef CC1000_BMAC cc1000_bmac_init();#endif #ifdef CC1000_TDMA cc1000_tdma_init(mos_node_id_get());#endif #endif /* PLATFORM_MICA2 / PLATFORM_MICA2DOT */ clock_init(); #ifdef PLATFORM_TELOSB kernel_timer_init();#endif #if defined(PLATFORM_MICAZ) || defined(PLATFORM_TELOSB)#if defined(CC2420) || !defined(SCONS) cc2420_init();#endif#endif#if defined(PLATFORM_TELOSB) st_flash_init(); sht11_init(); mos_node_id_init();#endif #ifdef PLATFORM_AVRDEV#if defined(CC2420) || !defined(SCONS) maxstream_init();#endif#endif // seed the rng srandom(mos_node_id_get()); #endif /* ARCH_MICRO */#ifdef PLATFORM_MICA_ANY //FIXME: light and temp won't right work unless we read from another ADC //driver first uint8_t val;#warning ADC Hack dev_read(DEV_MICA2_ACCEL_Y, &val, sizeof(val));#endif start();#ifdef PLATFORM_LINUX mos_thread_suspend(); //fixes threading issue with freebsd#endif}/** @brief main function, inits the kernel and spawns the start thread. */#ifdef PLATFORM_LINUXint main(int argc, char *argv[]){ arg_init(argc,argv);#elseint main(void){#endif sched_init(); //init scheduler--THIS MUST BE FIRST led_init(); //init leds early, to allow led debugging elsewhere com_init(); //init com system mos_thread_new(pre_start, START_STACK_SIZE, PRIORITY_NORMAL); //start the scheduler (never returns) mos_sched_start(); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -