Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SDR_Library/F446_ADC_Base.hpp
- Committer:
- MikamiUitOpen
- Date:
- 2021-03-03
- Revision:
- 1:32d6e3f7df30
- Parent:
- 0:7a653530c8ce
File content as of revision 1:32d6e3f7df30:
//-------------------------------------------------------------
// F446 内蔵 ADC 用抽象基底クラス(ヘッダ)
//
// 2020/07/24, Copyright (c) 2020 MIKAMI, Naoki
//-------------------------------------------------------------
#include "mbed.h"
#ifndef ADC_F446_POLLING_HPP
#define ADC_F446_POLLING_HPP
namespace Mikami
{
class AdcF446_Base
{
public:
// コンストラクタ
// fSampling 標本化周波数 [kHz]
// pin 入力ピンの名前
AdcF446_Base(float fSampling, PinName pin);
virtual ~AdcF446_Base() {}
// AD 変換された値を読み込む(純粋仮想関数)
virtual float Read() = 0;
protected:
ADC_TypeDef* const myAdc_; // AD 変換器に対応するポインタ
float ToFloat(uint16_t x) { return AMP_*(x - 2048); }
private:
static const float AMP_ = 1.0f/2048.0f;
// AD 変換器の外部トリガに使うタイマ (TIM8) の設定
// fSampling 標本化周波数 [kHz]
void SetTim8(float fSampling);
// コピー・コンストラクタ,代入演算子の禁止のため
AdcF446_Base(const AdcF446_Base&);
AdcF446_Base& operator=(const AdcF446_Base&);
};
}
#endif // ADC_F446_POLLING_HPP