void main(void) { ///1. Standard Power-on routine (Clocks, Timers, IRQ's, etc) ///2. Standard OpenTag Init (most stuff actually will not be used) platform_poweron(); platform_init_OT(); ///3. Initialize the User Applet & interrupts app_init(); ///4a. The device will wait (and block anything else) until you connect /// it to a valid console app. mpipedrv_standby(); ///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(); } }
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(); } }
//API wrappers void otapi_poweron() { platform_poweron(); }