コード例 #1
0
ファイル: main.c プロジェクト: jpnorair/OpenTag
/** Application Main <BR>
  * ======================================================================
  */
void main(void) {
    ///1. Standard Power-on routine (Clocks, Timers, IRQ's, etc)
    ///2. Standard OpenTag Init (most stuff actually will not be used)
    otapi_poweron();
    otapi_init();

    ///3. Palfi Application Initialization
    ///   Palfi app acts as an interupt-driven thread.  An interrupt pre-empts
    ///   the kernel and seeds the thread.  After this, the kernel takes-over
    ///   the execution of the thread.  This function enables these driving
    ///   interrupts.
    palfi_init();

    ///4. Top-level application init
    ///   In this demo, the top-level application does very little.
    app_init();

    WAIT_FOR_MPIPE();

    ///4b. Load a message to show that main startup has passed
    OTAPI_LOG_MSG(MSG_utf8, 6, 26, (ot_u8*)"SYS_ON", (ot_u8*)"System on and Mpipe active");

    ///5. MAIN RUNTIME (post-init)  <BR>
    ///<LI> Use a main loop with platform_ot_run(), and nothing more. </LI>
    ///<LI> You could put code before or after sys_runtime_manager, which will
    ///     run before or after the (task + kernel).  If you do, keep the code
    ///     very short or else you are risking timing glitches.</LI>
    ///<LI> To run any significant amount of user code, use tasks. </LI>
    while(1) {
    	platform_ot_run();
    }
}
コード例 #2
0
ファイル: main.c プロジェクト: armint/OpenTag
/** Application Main <BR>
  * ======================================================================
  */
void main(void) {
    ///1. Standard Power-on routine (Clocks, Timers, IRQ's, etc)
    ///2. Standard OpenTag Init (most stuff actually will not be used)
    otapi_poweron();
    otapi_init();

    ///3. Palfi Application Initialization
    ///   Palfi app acts as an interupt-driven thread.  An interrupt pre-empts
    ///   the kernel and seeds the thread.  After this, the kernel takes-over
    ///   the execution of the thread.  This function enables these driving
    ///   interrupts.
    palfi_init();

    ///4. Top-level application init
    ///   In this demo, the top-level application does very little.
    app_init();

    OTAPI_LOG_MSG(MSG_utf8, 6, 26, (ot_u8*)"SYS_ON", (ot_u8*)"System on and Mpipe active");

    ///5. MAIN RUNTIME (post-init)  <BR>
    ///<LI> a. Pre-empt the kernel (first run)   </LI>
    ///<LI> b. Go to sleep; OpenTag kernel will run automatically in
    ///        the background  </LI>
    ///<LI> c. The kernel has a built-in applet loader.  It is the best way
    ///        to use applets that generate requests or manipulate the system.
    ///        The applets only load during full-idle, so time slotting or
    ///        any other type of MAC activity is not affected. </LI>
    ///<LI> d. 99.99% (or more) of the time, the kernel is not actually
    ///        running.  You can run parallel, local tasks alongside OpenTag
    ///        as long as they operate above priority 1.  (I/O is usually
    ///        priority 0 and kernel is always priority 1) </LI>
    otapi_preempt();
    while(1) {
        app_manager();
        app_sleep();
    }

    ///6. Note on manually pre-empting the kernel for you own purposes:
    ///   It can be done (many internal tasks do it), but be careful.
    ///   It is recommended that you only do it when sys.mutex <= 1
    ///   (i.e. no radio data transfer underway).  One adaptation of
    ///   this demo is to have the mode-switching applets pre-empt the
    ///   kernel (it works fine, but you need to make your own loader
    ///   instead of using sys.loadapp).
}