diff options
author | Dave Hylands <dhylands@gmail.com> | 2014-07-22 07:57:36 -0700 |
---|---|---|
committer | Dave Hylands <dhylands@gmail.com> | 2014-08-07 23:15:41 -0700 |
commit | 6f418fc1b068c1a41113bb2b019a5803765e1deb (patch) | |
tree | 79477835459eb424012f58d77a150bdf9a80eed5 /teensy/mk20dx256-prefix.c | |
parent | 3ef911345c94a6d612ab50c1e912e81cb2cc3f71 (diff) | |
download | micropython-6f418fc1b068c1a41113bb2b019a5803765e1deb.tar.gz micropython-6f418fc1b068c1a41113bb2b019a5803765e1deb.zip |
Add support for selecting pin alternate functions from python.
Converts generted pins to use qstrs instead of string pointers.
This patch also adds the following functions:
pyb.Pin.names()
pyb.Pin.af_list()
pyb.Pin.gpio()
dir(pyb.Pin.board) and dir(pyb.Pin.cpu) also produce useful results.
pyb.Pin now takes kw args.
pyb.Pin.__str__ now prints more useful information about the pin
configuration.
I found the following functions in my boot.py to be useful:
```python
def pins():
for pin_name in dir(pyb.Pin.board):
pin = pyb.Pin(pin_name)
print('{:10s} {:s}'.format(pin_name, str(pin)))
def af():
for pin_name in dir(pyb.Pin.board):
pin = pyb.Pin(pin_name)
print('{:10s} {:s}'.format(pin_name, str(pin.af_list())))
```
Diffstat (limited to 'teensy/mk20dx256-prefix.c')
-rw-r--r-- | teensy/mk20dx256-prefix.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/teensy/mk20dx256-prefix.c b/teensy/mk20dx256-prefix.c index 2485dc01ab..048b64316a 100644 --- a/teensy/mk20dx256-prefix.c +++ b/teensy/mk20dx256-prefix.c @@ -15,6 +15,7 @@ #define AF(af_idx, af_fn, af_unit, af_type, af_ptr) \ { \ { &pin_af_type }, \ + .name = MP_QSTR_AF ## af_idx ## _ ## af_fn ## af_unit, \ .idx = (af_idx), \ .fn = AF_FN_ ## af_fn, \ .unit = (af_unit), \ @@ -25,7 +26,7 @@ #define PIN(p_port, p_pin, p_num_af, p_af, p_adc_num, p_adc_channel) \ { \ { &pin_type }, \ - .name = #p_port #p_pin, \ + .name = MP_QSTR_ ## p_port ## p_pin, \ .port = PORT_ ## p_port, \ .pin = (p_pin), \ .num_af = (p_num_af), \ |