User defined event handling functions
A user-defined event handling function is a function defined by the user for the purpose of performing event handling in the form of a callback from TWENET. Although we call them functions, they behave as state transition machines.
Register
Up to two user-defined event processing functions can be registered with ToCoNet_Event_Register_State_Machine()
.
User-defined event handling functions must be registered to receive E_EVENT_START_UP
events.
The notified event
The following three events are notified. Other events are passed on as function callback calls by the ToCoNet_Event_Process()
function.
E_EVENT_START_UP : on start-up
E_EVENT_TICK_TIMER : every tick timer fired (4ms default)
E_EVENT_TICK_SECOND : every 1sec
The following code is an example of communicating the completion of a transmission to the user-defined event processing function vProcessEvCore()
.
Calling vProcessEvCore()
without using ToCoNet_Event_Process()
should be avoided. The state transitions shown in the flow diagram will not take place and there will be inconsistencies in the information contained in the management structure of the user-defined event processing function.
It must not be called from an interrupt handler.
About state transitions
The state machine of user-defined event handling functions starts from E_STATE_IDLE (0)
.
When a user-defined event processing function is called, a state transition is declared by calling the ToCoNet_Event_SetState()
function. After declaring the state transition and exiting the user defined event handling function, the function is called again with the E_EVENT_NEW_STATE
event as a parameter. This process is continuous as long as the state transition continues (flow diagram).
You can keep the previous state by calling ToCoNet_Event_vKeepStateOnRamHoldSleep()
before sleep (hold RAM), and receive E_EVENT_START_UP
event after sleep is restored.
最終更新