Added one channel mode
Dependents: CW_Decoder_using_FFT_on_F446
Fork of F446_AD_DA by
Diff: F446_ADC_Interrupt.hpp
- Revision:
- 4:03e91e464ce5
- Parent:
- 1:6b9f2af6613d
--- a/F446_ADC_Interrupt.hpp Mon Jan 30 08:12:44 2017 +0000 +++ b/F446_ADC_Interrupt.hpp Sun Feb 05 07:59:14 2017 +0000 @@ -9,13 +9,14 @@ // 2016/11/12, Copyright (c) 2016 MIKAMI, Naoki //---------------------------------------------------------- -#ifndef F446_ADC_DUAL_INTERRUPT_HPP -#define F446_ADC_DUAL_INTERRUPT_HPP - #include "F446_ADC.hpp" namespace Mikami { + +#ifndef F446_ADC_DUAL_INTERRUPT_HPP +#define F446_ADC_DUAL_INTERRUPT_HPP + class AdcDual_Intr : public AdcDual { public: @@ -52,5 +53,47 @@ // for inhibition of substitute operator AdcDual_Intr& operator=(const AdcDual_Intr&); }; + +#endif // F446_ADC_DUAL_INTERRUPT_HPP + +//------------------------------------------------------------------------------ + +#ifndef F446_ADC_SINGLE_INTERRUPT_HPP +#define F446_ADC_SINGLE_INTERRUPT_HPP + + class AdcSingle_Intr : public AdcSingle + { + public: + AdcSingle_Intr(int frequency) : AdcSingle(frequency) + { ADC2->CR1 |= ADC_CR1_EOCIE; } + + virtual void Read(float &ad) + { + ad = ToFloat(ADC2->DR); + } + + virtual void Read(uint16_t &ad) + { + ad = ADC2->DR; + } + + // Set interrupt vector and enable IRQ of ADC + void SetIntrVec(void (*Func)()) + { + NVIC_SetVector(ADC_IRQn, (uint32_t)Func); // See "cmsis_nvic.h" + NVIC_EnableIRQ(ADC_IRQn); // See "core_cm4.h" + } + + void DisableAdcIntr() + { NVIC_DisableIRQ(ADC_IRQn); } + + private: + // for inhibition of copy constructor + AdcSingle_Intr(const AdcSingle_Intr&); + // for inhibition of substitute operator + AdcSingle_Intr& operator=(const AdcSingle_Intr&); + }; +#endif // F446_ADC_SINGLE_INTERRUPT_HPP + } -#endif // F446_ADC_DUAL_INTERRUPT_HPP +