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.
Dependents: UIT2_MovingAverage UIT2_AllpassReverb UIT2_CombReverb UIT2_FIR_LPF_Symmetry ... more
Diff: ADC_Base.cpp
- Revision:
- 15:ab7eb29b69ea
- Parent:
- 13:f2b8af192558
- Child:
- 16:0001d3e93bee
--- a/ADC_Base.cpp Sun Dec 21 08:07:09 2014 +0000
+++ b/ADC_Base.cpp Wed Dec 31 10:21:54 2014 +0000
@@ -3,7 +3,7 @@
// To get bit definition for register in
// peripheral, see "stm32f401xe.h"
//
-// 2014/12/19, Copyright (c) 2014 MIKAMI, Naoki
+// 2014/12/31, Copyright (c) 2014 MIKAMI, Naoki
//------------------------------------------------------
#include "ADC_Base.hpp"
@@ -12,30 +12,29 @@
{
ADC_Base::ADC_Base(PinName pin1, int frequency,
PinName pin2, PinName pin3)
- : adc_(pin1), /*PIN1_(pin1), PIN2_(pin2),
- PIN3_(pin3), */myAdc_(ADC1)
+ : adc_(pin1), myAdc_(ADC1)
{
myAdc_->CR2 = ADC_EXTERNALTRIGCONVEDGE_RISING // External Trigger on the rising edge
| ADC_EXTERNALTRIGCONV_T2_TRGO // Use Timer2 TRGO event
| ADC_CR2_ADON; // Enable ADC
- ch1_ = GetChannel(pin1);
+ ch1_ = GetChannelNumber(pin1);
if (pin2 != NC)
{
adc2_ = new AnalogIn(pin2);
- ch2_ = GetChannel(pin2);
+ ch2_ = GetChannelNumber(pin2);
}
if (pin3 != NC)
{
adc3_ = new AnalogIn(pin3);
- ch3_ = GetChannel(pin3);
+ ch3_ = GetChannelNumber(pin3);
}
SetTim2(frequency);
Select1stChannel();
}
// Extract channel number
- uint8_t ADC_Base::GetChannel(PinName pin)
+ uint8_t ADC_Base::GetChannelNumber(PinName pin)
{
uint8_t ch = 0;
if ((pin & 0x30) == 0x00) ch = pin;
@@ -59,3 +58,4 @@
}
}
+