Bluetooth Low Energy (a.k.a Bluetooth LE, BTLE, Bluetooth Smart)

Dynamic Pin assignment (I2C, etc)

22 Oct 2014

Crossposting this thread here: http://developer.mbed.org/users/nemovn/notebook/assigning-i2c-pins-manually-/

I think we need a way to support the super awesome GPIO capabilities of the NRF chip, currently the api limits pin selection.

A possible solution can be found here: http://developer.mbed.org/users/jaerts/code/I2CX/

It would be great if we can merge similar functionality into the core mbed api (so that it can be used with platforms that support this).

22 Oct 2014

Hi Joris,

you are already at least 3rd person within a week asking about this issue. We are aware of it, as I created an issue on github. You can also update us via https://github.com/mbedmicro/mbed/issues/573.

I believe github mbed SDK issues should be the issue tracker where we can connect that with commits/pull requests and track progress.

Do you think you can implement your proposed changes in the mbed HAL for NRF51 targets?

0xc0170

23 Oct 2014

You can always initialize your peripherals usnig pin-names directly; without needing to resort to the official mapping. This would hurt the portability of your programs to other platforms, but that's your choice.

Here's an example:

I2CX i2c(I2C_0, p28, p27);

The user has used pins 27 and 28 directly for data and clock instead of symbols such as I2C_SDA0 or I2C_SCL0.

28 Dec 2014

I'm newbie with mBed, so I did a lot of learning those past days.

I've experimenting I2C on an chinese LPC1768 board, and on my first trial, the controller was freezing not even reaching the main(). I figured out that I2C constructor using physical pins was the issue, ie. : "I2C i2c(P0_28, P0_27);". I was trying to use the SDA0/SCL0 of the LPC1768 which are share with P0_27/P0_28 GPIOs, pure coincidence about the numbering of those pins, because on mBed board, they are not even connected, the p27/p28 of the mBed are in fact P0_10/P0_11 which are SDA2/SCL2.

If I use the same I2C port SDA2/SCL2, everything is working. But what I should do if I really want to use SDA0/SCL0 or SDA1/SCL1 (which is also not connected on mBed) ? I've tried the I2CX mentionned above, but I can't get it compile, it complains about missing _i2c.sda/_i2c.scl members ...

29 Dec 2014
29 Dec 2014

That what I've done in the first place... But, as I mentionned in my post, just instantiate an object using "I2C i2c(P0_28, P0_27);" make the whole CPU freezing, not reaching the main(). I will digg more those SDK files that I've already seen before doing my post, but I think there a bug related to those PinMapping magics done on the fly ...

29 Dec 2014

Martin, mbed freezes because you mixed up SDA and SCL in the declaration. Try

I2C i2c (P0_27, P0_28)
29 Dec 2014

Thanks a lot, Wim. It is now working ! It's a shame that I didn't catch that before. I was probably confused by the numeric concidence with the orignal example "I2C i2c(p28, p27)" ...

29 Dec 2014

Martin,

In essence you were using the microcontroller pin names, not the friendly pin names. on the LPC1768 the microcontroller pin P0_27 maps to friendly name p28, and microcontroller pin P0_28 maps to friendly name p27, so either of the following will work

I2C i2c(P0_27,P0_28) or I2C i2c(p28,p27)

-Austin