Skip to content

Commit b73ac79

Browse files
committed
Fixing history - part 1
1 parent f5cbb0d commit b73ac79

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

drivers/source/DigitalIn.cpp renamed to drivers/AnalogIn.cpp

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,37 @@
1515
* limitations under the License.
1616
*/
1717

18-
#include "drivers/DigitalIn.h"
18+
#include "drivers/AnalogIn.h"
1919

20-
#include "platform/mbed_critical.h"
20+
#if DEVICE_ANALOGIN
2121

2222
namespace mbed {
2323

24-
void DigitalIn::mode(PinMode pull)
24+
SingletonPtr<PlatformMutex> AnalogIn::_mutex;
25+
26+
AnalogIn::AnalogIn(PinName pin)
27+
{
28+
lock();
29+
analogin_init(&_adc, pin);
30+
unlock();
31+
}
32+
33+
float AnalogIn::read()
2534
{
26-
core_util_critical_section_enter();
27-
gpio_mode(&gpio, pull);
28-
core_util_critical_section_exit();
35+
lock();
36+
float ret = analogin_read(&_adc);
37+
unlock();
38+
return ret;
39+
}
40+
41+
unsigned short AnalogIn::read_u16()
42+
{
43+
lock();
44+
unsigned short ret = analogin_read_u16(&_adc);
45+
unlock();
46+
return ret;
2947
}
3048

3149
} // namespace mbed
50+
51+
#endif

0 commit comments

Comments
 (0)