CQ出版社セミナ "実習・Armマイコン内蔵ペリフェラルを活用するためのC++プログラミング" で使う外付け回路のテスト
Dependencies: mbed UIT_SetOutputPortType UIT_AQM1602 UIT_ADT7410
PushButton/PushButton.cpp
- Committer:
- MikamiUitOpen
- Date:
- 2020-03-03
- Revision:
- 0:8c850cf6285d
- Child:
- 1:0a21041026c7
File content as of revision 0:8c850cf6285d:
//---------------------------------------------------------------- // InterruptIn, Timeout を利用してチャタリングを防止するクラス // 割込みサービス・ルーチンは非 static 関数にしている // // 2019/02/16, Copyright (c) 2019 MIKAMI, Naoki //---------------------------------------------------------------- #include "PushButton.hpp" using namespace Mikami; // コンストラクタ PushButton::PushButton(PinName pin, PinMode mode, RiseFall rf, void (*Func)(), float time) : pbSw_(InterruptIn(pin, mode)), fp_(Func), time_(time) { if (rf == RISE) pbSw_.rise(callback(this, &PushButton::IsrIntrIn)); else pbSw_.fall(callback(this, &PushButton::IsrIntrIn)); } // InterruptIn の割込みサービス・ルーチン void PushButton::IsrIntrIn() { fp_(); // コンストラクタの引数で与えられた関数が実行される pbSw_.disable_irq(); enabler_.attach(callback(this, &PushButton::IsrTimeout), time_); } // Timeout の割込みサービス・ルーチン void PushButton::IsrTimeout() { pbSw_.enable_irq(); }