class Pin¶
-
class
Pin
¶ Public Functions
-
Pin
(PinBank *bank, int index, int soc_pin_number, char *direction, int interrupt, int pull)¶ Creates a Pin with index and soc_pin_number, storing a reference to the PinBank. The direction, interrupt and pull parameters can also be set during the creation
- Return
- The initialized Pin.
- Parameters
index
-the identity of the pin used to create the derived class.
the
-pin on the header to control, identified by the SoC pin number.
direction
-(optional) the direction of the pin, either IN or OUT.
interrupt
-(optional)
pull
-(optional)
-
int
open
()¶ Exports the pin and opens the file descriptor for the pin value and sets its direction (IN/OUT).
- Return
- 0 if all the operations are successful. Otherwise, a perror message is thrown and the quick2wire_errno variable is set to PIN_ERR.
-
int
close
()¶ Closes the file descriptor and unexports the pin.
- Return
- 0 if succesful or if the pin was already closed. Otherwise it returns the status code returned by gpio_admin.
-
bool
closed
()¶ Check if the pin has been closed. A closed pin is that which has never been open or which has been open and already closed.
- Return
- Returns true if the pin is closed, otherwise, false is returned.
-
int
get_soc_pin_number
()¶ Returns the SoC pin number
- Return
- The SoC pin number
-
void
setValue
(int value)¶ Sets the value of the pin
- Parameters
value
-The value to set
-
int
getIndex
()¶ Returns the index number of the pin
-
void
setIndex
(int value)¶ Sets the number of the pin
-
char *
getDirection
()¶ Returns the direction of the pin as an string
- Return
- The direction of the pin
-
void
setDirection
(char *direction)¶ Sets the direction of the pin (IN/OUT)
Private Functions
-
int
get
()¶ Gets the value of the pin.
- Return
- The value of the pin
-
int
set
(int value)¶ Sets the value of the pin.
- Parameters
value
-The new value
-
int
write
(char *filename, char *value)¶ Writes the string value in filename, relative to the path in the /sys/devices directory for the pin. the absolute path is generated by the pin_path function. Writing on the file alters the behaviour of the pin, and depending on the name of the file, the results differ:
- direction: the direction of the pin (in, out)
- edge
- the value of the pin value (0, 1)
- Parameters
filename
-The name of the file. Typical values are: direction, edge, value.
value
-The value to write.
-
char *
pin_path
(char *filename)¶ Returns the absolute path for the filename value inside the gpio directory for the value of the Pin. The function is used by write to determine where to write a property of the GPIO port.
- Return
- The absolute path (including filename).
- Parameters
filename
-The name of the file.
-
char *
to_string
()¶ Returns information about the pin.
-