Ejemplo n.º 1
0
void
platform_poweron() {
	ot_u32 prescaler = 32;

    /// Hardware turn-on stuff
    SystemInit();                   // comes from STLib, does lots of startup
    platform_init_busclk();         // extra bus clock setup not in SystemInit()
    platform_init_periphclk();      // Peripherals OpenTag cares about
    platform_init_interruptor();    // Interrupts OpenTag cares about
    systim_init((void*)&prescaler);        // Initialize GPTIM (to 1024 Hz)
    platform_init_gpio();           // Set up connections on the board
    platform_init_spi();            // initialize command interface to radio

#if ( defined(RADIO_DEBUG) || (OT_FEATURE(MPIPE) == ENABLED) )
    platform_uart_init();
#endif /* RADIO_DEBUG */
#if defined(RADIO_DEBUG)
    debug_uart_init();
#endif /* RADIO_DEBUG */

    rng_seed();

    /// Restore vworm (following save on shutdown)
    vworm_init();

#   if (OT_FEATURE(MPIPE) == ENABLED)
        /// Mpipe (message pipe) typically used for serial-line comm.
        mpipe_init(NULL);
#   endif
}
Ejemplo n.º 2
0
void main( void ) {
    
    /// Platform power-up initialization:
    platform_poweron();     // 1. Clocks, Timers, IRQ's, etc
    platform_init_gpio();   // 2. Not built into platform_poweron()
    platform_init_OT();     // 3. OpenTag module inits

    /// Set up the user timer (you can change this if you want).  This code is
    /// lifted from platform_CC430.c (platform_init_gptim)
    APPTIM->CTL    |= 0x0004;
    APPTIM->CTL     = (0x01C3 & 0x01E0);
    APPTIM->EX0     = (0x01C3 & 0x0007);
    APPTIM->CCR0    = 0;
    APPTIM->CTL    |= 0x0013;


    /// Bind the System RFA callbacks to use the red_ functions
    red_vector              = 0;
    sys.evt.RFA.init        = &red_init;
    sys.evt.RFA.terminate   = &red_terminate;
    
    /// Bind the api callback to our api-based app
    sys.loadapp             = &app_pingpong;
    
    
    /// Start the OpenTag Daemon:
    /// Run this once.  Afterward, it will automatically run whenever there is
    /// a GPTIM interrupt (usually TIM0A5).  OT manages this timer internally.
    platform_ot_run();
    
    
    /// Wait around until something interesting happens!
    /// - If you have code that runs in parallel, put it in here
    while (1) {
        my_local_services();
        SLEEP_MCU();
    }

}