File tree Expand file tree Collapse file tree 1 file changed +26
-6
lines changed Expand file tree Collapse file tree 1 file changed +26
-6
lines changed Original file line number Diff line number Diff line change 15
15
* limitations under the License.
16
16
*/
17
17
18
- #include " drivers/DigitalIn .h"
18
+ #include " drivers/AnalogIn .h"
19
19
20
- #include " platform/mbed_critical.h "
20
+ #if DEVICE_ANALOGIN
21
21
22
22
namespace mbed {
23
23
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 ()
25
34
{
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;
29
47
}
30
48
31
49
} // namespace mbed
50
+
51
+ #endif
You can’t perform that action at this time.
0 commit comments