energia / Energia

Fork of Arduino for the Texas Instruments LaunchPad's
http://energia.nu
Other
795 stars 671 forks source link

Add SPI(1) and I²C(1) on MSP430F5529 #298

Open rei-vilo opened 10 years ago

rei-vilo commented 10 years ago

The MSP430F5529 includes more than 1 SPI port and more than 1 I²C port.

As at today, Energia only implements SPI(0) and I²C(0).

MISO (1) on P4_2 or 9 MOSI (1) on P4_1 or 10 SCK (1) on P4_3 or 34 CS (1) on P4_0 or 33

SCL (1) on P4_2 or 9 SDA (1) on P4_1 or 10

dd430 commented 10 years ago

In addition to enable this support, per the LaunchPad pin-out standard @ http://www.ti.com/ww/en/launchpad/img/launchpad-byob-pinout.png (that many existing and all future 'compliant' BP should follow), consider setting SPI(0) & I2C(1) as default communication option for F5529 LP board.

alfh commented 10 years ago

I'm trying to get the U2C(1), i.e. USCB_1 module to work on F5529 Launchpad.

The code is here https://github.com/alfh/Energia/tree/feature_i2c_uscb1, commit : https://github.com/alfh/Energia/commit/87946986d775f4fdd3894537497daa6136e5e167

It is not working yet. It is working for USCB0, but not for USCB1. I will write to the Energia forum for some help

alfh commented 10 years ago

I'm making progress on getting this to work, see http://forum.43oh.com/topic/5174-getting-i2c1-ie-usci-b1-to-work-on-f5529-launchpad/

I will commit more code to github shortly.

alfh commented 10 years ago

The code in https://github.com/alfh/Energia/tree/feature_i2c_uscb1 is now working for me, it allows me to use "Wire" for USCI_B0, and "Wire1" for USCI_B1. The code still needs clean up, and review, before I will make a pull request to merge the code.

robertinant commented 10 years ago

Awesome! I'll wait for the pull request so that we can review.

rei-vilo commented 10 years ago

Could you please provide an example?

I've downloaded and compiled your Energia fork and I'm trying to test the library.

With the following code for the MSP430F5529, #include "Wire.h", I have the following error when compiling

[/Users/ReiVilo/Desktop/Energia.app/Contents/Resources/Java/hardware/tools/msp430/bin/msp430-g++, -c, -g, -Os, -w, -ffunction-sections, -fdata-sections, -mmcu=msp430f5529, -DF_CPU=25000000L, -MMD, -DARDUINO=101, -DENERGIA=12, -I/Users/ReiVilo/Desktop/Energia.app/Contents/Resources/Java/hardware/msp430/cores/msp430, -I/Users/ReiVilo/Desktop/Energia.app/Contents/Resources/Java/hardware/msp430/variants/launchpad_f5529, /var/folders/5d/dky9xc691m32kztqnhkn8bhw0000gn/T/build8620168210632241345.tmp/F5529_two_I2C.cpp, -o, /var/folders/5d/dky9xc691m32kztqnhkn8bhw0000gn/T/build8620168210632241345.tmp/F5529_two_I²C.cpp.o]

In file included from F5529_two_I2C.ino:1:0:

/Users/ReiVilo/Desktop/Energia.app/Contents/Resources/Java/hardware/msp430/cores/msp430/Wire.h:36:2: error: 
#error "********** USI not available"

/Users/ReiVilo/Desktop/Energia.app/Contents/Resources/Java/hardware/msp430/cores/msp430/Wire.h:40:2: error: 
#error "********** USCI not available"

Thank you!

rei-vilo commented 10 years ago

Thank you for your answer on the 43oh forum.

Adding #include "Energia.h" solved the problem.

However, this pre-processing statement is optional, as the Energia IDE adds it automatically. So something goes wrong here.

I'm going to test my example now and keep you updated.

rei-vilo commented 10 years ago

I've tested Wire and Wire1 with a HMC6352 and everything runs fine.

Only remains the #include "Energia.h" statement that should remain automatic.

alfh commented 10 years ago

I've made pull request #398 for this, to get the process started on reviewing my changes.