Added one channel mode
Dependents: CW_Decoder_using_FFT_on_F446
Fork of F446_AD_DA by
F446_ADC.hpp
- Committer:
- MikamiUitOpen
- Date:
- 2016-11-11
- Revision:
- 0:c945b4fe9a48
- Child:
- 1:6b9f2af6613d
File content as of revision 0:c945b4fe9a48:
//---------------------------------------------------------- // Simultanuous AD Conversion by polling using // ADC2 and ADC3 on STM32F446 ---- Header // // STM32F446 の ADC2, ADC3 を使って同時に AD 変換を開始し, // ポーリングによりアナログ信号を入力するクラス(ヘッダ) // A0 (PA_0) : ADC2 CH0 // A1 (PA_1) : ADC3 CH1 // // 2016/11/10, Copyright (c) 2016 MIKAMI, Naoki //---------------------------------------------------------- #include "mbed.h" #ifndef STM32F446xx #error Select STM32F446. #endif #ifndef F446_ADC_DUAL_HPP #define F446_ADC_DUAL_HPP namespace Mikami { class AdcDual { public: // Constructor // frequency: 標本化周波数 explicit AdcDual(int frequency); // -1.0f <= data1, data2 <= 1.0f virtual void Read(float &ad1, float &ad2); // 0 <= data1, data2 <= 4095 virtual void Read(uint16_t &ad1, uint16_t &ad2); protected: float ToFloat(uint16_t x) { return AMP_*(x - 2048); } private: static const float AMP_ = 1.0f/2048.0f; static const uint32_t EOC23_ = ADC_CSR_EOC2 | ADC_CSR_EOC3; // AD 変換が完了するまで待つ void WaitDone() { while((ADC->CSR & EOC23_) != EOC23_); } // AD 変換器の外部トリガに使うタイマ (TIM8) の設定 void SetTim8(int frequency); // for inhibition of copy constructor AdcDual(const AdcDual&); // for inhibition of substitute operator AdcDual& operator=(const AdcDual&); }; } #endif // F446_ADC_DUAL_HPP