STM32F446 の内蔵 ADC, DAC を 2 チャンネルで使うためのライブラリ.このライブラリを登録した際のプログラム: Demo_DSP_ADDA_Dual. Library for build-in ADC and DAC in STM32F446 using with dual channels.
Dependents: F446_DSP_Oscilloscope Demo_DSP_ADDA_Dual TrG_Oscilloscope
Diff: DSP_AdcDualIntr.hpp
- Revision:
- 0:c02c700a8ecf
- Child:
- 1:e1c5baa559de
diff -r 000000000000 -r c02c700a8ecf DSP_AdcDualIntr.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DSP_AdcDualIntr.hpp Tue Sep 22 04:52:53 2020 +0000 @@ -0,0 +1,55 @@ +//------------------------------------------------------------- +// STM32F446 内蔵 ADC を割り込み方式で使うための派生クラス +// 基底クラス: DspAdcDual_Base +// +// 2020/09/22, Copyright (c) 2020 MIKAMI, Naoki +//------------------------------------------------------------- + +#include "DSP_AdcDualBase.hpp" + +#ifndef DSP_ADC_DUAL_INTERRUPT_HPP +#define DSP_ADC_DUAL_INTERRUPT_HPP + +namespace Mikami +{ + class DspAdcDualIntr : public DspAdcDualBase + { + public: + // コンストラクタ + // fSampling 標本化周波数 [kHz] + // pinCh1 チャンネル 1 に対応する入力ピンの名前 + // pinCh2 チャンネル 2 に対応する入力ピンの名前 + DspAdcDualIntr(float fSampling, PinName pinCh1, PinName pinCh2) + : DspAdcDualBase(fSampling, pinCh1, pinCh2) + { adcCh1_->CR1 |= ADC_CR1_EOCIE; } + + virtual ~DspAdcDualIntr() {} + + // AD 変換された値を読み込む + // -1.0f <= AD変換された値 < 1.0f + virtual void Read(float &ad1, float &ad2) const + { + ad1 = ToFloat(adcCh1_->DR); + ad2 = ToFloat(adcCh2_->DR); + } + + // 割り込みベクタの設定と ADC 割り込みの有効化 + void SetIntrVec(void (*Func)()) + { + NVIC_SetVector(ADC_IRQn, (uint32_t)Func); // See "cmsis_nvic.h" + NVIC_EnableIRQ(ADC_IRQn); // See "core_cm4.h" + } + + // ADC 割込みを有効にする + void EnableAdcIntr() { NVIC_EnableIRQ(ADC_IRQn); } + + // ADC 割込みを無効にする + void DisableAdcIntr() { NVIC_DisableIRQ(ADC_IRQn); } + +private: + // コピー・コンストラクタ,代入演算子の禁止のため + DspAdcDualIntr(const DspAdcDualIntr&); + DspAdcDualIntr& operator=(const DspAdcDualIntr&); + }; +} +#endif // DSP_ADC_DUAL_INTERRUPT_HPP \ No newline at end of file