SI4707 Library Port Request

I have placed all the files from the Arduino Library for the Si4707 into a github repo. Would someone be able to help me figure out how to change what I have to work properly with Spark?

I know there is a SI4707_PATCH.h file that loads data into program mem on the arduino that will have to be added to the .cpp file and then change the function on how to call it but I can deal with that if I can get the rest of the code to work.

Thanks!!

1 Like

@AIW, from a quick first look, all the hardware specific code will have to be modified and the 1 second timer interrupt can be implemented with the SparkIntervalTimer library. The patch file uses a PROGMEM construct used in Arduino land to put stuff in flash instead of memory. For the Spark, making the array “const” puts it in flash. How advanced are you at programming? :smile:

1 Like

@peekay123, Thanks for the tip! I had to do some similar changing of the hardware related calls when I converted to Python for RaspPi. Most of it was all related to interrupt or interrupt service routines. I just got rid of them or commented them out and then added an attachInterrupt() in the setup loop to look for the interrupt pin to fall and then call the proper function. Changed the patch to a const array as well. It all compiles correctly. Now I just need to hook everything up on the breadboard and see what happens.

Feel free to take a look at the updated files if you want. I updated the README to be a little more descriptive as well.

I’ve hooked up the radio module but it seems as if the I2C functions aren’t working as normal. I can’t get the radio to initialize. Does the I2C operation need to be changed or should everything written for Arduino Wire Library work the same in Spark?

@AIW, I am not sure if the SI4707 board you have has these but the Spark needs both I2C lines to be pulled up to 3.3v using 4.7K ohm (up to 10K) resistors. :smile:

Yes, I’m using the low voltage side of an Adafruit I2C level shifter. So both the Spark and the Radio Module are pulled up by the 3.3V 10K’s built into that. The 5V side of that adapter is not connected at all.

I’ve read some issues on the bus address for the I2C in the past. It’s 7-Bit address is 0b0010001 (0x11). Do I call it with this address or do I need to call an 8-bit address. In the past we have used 0x22 >> 1 if needed, but I’ve tried both. I may try another module just to be sure its the code.

@AIW, the SI4707 board works fine with 3.3V! Just look at their “Raspberry Pi Operation” section. It says:

**Remember that Raspberry Pi I2C operation is already 3.3V bus and the pull up resistors for I2C are already installed on the Raspberry Pi, so no need to add those.

So you don’t need the level converter, just pull-up resistors. However, have the level converter won’t stop it from working I suspect.

The I2C address does not need to be shifted, however all I2C addresses are 7-bits anyway. So you would call it with address 0x11 which IS the 7-bit address.

Yes, I know they are both 3.3V devices. The level convertor wasn’t to shift the I2C voltage, I was just trying to take advantage of the 10K pullups on one side of the device since I didn’t have any spares laying around. I’ll bring home some 4.7K resistors today and give it another run.

To make things a little more streamlined, I added the code from the DEFENITIONS.h file to the SI4707.h and added the PATCH.h info to the cpp file.

I’ll give this another go this evening. Thanks again for staying in touch on this.

Got it working, with some changes.

  1. Added the 4.7K pullups
  2. Added a while(!Serial.available( )) at the beginning of the setup (saw this in forum post, https://community.spark.io/t/installing-the-usb-driver-on-windows-serial-debugging/882/23) to help establish the coolTerm/putty connections reliably.
  3. I had problem with the attachInterrupt() call that I normally use so I made a new function at the end of the example just to change the value of the intStatus variable to indicate it needed to be checked. Before I did this it would lock up the program as soon as it attached the interrupt. I need to send a viable SAME message to test the interrupt feature in the next day or so. But in the meantime all menu options are working…tune, scan, volume, mute, reprint menu, etc…

All files in the repo are up to date as of this post.

Just to add. If you look at the items needed for audio, you will notice that an amp is required for an 8 ohm speaker. You will need a separate 5V source to power that amp. If you are running the audio from the module directly to a line in or pc speakers with their own integrated power supply and volume control should be able to feed the audio directly to those from the module. Once I have tested all the features I will also add a Spark operation page to my website. www.aiwindustries.com

1 Like