Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: F446_DSP_Oscilloscope Demo_DSP_ADDA_Dual TrG_Oscilloscope
DSP_AdcDualBase.hpp
00001 //---------------------------------------------------------- 00002 // STM32F446 の ADC2, ADC3 を使って同時に AD 変換を開始し, 00003 // アナログ信号を入力するための抽象クラス(ヘッダ) 00004 // CH1 は ADC2 を使用 00005 // CH2 は ADC3 を使用 00006 // Read(), Write() の引数: 00007 // 第一引数:CH1,第二引数:CH2 00008 // 00009 // 2020/11/07, Copyright (c) 2020 MIKAMI, Naoki 00010 //---------------------------------------------------------- 00011 00012 #include "mbed.h" 00013 #include "PeripheralPins.h" // PinMap_ADC で使用 00014 // PeripheralPins.c が含まれるディレクトリ: 00015 // mbed-dev\targets\TARGET_STM\TARGET_STM32F4\ 00016 // TARGET_STM32F446xE\TARGET_NUCLEO_F446RE 00017 00018 #ifndef STM32F446xx 00019 #error Select NUCLEO-F446RE. 00020 #endif 00021 00022 #ifndef F446_ADC_DUAL_HPP 00023 #define F446_ADC_DUAL_HPP 00024 00025 namespace Mikami 00026 { 00027 class DspAdcDualBase 00028 { 00029 public: 00030 // コンストラクタ 00031 // fSampling 標本化周波数 [kHz] 00032 // pinCh1 チャンネル 1 に対応する入力ピンの名前 00033 // pinCh2 チャンネル 2 に対応する入力ピンの名前 00034 DspAdcDualBase(float fSampling, PinName pinCh1, PinName pinCh2); 00035 00036 virtual ~DspAdcDualBase() {} 00037 00038 // AD 変換された値を読み込む 00039 // -1.0f <= AD変換された値 < 1.0f 00040 virtual void Read(float &ad1, float &ad2) const = 0; // 純粋仮想関数 00041 00042 // AD 変換器の外部トリガに使うタイマ (TIM8) の設定 00043 // fSampling 標本化周波数 [kHz] 00044 void SetFs(float fSampling); 00045 00046 protected: 00047 ADC_TypeDef* adcCh1_; // チャンネル 1 の AD 変換器に対応する構造体のポインタ 00048 ADC_TypeDef* adcCh2_; // チャンネル 2 の AD 変換器に対応する構造体のポインタ 00049 00050 float ToFloat(uint16_t x) const { return AMP_*(x - 2048); } 00051 00052 private: 00053 static const float AMP_ = 1.0f/2048.0f; 00054 00055 // AD 変換器の初期設定 00056 void Initialize(ADC_TypeDef* adc, PinName pin); 00057 00058 // pin に対応する AD 変換器が存在することを確認する 00059 bool PinmapMatch(PinName pin, ADC_TypeDef* const adc); 00060 00061 // コピー・コンストラクタ,代入演算子の禁止のため 00062 DspAdcDualBase(const DspAdcDualBase&); 00063 DspAdcDualBase& operator=(const DspAdcDualBase&); 00064 }; 00065 } 00066 #endif // F446_ADC_DUAL_HPP
Generated on Tue Jul 19 2022 03:14:12 by
