# Events

## Built-on events

| Name                   | Remark                                                                                                                                                                                                                                                                                                                                    |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| E\_EVENT\_START\_UP    | This event occurs when the system is woken up (or wakes up from sleep). The event argument is given as `EVARG_START_UP_WAKEUP_MASK` or `(EVARG_START_UP_WAKEUP_MASK \| EVARG_START_UP_WAKEUP_ RAMHOLD_MASK)`, the former means return from DEEP sleep, the latter means return from normal RAM hold sleep.                                |
| E\_EVENT\_NEW\_STATE   | This is the first event called when a state transition occurs. It is not called when the system starts (START\_UP event occurs). The event argument is undefined.                                                                                                                                                                         |
| E\_EVENT\_TICK\_TIMER  | Called every system timer (4ms, as default). The event argument is undefined. It is called after the module processing in the system is finished. Because of the variability of the calls, processes which require priority in timing should be described in `E_AHI_DEVICE_TICK_TIMER` in the interrupt handler in `cbToCoNet_u8HwInt()`. |
| E\_EVENT\_TICK\_SECOND | Called every second. The event argument is undefined.                                                                                                                                                                                                                                                                                     |
| E\_ORDER\_INITIALIZE   | Use this as a message to encourage initialization.                                                                                                                                                                                                                                                                                        |
| E\_ORDER\_KICK         | Use this as a message to encourage people to start.                                                                                                                                                                                                                                                                                       |

## User-defined events

If you prepare user-defined event names, assign values after `ToCoNet_EVENT_APP_BASE`.

```c
typedef enum
{
	E_EVENT_APP_BASE = ToCoNet_EVENT_APP_BASE,
    E_EVENT_TICK_A,
    E_EVENT_SCAN_FINISH,
    E_EVENT_SLAVE_CONF_FAIL,
    E_EVENT_SLEEP_REQUEST
} teEventApp;
```

{% hint style="warning" %}
Do not apply the compile option to reduce the enum to 16 or 8 bits.
{% endhint %}
