RogiStandard-hal
STM32 向けサークル共通ライブラリ
読み取り中…
検索中…
一致する文字列を見つけられません
AirSolenoid.hpp
[詳解]
1#pragma once
2#include "main.h"
3#ifndef HAL_GPIO_MODULE_ENABLED
4#error "AirSolenoid には GPIO が必要です。CubeMX で GPIO を有効にしてコードを再生成してください。"
5#endif
6#include <cstdint>
7
8// 単純なGPIO駆動のエア電磁弁ドライバ
9// - begin(): 初期状態へ(安全のためOFF)
10// - set(true/false): ON/OFF 切替
11// - on()/off(): 明示的制御
12// - deviceID(): 任意の識別子(0/1など)
14public:
15 // コンストラクタ: 対象GPIOポート/ピン、論理極性(active_high)、任意のデバイスID
16 AirSolenoid(GPIO_TypeDef* port, uint16_t pin, bool active_high = true, uint8_t device_id = 0);
17
18 // 初期化: 出力を安全側(OFF)へ
19 void begin();
20
21 // true=ON, false=OFF
22 void set(bool on);
23
24 // 明示的ON/OFF(極性はactive_highに従う)
25 void on();
26 void off();
27
28 // 任意の識別子(配線系のスロット識別など)
29 uint8_t deviceID() const;
30
31private:
32 GPIO_TypeDef* port_;
33 uint16_t pin_;
34 bool active_high_;
35 uint8_t device_id_;
36};
void set(bool on)
uint8_t deviceID() const