forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 0
Hardware API
Daniel Campora edited this page Aug 20, 2015
·
115 revisions
The classes to control the peripherals of the board will reside in a new module called hardware, therefore, by doing:
import hardware
dir(hardware)one can easily see what's supported on the board.
- id, mode are mandatory and positional (also can be named)
- pull is optional and positional (also can be named)
- rest of args are kwonly
- only "value" is required for a port to implement (initial value if given)
- rest are optional, and a port can define them and also define others
pin = Pin(id, mode, pull=Pin.PULL_NONE, *, value, drive, slew, ...)
-
pin.init(...)re init -
pin.high()set high -
pin.low()set low -
pin.value()get value -
pin.value(x)set value -
pin()fast method to get the value of the pin -
pin(value)fast method to set the value of the pin pin.toggle()
Methods to get/set parameters:
-
pin.id()this one is only a getter pin.mode()pin.pull()pin.drive()pin.slew()
-
for mode:
Pin.IN,Pin.OUT,Pin.OPEN_DRAIN -
for pull:
Pin.PULL_UP,Pin.PULL_DOWN,Pin.PULL_NONE_optional pull:_Pin.PULL_UP_STRONG,Pin.PULL_DOWN_WEAK`, ... -
for drive:
Pin.LOW_POWER,Pin.MED_POWER,Pin.HIGH_POWER -
for slew:
Pin.FAST_RISE,Pin.SLOW_RISE -
for interrupt (callback) mode:
pin.INT_RISING,pin.INT_FALLING,pin.INT_RISING_FALLING,pin.INT_HIGH_LEVEL,pin.INT_LOW_LEVEL
- Mandatory:
Pin.board, optional:Pin.cpu