PinOut: I2Cn_SCL & I2Cn_SDA
NVIC Settings:
I2Cn interrupt: Enable
template <class T>
T: 送受信するデータ型
I2C_Master_IT( I2C_HandleTypeDef *hi2c );
I2C_Master_IT( I2C_HandleTypeDef &hi2c );
ピンを設定します
// 例 I2C_Master_IT<uint16_t> master(hi2c1); I2C_Master_IT<uint16_t> master(&hi2c1);
void init() noexcept;再初期化します
// 例 master.init();
HAL_StatusTypeDef transmit( uint8_t target, const T &data ) const noexcept;HAL_I2C_Master_Transmit_IT() の結果を返します
// 例 uint16_t data = 0xAC; master.transmit(0x02, data); master.transmit(0x02, 0x35); // 変数ではなくリテラルも使用可能
HAL_StatusTypeDef receive( uint8_t target, T &data ) const noexcept;HAL_I2C_Master_Receive_IT() の結果を返します
// 例 uint16_t data; master.receive(0x02, data);
void setTxCallback( std::function<void()> function ) noexcept;送信完了時の割り込み関数を設定します
// 例 master.setTxCallback([]{ logger.println("Tx\n"); });
void setRxCallback( std::function<void()> function ) noexcept;受信完了時の割り込み関数を設定します
// 例 master.setRxCallback([]{ logger.println("Rx\n"); });
void setErrorCallback( std::function<void()> function ) noexcept;エラー取得時の割り込み関数を設定します
// 例 slave.setErrorCallback([]{ logger.println("Error"); });