# イベント

## 組み込みイベント

| 定義                     | 解説                                                                                                                                                                                                 |
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| E\_EVENT\_START\_UP    | システム起動（またはスリープ復帰）時に発生します。イベント引数は EVARG\_START\_UP\_WAKEUP\_MASK または(EVARG\_START\_UP\_WAKEUP\_MASK \| EVARG\_START\_UP\_WAKEUP\_ RAMHOLD\_MASK) が与えられ、前者はDEEPスリープからの復帰、後者は通常のRAM保持スリープからの復帰を意味します。 |
| E\_EVENT\_NEW\_STATE   | 状態遷移したときに最初に呼ばれるイベントです。※ システム始動時には呼び出されません（START\_UPイベントが発生する）。イベント引数は未定義。                                                                                                                         |
| E\_EVENT\_TICK\_TIMER  | システムタイマー(4ms)毎に呼び出されます。イベント引数は未定義。※ システム内のモジュール処理が終わった後に呼ばれます。呼び出しはばらつきが発生するため、タイミングを優先したい処理は cbToCoNet\_u8HwInt() 中の割り込みハンドラ中の E\_AHI\_DEVICE\_TICK\_TIMER に記述します。                                |
| E\_EVENT\_TICK\_SECOND | １秒ごとに呼び出されます。イベント引数は未定義。                                                                                                                                                                           |
| E\_ORDER\_INITIALIZE   | 初期化を促すメッセージとして利用する。                                                                                                                                                                                |
| E\_ORDER\_KICK         | 開始を促すメッセージとして利用する。                                                                                                                                                                                 |

## ユーザ定義イベント

ユーザ定義のイベント名を用意する場合は、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" %}
enum を 16bit や 8bit に小さくするコンパイルオプションは適用しないでください。
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sdk.twelite.info/twelite-net-api-ref/yzaibento/ibento.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
