Library for build-in ADC and DAC in STM32F446 mounted on Nucleo F446RE. Nucleo F446RE に搭載されている STM32F446 の内蔵 ADC, DAC 用のライブラリ.

Dependents:   Demo_F446_AD_DA F446_MySoundMachine F446_ADF_Nlms F446_Spectrogram

Revision:
0:c945b4fe9a48
Child:
1:6b9f2af6613d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/F446_ADC_Interrupt.hpp	Fri Nov 11 06:28:48 2016 +0000
@@ -0,0 +1,56 @@
+//----------------------------------------------------------
+//  Simultanuous AD Conversion by interrupt using
+//  ADC2 and ADC3 on STM32F446 ---- Header
+//
+//  STM32F446 の ADC2, ADC3 を使って同時に AD 変換を開始し,
+//  割り込みによりアナログ信号を入力するクラス(ヘッダ)
+//      AdcDual クラスの派生クラス
+//
+//  2016/11/11, Copyright (c) 2016 MIKAMI, Naoki
+//----------------------------------------------------------
+
+#ifndef F446_ADC_DUAL_INTERRUPT_HPP
+#define F446_ADC_DUAL_INTERRUPT_HPP
+
+#include "F446_ADC.hpp"
+
+namespace Mikami
+{
+    class AdcDual_Intr : public AdcDual
+    {
+    public:
+        AdcDual_Intr(int frequency) : AdcDual(frequency)
+        {   ADC2->CR1 |= ADC_CR1_EOCIE; }
+
+        // -1.0f <= data1, data2 <= 1.0f
+        virtual void Read(float &ad2, float &ad1)
+        {
+            ad1 = ToFloat(ADC2->DR);
+            ad2 = ToFloat(ADC3->DR);
+        }
+
+        // 0 <= data1, data2 <= 4095
+        virtual void Read(uint16_t &ad2, uint16_t &ad1)
+        {
+            ad1 = ADC2->DR;
+            ad2 = ADC3->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
+        AdcDual_Intr(const AdcDual_Intr&);
+        // for inhibition of substitute operator
+        AdcDual_Intr& operator=(const AdcDual_Intr&);     
+    };
+}
+#endif  // F446_ADC_DUAL_INTERRUPT_HPP
\ No newline at end of file