multi peripheral functionality on same pin

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
ajie_dirgantara
Posts: 81
Joined: Fri Sep 02, 2016 9:26 am

multi peripheral functionality on same pin

Post by ajie_dirgantara » Sat Aug 26, 2017 2:29 am

Is it possible to enabled multiple functionality on single pin by assigning definition on mpconfigboard.h, e.g like this (note that B10 and B11 can be used as uart OR i2c) :

mpconfigboard.h

#define MICROPY_HW_UART3_TX (pin_B10)
#define MICROPY_HW_UART3_RX (pin_B11)

#define MICROPY_HW_I2C2_SCL (pin_B10)
#define MICROPY_HW_I2C2_SDA (pin_B11)


and later on, in .py application, we called :

uart3 = pyb.UART(3, 9600)

an in some OTHERS application on different board with B10 and B11 assigned as i2c, we do :

i2c2 = pyb.I2C(2, pyb.I2C.MASTER)


The point is, I want to use single, unchanged micropython image, to support multiple hardware application.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: multi peripheral functionality on same pin

Post by dhylands » Sun Aug 27, 2017 4:35 am

That should work fine.

You can use the pins_af.py from the build directory for your board, and the examples/pins.py file to print out the current settings of the alternate functions and verify that things are setup the way you think they are.

User avatar
TravisT
Posts: 72
Joined: Sun Feb 23, 2014 2:31 pm
Location: Portland, OR
Contact:

Re: multi peripheral functionality on same pin

Post by TravisT » Fri Nov 10, 2017 6:49 am

Maybe I am not seeing it, but it seems like the CAN interface is one of the few that do not let me pass different pin assignments to, like SPI.

I looked up the pin alternative function from the REPL and both B13 and B5 do not show CAN as options, even though I know from the STM32CUBEMX and the DFU documentation say it is.

How would you go about doing this?
_______________
Travis Travelstead

User avatar
TravisT
Posts: 72
Joined: Sun Feb 23, 2014 2:31 pm
Location: Portland, OR
Contact:

Re: multi peripheral functionality on same pin

Post by TravisT » Fri Nov 10, 2017 6:56 am

Ignore that last post. I posted on the wrong topic, and have not yet found how I can delete a post.
_______________
Travis Travelstead

Post Reply