For the STM32F4DISC board, you can determine the pin names in one of a couple of different ways:
1 - Examine the pins.csv file:
https://github.com/micropython/micropyt ... C/pins.csv
2 - Use the dir command from the python command line:
Code: Select all
Micro Python v1.3.8-9-g8a2cc1c on 2014-12-29; F4DISC with STM32F407
Type "help()" for more information.
>>> dir(pyb.Pin.board)
['PC0', 'PC1', 'PC2', 'PC3', 'PA0', 'PA1', 'PA2', 'PA3', 'PA4', 'PA5', 'PA6', 'PA7', 'PC4', 'PC5', 'PB0', 'PB1', 'PB2', 'PE7', 'PE8', 'PE9', 'PE10', 'PE11', 'PE12', 'PE13', 'PE14', 'PE15', 'PB10', 'PB11', 'PB12', 'PB13', 'PB14', 'PB15', 'PD8', 'PD9', 'PD10', 'PD11', 'PD12', 'PD13', 'PD14', 'PD15', 'PC6', 'PC7', 'PC8', 'PC9', 'PA8', 'PA9', 'PA10', 'PA13', 'PA14', 'PA15', 'PC10', 'PC11', 'PC12', 'PD0', 'PD1', 'PD2', 'PD3', 'PD4', 'PD5', 'PD6', 'PD7', 'PB4', 'PB5', 'PB6', 'PB7', 'PB8', 'PB9', 'PE0', 'PE1', 'PE2', 'PE3', 'PE4', 'PE5', 'PE6', 'PC13', 'PC14', 'PC15', 'PH0', 'PH1', 'LED_GREEN', 'LED_ORANGE', 'LED_RED', 'LED_BLUE', 'SW']
>>> dir(pyb.Pin.cpu)
['A0', 'A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A9', 'A10', 'A13', 'A14', 'A15', 'B0', 'B1', 'B2', 'B4', 'B5', 'B6', 'B7', 'B8', 'B9', 'B10', 'B11', 'B12', 'B13', 'B14', 'B15', 'C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10', 'C11', 'C12', 'C13', 'C14', 'C15', 'D0', 'D1', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9', 'D10', 'D11', 'D12', 'D13', 'D14', 'D15', 'E0', 'E1', 'E2', 'E3', 'E4', 'E5', 'E6', 'E7', 'E8', 'E9', 'E10', 'E11', 'E12', 'E13', 'E14', 'E15', 'H0', 'H1']
The board pins typically match the names silscreened on the board, where the CPU pins are always of the form Port Letter followed by pin number within the port. For the STM32F4DISC board, these are almost identical (the board names start with a P).
To determine which functions are available on which pins, you can look at this file:
https://github.com/micropython/micropyt ... 405_af.csv which has all of the alternae functions listed for each pin.
There is also a generated python file called pins_af.py which you'll find in build-STM32F4DISC, which looks something like this:
Code: Select all
PINS_AF = (
('PC0', ),
('PC1', ),
('PC2', (5, 'SPI2_MISO'), (6, 'I2S2_EXTSD'), ),
('PC3', (5, 'SPI2_MOSI'), (5, 'I2S2_SD'), ),
('PA0', (1, 'TIM2_CH1'), (1, 'TIM2_ETR'), (2, 'TIM5_CH1'), (3, 'TIM8_ETR'), (7, 'USART2_CTS'), (8, 'UART4_TX'), ),
('PA1', (1, 'TIM2_CH2'), (2, 'TIM5_CH2'), (7, 'USART2_RTS'), (8, 'UART4_RX'), ),
('PA2', (1, 'TIM2_CH3'), (2, 'TIM5_CH3'), (3, 'TIM9_CH1'), (7, 'USART2_TX'), ),
('PA3', (1, 'TIM2_CH4'), (2, 'TIM5_CH4'), (3, 'TIM9_CH2'), (7, 'USART2_RX'), ),
('PA4', (5, 'SPI1_NSS'), (6, 'SPI3_NSS'), (6, 'I2S3_WS'), (7, 'USART2_CK'), ),
('PA5', (1, 'TIM2_CH1'), (1, 'TIM2_ETR'), (3, 'TIM8_CH1N'), (5, 'SPI1_SCK'), ),
...
If you copy pins_af.py to your board along with the examples/pins.py file, then you can do:
Code: Select all
>>> import pins
>>> pins.pins()
PC0 IN
PC1 IN
PC2 IN
PC3 IN
PA0 IN
PA1 IN
PA2 IN
PA3 IN
...
to see how each pin is currently configured. You can run:
Code: Select all
>>> pins.af()
PC0
PC1
PC2 5: SPI2_MISO 6: I2S2_EXTSD
PC3 5: SPI2_MOSI 5: I2S2_SD
PA0 1: TIM2_CH1 1: TIM2_ETR 2: TIM5_CH1 3: TIM8_ETR 7: USART2_CTS 8: UART4_TX
PA1 1: TIM2_CH2 2: TIM5_CH2 7: USART2_RTS 8: UART4_RX
PA2 1: TIM2_CH3 2: TIM5_CH3 3: TIM9_CH1 7: USART2_TX
...
to see the available functions for each pin in a slightly more readable form than looking at pins_af.py directly.
Most of the pyb functions work the same on the discovery board as they do on the pyboard. The exceptions that I can think of are pyb.Accel and pyb.Servo aren't present. You can see what is present by using:
Code: Select all
>>> dir(pyb)
['__name__', 'bootloader', 'hard_reset', 'info', 'unique_id', 'freq', 'repl_info', 'wfi', 'disable_irq', 'enable_irq', 'stop', 'standby', 'main', 'repl_uart', 'usb_mode', 'hid_mouse', 'hid_keyboard', 'USB_VCP', 'USB_HID', 'have_cdc', 'hid', 'millis', 'elapsed_millis', 'micros', 'elapsed_micros', 'delay', 'udelay', 'sync', 'mount', 'Timer', 'rng', 'RTC', 'Pin', 'ExtInt', 'Switch', 'LED', 'I2C', 'SPI', 'UART', 'CAN', 'ADC', 'ADCAll', 'DAC']
There is an staccel.py in the boards/STMF4DISC directory that is supposed to work with the accelerometer (I haven't used it myself).