@iiot2k/gpiox
Version:
Input/Output on any gpio library
36 lines (27 loc) • 1.62 kB
Markdown
# API @iiot2k/gpiox
Input/Output on any gpio library
Library functions and constants are explained in TypeScript file **gpiox.d.ts**
The @iiot2k/gpiox driver uses the gpio character devices interface (V2) from the Linux operating system.<br>
The driver is loaded on call with ```require("@iiot2k/gpiox");```<br>
On 64bit OS the driver ***gpiox_arm64.node*** is loaded.<br>
## pin Parameter
The Raspberry Pi has gpio pins from GPIO0 to GPIO27.<br>
Valid ```pin``` parameter values are 0..27.<br>
## mode Parameter
Each gpio pin can be assigned a function.<br>
The following table shows the different modes with ```mode``` parameter.<br>
|Constant|State-0|State-1|function|
|:--|:--|:--|:--|
|GPIO_MODE_INPUT_NOPULL|ground|+3.3V|floating input|
|GPIO_MODE_INPUT_PULLDOWN|open/ground|+3.3V|pulldown resistor input|
|GPIO_MODE_INPUT_PULLUP|open/+3.3V|ground|pullup resistor input|
|GPIO_MODE_OUTPUT|ground|+3.3V|output|
|GPIO_MODE_OUTPUT_SOURCE|Hi-Z|+3.3V|output source|
|GPIO_MODE_OUTPUT_SINK|Hi-Z|ground|output sink|
Floating input/output is used when the pin is connected to another pin.<br>
Input voltages more than +3.3V can destroy the input.<br>
Hi-Z refers to an output signal state in which the signal is not being driven.<br>
Please do not init gpio pins with special functions (i2c, spi, uart..).<br>
GPIO output current is limited.<br>
Use [ULN2803A](https://www.ti.com/product/ULN2803C) (low switch) or
[TBD62783](https://toshiba.semicon-storage.com/eu/semiconductor/product/linear-ics/transistor-arrays/detail.TBD62783APG.html) (high switch) for drive output.<br>