Mistake on this page?
Report an issue in GitHub or email us
InterfaceDigitalIn.h
1 /*
2  * Mbed-OS Microcontroller Library
3  * Copyright (c) 2021 Embedded Planet
4  * Copyright (c) 2021 ARM Limited
5  * SPDX-License-Identifier: Apache-2.0
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License
18  */
19 
20 #ifndef MBED_INTERFACE_DIGITALIN_H_
21 #define MBED_INTERFACE_DIGITALIN_H_
22 
23 
24 namespace mbed {
25 
26 class DigitalIn;
27 
28 namespace interface {
29 
30 #ifdef FEATURE_EXPERIMENTAL_API
31 
32 // TODO - move method doxygen comments to interface once this polymorphism is mainstream
33 
34 // Pure interface definition for DigitalIn
35 struct DigitalIn {
36  virtual ~DigitalIn() = default;
37  virtual int read() = 0;
38  virtual void mode(PinMode pull) = 0;
39  virtual int is_connected() = 0;
40 
41  operator int()
42  {
43  // Underlying implementation is responsible for thread-safety
44  return read();
45  }
46 
47 };
48 #else
50 #endif /* FEATURE_EXPERIMENTAL_API */
51 
52 } // namespace interface
53 } // namespace mbed
54 
55 #endif /* MBED_INTERFACE_DIGITALIN_H_ */
int read()
Read the input, represented as 0 or 1 (int)
Definition: DigitalIn.h:97
DigitalIn(PinName pin)
Create a DigitalIn connected to the specified pin.
Definition: DigitalIn.h:67
void mode(PinMode pull)
Set the input pin mode.
~DigitalIn()
Class destructor, deinitialize the pin.
Definition: DigitalIn.h:86
int is_connected()
Return the output setting, represented as 0 or 1 (int)
Definition: DigitalIn.h:114
A digital input, used for reading the state of a pin.
Definition: DigitalIn.h:56
Definition: ATHandler.h:46
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.