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

msp430: i2c, allow choosing which USCI_Bx module to use #590

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

alfh
Copy link

@alfh alfh commented Mar 29, 2015

The Launchpad F5529 supports both USCI_B0 and USCI_B1 for i2c communcation.

This pull request adds support for choosing which module to use, by adding a "Wire.setModule(1)" before doing "Wire.begin()" in a sketch.

So this pull request allows one to choose which module to use, but it does not allow one to use both modules.

This is an attempt at making a simpler, i.e. less changes, pull request than pull request #398.
I think as a first step, it would be nice to at least choose which module to use.

Comments are appreciated.
Is there for example a better way to switch between registeres for USCI_B0 and USCI_B1 than using pointers ?

Note that this pull request also contains some i2c cleanup, which I've made separate pull requests for.
So I think the other pull requests should be merged first, and then I could rebase this pull request.

But I wanted to have the code as nice as possible in this pull request, so you can comment on what you like and dislike.

Regards
Alf Hogemark

alfh added 12 commits March 27, 2015 11:12
Replace #ifdef with #if defined, to consistently use
if defined in the twi.c file.
Likewise, replace ifndef with if !defined.
…SCB1

Replace hardcoded USCB0... registers with use of UCBx defines, so
we can choose if we want to use USCB0 or USCB1.
The family guide suggests that pin mode should be set just
before enabling the module.
Each MSP430 have just one type of module, USI, USCI,
USCI_Bx, or EUSCI_Bx, so make code more readable
by using #if #elif for the code that is different
for the different modules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants