Class library for internal ADC and DAC connected by SPI. 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. Validated for ST Nucleo F401RE, F411RE. 内蔵 ADC と,SPI 接続の DAC のためのクラスライブラリ.DAC の出力信号を平滑化するためのスイッチトキャパシタフィルタ用のクロックは TIM3 を使用.ST Nucleo F401RE,F411RE で動作を確認.

Dependents:   UITDSP_ADDA_Example UIT2_MovingAv_Intr UIT2_VariableFIR UIT2_VowelSynthesizer ... more

Revision:
6:9deca4a06c8c
Parent:
5:ff25db28bc64
diff -r ff25db28bc64 -r 9deca4a06c8c TIM4_SlaveSelect.hpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TIM4_SlaveSelect.hpp	Tue Mar 31 06:01:38 2015 +0000
@@ -0,0 +1,57 @@
+//--------------------------------------------------------------
+//  Class for generate SPI slave select using TIM4
+//
+//  PB_6 (D10), PB_7, PB_8 (D15), and PB_9 (D14) can be used
+//  2015/03/31, Copyright (c) 2015 MIKAMI, Naoki
+//--------------------------------------------------------------
+
+#ifndef TIM4_SLAVESELECT_HPP
+#define TIM4_SLAVESELECT_HPP
+
+#include "mbed.h"
+
+namespace Mikami
+{
+    class TIM4_SlaveSelect
+    {
+    public:
+        TIM4_SlaveSelect(
+            uint16_t psc,   // prescaler
+            uint16_t arr,   // auto-reload register
+            PinName pin)    // pin name
+            : myTim_(TIM4)
+        {
+            if ( (pin != PB_6) && (pin != PB_7)
+               &&(pin != PB_8) && (pin != PB_9) )
+            {
+                fprintf(stderr, "\r\nIllegal pin name in TIM4_SlaveSelect\r\n");
+                while (true) {}
+            }
+
+            PwmOut css(pin);            // for slave select
+            myTim_->CR1 |= TIM_CR1_OPM; // one-pulse mode
+            myTim_->PSC = psc;          // prescaler
+            myTim_->ARR = arr;          // pulse width
+            if (pin == PB_6) myTim_->CCR1 = 1;
+            if (pin == PB_7) myTim_->CCR2 = 1;
+            if (pin == PB_8) myTim_->CCR3 = 1;
+            if (pin == PB_9) myTim_->CCR4 = 1;
+        }
+
+        // Generate slave select
+        void SlaveSelect()
+        {
+            myTim_->CNT = 1;            // Set counter 1
+            myTim_->CR1 |= TIM_CR1_CEN; // Enable TIM4
+        }
+
+    private:
+        TIM_TypeDef* const myTim_;
+
+        // Forbid to use copy constructor
+        TIM4_SlaveSelect(const TIM4_SlaveSelect&);
+        // Forbid to use substitution operator
+        TIM4_SlaveSelect operator=(const TIM4_SlaveSelect&);
+    };
+}
+#endif  // TIM4_SLAVESELECT_HPP