Added one channel mode
Dependents: CW_Decoder_using_FFT_on_F446
Fork of F446_AD_DA by
Diff: F446_ADC.hpp
- Revision:
- 4:03e91e464ce5
- Parent:
- 3:d1da91aec62f
--- a/F446_ADC.hpp Mon Jan 30 08:12:44 2017 +0000 +++ b/F446_ADC.hpp Sun Feb 05 07:59:14 2017 +0000 @@ -11,6 +11,14 @@ // // 2017/01/30, Copyright (c) 2017 MIKAMI, Naoki //---------------------------------------------------------- +/* + * Modified by Kenji Arai + * http://www.page.sannet.ne.jp/kenjia/index.html + * http://mbed.org/users/kenjiArai/ + * + * Started: Feburary 1st, 2017 + * Revised: Feburary 1st, 2017 + */ #include "mbed.h" @@ -20,11 +28,11 @@ #include "F446_DAC.hpp" +namespace Mikami +{ #ifndef F446_ADC_DUAL_HPP #define F446_ADC_DUAL_HPP -namespace Mikami -{ class AdcDual { public: @@ -60,5 +68,44 @@ // for inhibition of substitute operator AdcDual& operator=(const AdcDual&); }; + +#endif // F446_ADC_DUAL_HPP + +#ifndef F446_ADC_SINGLE_HPP +#define F446_ADC_SINGLE_HPP + + class AdcSingle + { + public: + // Constructor + // frequency: sampling frequency + explicit AdcSingle(int frequency); + + virtual void Read(float &ad); + + virtual void Read(uint16_t &ad); + + protected: + float ToFloat(uint16_t x) + { return AMP_*(x - 2048); } + + private: + static const float AMP_ = 1.0f/2048.0f; + static const uint32_t EOC2_ = ADC_CSR_EOC2; + + // waiting ADC conversion + void WaitDone() + { while((ADC->CSR & EOC2_) != EOC2_); } + + // Set timer(TIM() for trigger for ADC + void SetTim8(int frequency); + + // for inhibition of copy constructor + AdcSingle(const AdcSingle&); + // for inhibition of substitute operator + AdcSingle& operator=(const AdcSingle&); + }; + +#endif // F446_ADC_SINGLE_HPP } -#endif // F446_ADC_DUAL_HPP +