# SPI (メンバ関数版)

`begin()`メソッドによりハードウェアの初期化を行った後、`beginTransaction()`によりバスの読み書きができるようになります。`beginTransaction()`を実行するとSPIのセレクトピンが選択されます。読み書きは`transfer()`関数を用います。SPIは読み出しと書き込みを同時に実行します。

### beginTransaction()

```cpp
void beginTransaction()
void beginTransaction(SPISettings settings)
```

バスの利用開始を行います。SPIのセレクトピンをセットします。

`settings`パラメータを与えて呼び出した場合は、バスの設定を行います。

### endTransaction()

```cpp
void endTransaction()
```

バスの利用を終了します。SPIのセレクトピンを解除します。

### transfer(), transfer16(), transfer32()

```cpp
inline uint8_t transfer(uint8_t data)
inline uint16_t transfer16(uint16_t data)
inline uint32_t transfer32(uint32_t data)
```

&#x20;バスの読み書きを行います。`trasnfer()`は8bit、`transfer16()`は16bit、`transfer32()`は32bitの転送を行います。


---

# 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://mwx.twelite.info/v0.1.5/api-reference/predefined_objs/spi/spi-member.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.
