-
Notifications
You must be signed in to change notification settings - Fork 30
/
pin_dump.py
35 lines (31 loc) · 1.02 KB
/
pin_dump.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from pyb import Pin, I2C, SPI, UART, ADC, Servo, DAC
def pins():
for pin_name in dir(Pin.board):
pin = Pin(pin_name)
print('{:10s} {:s}'.format(pin_name, str(pin)))
def af():
for pin_name in dir(Pin.board):
pin = Pin(pin_name)
print('{:10s} {:s}'.format(pin_name, str(pin.af_list())))
def pins_test():
i2c = I2C(1, I2C.MASTER)
spi = SPI(2, SPI.MASTER)
uart = UART(3, 9600)
servo = Servo(1)
adc = ADC(Pin.board.X3)
dac = DAC(1)
pin = Pin('X4', mode=Pin.AF_PP, af=Pin.AF3_TIM9)
pin = Pin('Y1', mode=Pin.AF_OD, af=3)
pin = Pin('Y2', mode=Pin.OUT_PP)
pin = Pin('Y3', mode=Pin.OUT_OD, pull=Pin.PULL_UP)
pin.high()
pin = Pin('Y4', mode=Pin.OUT_OD, pull=Pin.PULL_DOWN)
pin.high()
pin = Pin('X18', mode=Pin.IN, pull=Pin.PULL_NONE)
pin = Pin('X19', mode=Pin.IN, pull=Pin.PULL_UP)
pin = Pin('X20', mode=Pin.IN, pull=Pin.PULL_DOWN)
print('===== output of pins() =====')
pins()
print('===== output of af() =====')
af()
pins_test()