circuitpython/teensy/pin_defs_teensy.h
Dave Hylands 6f418fc1b0 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())))
```
2014-08-07 23:15:41 -07:00

46 lines
752 B
C

enum {
PORT_A,
PORT_B,
PORT_C,
PORT_D,
PORT_E,
PORT_Z,
};
enum {
AF_FN_FTM,
AF_FN_I2C,
AF_FN_UART,
AF_FN_SPI
};
enum {
AF_PIN_TYPE_FTM_CH0 = 0,
AF_PIN_TYPE_FTM_CH1,
AF_PIN_TYPE_FTM_CH2,
AF_PIN_TYPE_FTM_CH3,
AF_PIN_TYPE_FTM_QD_PHA,
AF_PIN_TYPE_FTM_QD_PHB,
AF_PIN_TYPE_I2C_SDA = 0,
AF_PIN_TYPE_I2C_SCL,
AF_PIN_TYPE_SPI_MOSI = 0,
AF_PIN_TYPE_SPI_MISO,
AF_PIN_TYPE_SPI_SCK,
AF_PIN_TYPE_SPI_NSS,
AF_PIN_TYPE_UART_TX = 0,
AF_PIN_TYPE_UART_RX,
AF_PIN_TYPE_UART_CTS,
AF_PIN_TYPE_UART_RTS,
};
#define PIN_DEFS_PORT_AF_UNION \
FTM_TypeDef *FTM; \
I2C_TypeDef *I2C; \
UART_TypeDef *UART; \
SPI_TypeDef *SPI;
typedef GPIO_TypeDef pin_gpio_t;