Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SCL and SDA defs for I2C[0-2]; redefine I2C_[SCL,SDA] to I2C2 #4102

Merged
merged 1 commit into from
Apr 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions targets/TARGET_NXP/TARGET_LPC176X/TARGET_MBED_LPC1768/PinNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,17 @@ typedef enum {
A4 = P1_30,
A5 = P1_31,

I2C_SCL = D15,
I2C_SDA = D14,

// Not connected
NC = (int)0xFFFFFFFF
NC = (int)0xFFFFFFFF,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this should probably be declared at the end of the enum. If someone came along and added a new pin, the enum may overflow (since enums increment from the last value). I'm not entirely sure what happens at that point.

Copy link
Contributor

@geky geky Mar 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I just looked it up, the enum will just upgrade to uint64_t. It's up to you if you want it at the end.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving the NC to the bottom and removing the , would result in a smaller diff.

Copy link
Contributor Author

@wdwalker wdwalker Mar 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing I was attempting to do here was use NC to indicate I2C0 was not connected on the LPC1768 and allow any error-checking code to kick in. In order to do that, NC needs to be ahead of these lines:

I2C_SCL0 = NC,
I2C_SDA0 = NC,

Alternatively, I could just omit these lines and leave NC at the bottom of the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW - at this point in this particular file, it seems as though all auto-increment for the enum is pretty much done with and we're in a section where the rest of the enum items are forced to have a specific value.


I2C_SCL0 = NC,
I2C_SDA0 = NC,
I2C_SCL1 = p10,
I2C_SDA1 = p9,
I2C_SCL2 = p27, // pin used by application board
I2C_SDA2 = p28, // pin used by application board
I2C_SCL = I2C_SCL2,
I2C_SDA = I2C_SDA2,
Copy link
Contributor

@bridadan bridadan Apr 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this is going to be a breaking change. I2C_SCL used to follow this map I2C_SCL->D15->P0_28. After these changes, I2C_SCL will follow this map: I2C_SCL->I2C_SCL2->p27->P0_11. I2C_SDA is also following a different mapping. This will break any current application that use the I2C_SCL and I2C_SDA pin names.

} PinName;

typedef enum {
Expand Down