Class library for internal ADC and DAC connected by SPI. ADC is triggered by TIM2. This library support clock generator using TIM3 for switched-capacitor filter to smooth output signal of DAC. This library includes derivative class to support interrupt occured in end of AD conversion. Slave select of SPI for DAC is generated using TIM4. Validated for ST Nucleo F401RE, F411RE. New version. 内蔵 ADC と,SPI 接続の DAC のためのクラスライブラリ.ADC の変換開始トリガは TIM2 で発生.DAC の出力信号を平滑化するためのスイッチトキャパシタフィルタ用のクロックは TIM3 を使用.DAC の SPI 用スレーブ選択信号は TIM4 で発生.ST Nucleo F401RE,F411RE で動作を確認.新バージョン
Dependents: UIT2_MovingAverage UIT2_AllpassReverb UIT2_CombReverb UIT2_FIR_LPF_Symmetry ... more
Diff: ADC_Base.hpp
- Revision:
- 13:f2b8af192558
- Parent:
- 9:72fe42a4323c
- Child:
- 15:ab7eb29b69ea
diff -r 479d18a09e87 -r f2b8af192558 ADC_Base.hpp --- a/ADC_Base.hpp Mon Dec 01 07:13:33 2014 +0000 +++ b/ADC_Base.hpp Fri Dec 19 06:01:15 2014 +0000 @@ -1,7 +1,7 @@ //------------------------------------------------------ // Class for ADC using TIM2 trigger -- Header // -// 2014/11/12, Copyright (c) 2014 MIKAMI, Naoki +// 2014/12/19, Copyright (c) 2014 MIKAMI, Naoki //------------------------------------------------------ #ifndef ADC_BASE_HPP @@ -21,13 +21,16 @@ // initailized by regular excutable statements AnalogIn* adc2_; AnalogIn* adc3_; - - // Pins for Analog input - const PinName PIN1_, PIN2_, PIN3_; + + // Channel of ADC1 + uint8_t ch1_, ch2_, ch3_; // Set timer to generate sampling pulse for ADC void SetTim2(int frequency); + // Exctract channel number + uint8_t GetChannel(PinName); + // for inhibition of copy constructor ADC_Base(const ADC_Base&); // for inhibition of substitute operator @@ -44,6 +47,7 @@ { while((myAdc_->SR & ADC_SR_EOC) == RESET); } public: + // Constructor // pin1: Pin Name for input as A0, A1, etc. // frequency: Sampling frequency @@ -67,9 +71,9 @@ } // Select channel - void Select1stChannel() { myAdc_->SQR3 = PIN1_; } - void Select2ndChannel() { myAdc_->SQR3 = PIN2_; } - void Select3rdChannel() { myAdc_->SQR3 = PIN3_; } + void Select1stChannel() { myAdc_->SQR3 = ch1_; } + void Select2ndChannel() { myAdc_->SQR3 = ch2_; } + void Select3rdChannel() { myAdc_->SQR3 = ch3_; } // Software start virtual void SoftStart() @@ -79,7 +83,3 @@ }; } #endif // ADC_BASE_HPP - - - -