chillyjee 2 Posted April 12, 2016 Share Posted April 12, 2016 Hello everyone, I am a newbie here, just received my MSP432 launchpad few days ago and I'm willing to develop a wireless bluetooth communication between my MSP432+Bluefruit LE SPI and my computer. I downloaded the librairies from Adafruit that are designed for Arduino and I think I succeeded to convert a honest part of the code for Energia. Though, I still have an important problem that stops me to go forward. Indeed the Bluefruit LE SPI dongle communicate through some commands called ATCommand, and I don't succeed to transmit those commands through the dongle. As an example this is the original Arduino code for a factory reset of the bluetooth device : /* Perform a factory reset to make sure everything is in a known state */ Serial.println(F("Performing a factory reset: ")); println("AT+FACTORYRESET"); bool isOK = ble.waitForOK(); // Bluefruit need 1 second to reboot delay(1000); // flush all left over ble.flush(); if ( ! isOK ){ error(F("Couldn't factory reset")); } In Arduino they use the println to transmit the command but in Energia I just get the "AT+FACTORYRESET" back in my Serial monitor but don't believe the device receives it. I tried to use SPI.transfer to send the message the following way but still get a failure result for the factory reset process : bool Adafruit_BLE::factoryReset(void) { char c; SPI.begin(); // println("AT+FACTORYRESET"); for (const char * p = "AT+FACTORYRESET" ; c = *p; p=p+2) { digitalWrite(18,LOW); SPI.transfer(0x10); // First Byte indicating that a COMMAND is sent according to Adafruit SDEP protocol SPI.transfer(c); // First byte of data const char * d = p+1; char e = *d; // Second byte of data SPI.transfer(e); digitalWrite(18,HIGH); } println("AT+FACTORYRESET"); bool isOK = waitForOK(); // Bluefruit need 1 second to reboot delay(1000); // flush all left over flush(); return isOK; } If anyone succeeded to connect this bluetooth dongle through SPI with MSP or has an idea of how to do it, pleeaase help me PS : It seems that this operation (like any other) is not achievable because the IRQ pin (This is the nRF51 -> Arduino 'interrupt' pin that lets the Arduino or MCU know when data is available on the nRF51, indicating that a new SPI transaction should be initiated by the Arduino/MCU) is never on HIGH. It is weird because normally after received any command message, it is supposed to turn on... Quote Link to post Share on other sites
BRey 22 Posted April 13, 2016 Share Posted April 13, 2016 I had to add an "SPI.setDataMode(SPI_Mode0);" call to make the MSP432 SPI work using the Reaper's UIPEthernet library. Also, it defaults to LaunchPad Pin 18 for CS and the SPI library manages the CS. If you want a different CS you use SPI.begin(SS); where SS is the PIN number you are using. Most of the code I have seen manipulates the CS outside the library so specifying the CS in the SPI.begin may not matter although I think the SPI library will mess with Pin 18 if you don't which may cause other problems. I am planning to continue testing tonight trying to clarify some of the MSP432 issues I am seeing. B Quote Link to post Share on other sites
chillyjee 2 Posted April 14, 2016 Author Share Posted April 14, 2016 I found the solution, the data wasn't transmitted correctly initially so there was nothing on the buffer and so the process was stuck in an available()==0 loop. I finished to code this driver completely (I think ?), here is a link for you folks : https://github.com/chillyjee/BluefruitSPI Developed for MSP432 but surely compatible with any MSP43x platform Leave any questions. Sterny 1 Quote Link to post Share on other sites
Sterny 12 Posted April 14, 2016 Share Posted April 14, 2016 Thanks porting the library! I've got some of those BlueFruits that I use with Arduino. I'll give it a try on a few Launchpads and Energia. Quote Link to post Share on other sites
chBalian 0 Posted May 10, 2016 Share Posted May 10, 2016 chillyjee, This is pretty damn cool! Nice work. I also have a Texas Instruments MSP432 P401 Launchpad, and I've been playing around with it to familiarize myself with the board. I would like to implement you project into my MSP board, and see what it can do (as I also have a Bluetooth LE UART Friend; not sure which Bluetooth LE you are using) Can I ask quickly how you tested your code? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.