void app_invoke(ot_u8 channel) { /// The "External Task" is the place where the kernel runs the main user app. /// Our app has 4 functions (call types). /// <LI> The task event state is set to 1. Event 0 is always Task-off, but /// otherwise each task manages its own event numbers </LI> /// <LI> We store the channel in the cursor, which is not being used otherwise. /// The Task "cursor" can be used for additional state control, beyond the /// event number. </LI> /// <LI> We give it a runtime reservation of 1 tick (it runs pretty fast). /// This is also short enough to pre-empt RX listening, but not RX data. /// Try changing to a higher number, and observing how the kernel /// manages this task. </LI> /// <LI> We give it a latency of 255. Latency is unimportant for run-once /// tasks, so giving it the max latency will prevent it from blocking /// any other tasks. </LI> /// <LI> We tell it to start ASAP (preemption delay parameter = 0) </LI> /// /// @note The latency parameter is mostly useful for protocol management, /// for which you probably want to enforce a request-response turnaround time. /// for processing and for iterative tasks it is not important: set to 255. /// sys_task_setevent(APP_TASK, 1); sys_task_setcursor(APP_TASK, channel); sys_task_setreserve(APP_TASK, 1); sys_task_setlatency(APP_TASK, 255); sys_preempt(APP_TASK, 0); }
void sub_mpipe_actuate(ot_u8 new_event, ot_u8 new_reserve, ot_uint new_nextevent) { /// Kernel should be pre-empted in order to cancel the currently scheduled /// task for MPipe and replace it with this one (if any task is scheduled). sys.task_MPA.event = new_event; sys.task_MPA.reserve = new_reserve; sys_preempt(&sys.task_MPA, new_nextevent); }
void network_sig_route(void* route, void* session) { /// network_sig_route() will have route >= 0 on successful request processing. /// "route" will always be set to -1, which will cause the Data Link Layer to /// ignore the rest of the session and keep listening (sniffing). static const ot_u8 unknown_rx[10] = "UNKNOWN_RX"; static const ot_u8 opentag_rx[10] = "OPENTAG_RX"; ot_u8* label; // A valid packet has been received. // You can look at the response in the TX Queue (and log it if you want). // We just log the request and mark it as known or unknown. if (*(ot_int*)route >= 0) { label = (ot_u8*)opentag_rx; } else { label = (ot_u8*)unknown_rx; } // Log the received packet data (with 10 character label) otapi_log_msg(MSG_raw, 10, rxq.length, label, rxq.front); // Turn on Green LED to indicate received packet // Activate the app task, which will turn off the LED in 30 ticks otapi_led1_on(); sys_task_setevent(APP_TASK, 1); sys_preempt(APP_TASK, 30); // Tell DLL to disregard session, no matter what. *(ot_int*)route = -1; }
void PALFI_WAKE_ISR(void) { /// In this demo the PALFI LF interface is not initialized. However, there are /// some switches (buttons) that are attached to the PaLFI core, and they use /// the same interrupt. Those buttons are attached. if (PALFI_WAKE_PORT->IFG & BOARD_SW2_PIN) { sys_task_setevent(PALFI_TASK, 2); sys_task_setreserve(PALFI_TASK, 64); sys_task_setlatency(PALFI_TASK, 255); sys_preempt(PALFI_TASK, 0); } //if (PALFI_WAKE_PORT->IFG & PALFI_WAKE_PIN) { // sys_task_setevent(PALFI_TASK, 1); //} PALFI_WAKE_PORT->IFG = 0; }
OT_WEAK ot_u16 otapi_start_dialog(ot_u16 timeout) { /// Stop any ongoing processes and seed the event for the event manager. The /// radio killer will work in all cases, but it is bad form to kill sessions /// that are moving data. if (timeout != 0) { dll.comm.tc = TI2CLK(timeout); } ///@todo update null radio driver to modern interface # ifndef __KERNEL_NONE__ if (radio.state != RADIO_Idle) { rm2_kill(); } # endif # ifndef __KERNEL_NONE__ sys.task_RFA.event = 0; sys_preempt(&sys.task_RFA, 0); # endif return 1; }
void app_invoke(ot_u8 call_type) { /// The "External Task" is the place where the kernel runs the main user app. /// Our app has 4 functions (call types). /// <LI> We give it a runtime reservation of 1 tick (it runs pretty fast). /// This is also short enough to pre-empt RX listening, but not RX data. /// Try changing to a higher number, and observing how the kernel /// manages this task. </LI> /// <LI> We give it a latency of 255. Latency is unimportant for run-once /// tasks, so giving it the max latency will prevent it from blocking /// any other tasks. </LI> /// <LI> We tell it to start ASAP (next = 0) </LI> /// /// @note The latency parameter is mostly useful for protocol management, /// for which you probably want to enforce a request-response turnaround time. /// for processing and basic, iterative tasks it is not important: set to 255. /// sys_task_setevent(OPMODE_TASK, call_type); sys_task_setreserve(OPMODE_TASK, 1); sys_task_setlatency(OPMODE_TASK, 255); sys_preempt(OPMODE_TASK, 0); }