about SPI and I2C in IOIO Lib

eric010101

Member
Licensed User
Longtime User
Hi,
I wonder if IOIO lib will support SPI and I2C bus soon.
It would be great if Android can talk to I2C or SPI sensors through IOIO using B4A, Isn't it.
 

eric010101

Member
Licensed User
Longtime User
good to hear TwiMaster is working

with TwiMaster, we, B4A user can use I2C devices, and it will open up a door for IOIO user to talk to sensors, clocks etc. I personally used I2C RH/Temp sensors in a WSN project. I would like to test your TwiMaster Lib in my project. Right now I still have to use a 8051 to read data from sensors and then pass it to Android through IOIO Uart port.

by the way, I found that I can't use serial or AStreams to read uart data from IOIO, but I, finally, figured out a way to read it directly from inputstream. I have to define buffer size exactly the size in in1.BytesAvailable.

Sub Timer2_Tick
If in1.BytesAvailable>0 Then
Dim buffer(in1.BytesAvailable) As Byte
Dim count As Int
count = in1.ReadBytes(buffer, 0,BUFFER.Length)
LABEL2.Text="Read " & count & " bytes."
txtLog.Text=BytesToString(buffer, 0, count, "UTF8")
End If
end sub

it would not work if I use

Dim buffer() As Byte

I don't know why, but it just worked fine for me after 24 hours testing with a lot of data stream, It didn;t miss a byte, isn;t that great?

can I try you TwiMaster Lib? or I need to wait for a while?

anyway, thank you for let me know you are working on that.
 
Last edited:
Upvote 0

agraham

Expert
Licensed User
Longtime User
I don't know why the input stream doesn't behave as expected but I just pass it on and don't do anything in the library to it. Perhaps the IOIO library implementation is a bit off. Anyway glad you got it to work in the end.

Version 1.3 now posted has TwiMaster and SpiMaster implemented.
 
Upvote 0

eric010101

Member
Licensed User
Longtime User
incompatibilityException IOIO

Hi,

I tried IOIO Lib1.3, and try to run the demo program, and found an exception while running YOYO.WaitforConnect()
the error was:

ioio.lib.api.exception.incompatibilityException: IOIO firmware does not support required firmware: IOIO0003.

What happen?

Help Needed.

p.s. I did copy lib to the liberary folder and replaced those 4 old files.
and in the IDE, it shows the IOIO is version 1.3 but the IOIOlib is Version 1.0, but I did copy files to the folder, why the version is different.
after cheking my hardware, I am using yoyo.VER_FIRMWARE=IOIO0100, yoyo.VER_HARDWARE=SPRK0016, So where can I get IOIO0003 firmware?
 
Last edited:
Upvote 0

agraham

Expert
Licensed User
Longtime User
Did you try to use IOIO 1.2? The IOIOlib version in the IOIO 1.3 archive is the same as in the 1.2 archive and is IOIO10300. This is different to the IOIOlib in the 1.1 archive which was IOIO0100. I needed to change IOIOlib in 1.2 to support the new PulseInput.

The IOIO https://github.com/ytai/ioio/wiki/Downloads page says that the IOIOlib version IOIO0302 (a couple of points on from IOI0300) supports all firmwares but this seems to be a lie as it explicitly checks for firmware IOIO0003.

There is a link to an IOIO Manager Application that lets you upgrade the firmware on your board here https://github.com/ytai/ioio/wiki but I can't see the IOIO003, or any, firmware image to use with it.

It looks like the IOIO software/firmware matching is a bit of a mess. I've attached the original IOIO0100 lib. It uses the same xml file as you've got which is why it didn't show a version change.
 

Attachments

  • IOIO0001lib.zip
    64.2 KB · Views: 416
Upvote 0

agraham

Expert
Licensed User
Longtime User
I found the firmware. It's what they call the "Application Image Bundle (click or scan)" here https://github.com/ytai/ioio/wiki/Downloads. Load the one for 3.2 with the IOIO Manager Application and hopefully it will work with the new IOIO 1.3 library. Post in this thread what happens. I'll update the IOIOlib to IOIO0302 some time soon.
 
Upvote 0

eric010101

Member
Licensed User
Longtime User
MISSING ioio1.2.ZIP

I can't find IOIO1.2.zip anymore in this forum. I did tried IOIO manager, but my Firmware is IOIO0001, The Manager require IOIO00200, So I am stuck here, can you repost the link for IOIO1.2.zip, So I can give it a try.

I will also try to upgrade my IOIO firmware if I can understand how.

I just purchased the IOIO board a month ago, I don't know why Sparkfun give me boards that contains old firmware.

This could a potential harzard for me if I want to promot B4A and IOIO in china and Taiwan.

despite of this inconvient, I think B4A is a great product, I am working on writting a book to introduct B4A in chinese.

by the way, I post a UART sample project in other post, hope you can give me some comments

Help is still needed.

best,

Eric Wang
there is a cyclone (Typhoon) just next to my hometown, so I got oneday off that I can concentrate on IOIO. How's cyclone Irene in the state, do you get day off also?
 
Upvote 0

eric010101

Member
Licensed User
Longtime User
Problem fixed

I tried to run App-IOIO0200.zip and I found no error on firmware. good.
I don't kn ow why, but It seems when I run APP-IOIO, it rewrite the firmware.

now, I can have your IOIOlib1.3 running, but I still need to figure out how to read data from I2C and SPI master.

I'll keep you posted once I have the working code.

Thanks for the HELP.

ERIC WANG
SWEETEK
 
Upvote 0

eric010101

Member
Licensed User
Longtime User
need little luck

I tried TwiMaster to read data from a DS1307 I2C RTC, and it keep shows an ConnectionLostException error, checked signals SDA and CLS with logic analyzer, found no signal been sent at all. any idea?

anyone working on I2C? I need friends. haha!

Eric
 
Upvote 0

eric010101

Member
Licensed User
Longtime User
I2C done

hi,

I have my I2C worked. read DS1307 RTC, from IOIO pin25(SCK) & pin26(SDA) Here is my code:


YOYO.Initialize
YOYO.WaitForConnect()
TWI=yoypenTwiMaster(2,Twi.RATE_100KHz,False)
Dim wBuffer(2) As Byte
Dim rBuffer(7) As Byte
Dim Rs() As Boolean
Dim suc As Boolean
Dim tmp As String
Do
wBuffer(0)=0
wBuffer(1)=0x68
If twi.IsInitialized=True Then
result=TWI.WriteRead(0x68,False,wbuffer,1,rBuffer,0)
result=TWI.WriteRead(0x68,False,wbuffer,0,rBuffer,7)
If result=True Then
lbStatus.Text="Read " & 7 & " bytes. @ " & DateTime.Time(DateTime.Now)
txtRX.Text= Bit.ToHexString(rbuffer(6)) & "/" & _ 'sec
Bit.ToHexString(rbuffer(5)) & "/" & _ 'min
Bit.ToHexString(rbuffer(4)) & " " & _ 'hour
Bit.ToHexString(rbuffer(2)) & ":" & _ 'day
Bit.ToHexString(rbuffer(1)) & ":" & _ 'month
Bit.ToHexString(rbuffer(0)) 'year
End If
Else
Msgbox("NOT ready","")
End If

Loop

it will display date/time like this: 11/8/30 0:40:21 on txtRX.
 
Upvote 0

eric010101

Member
Licensed User
Longtime User
IOIOlib 3.2 Tested and is good for I2C

:sign0060:

IOIOlib 3.2 Tested and is good for I2C with DS1307. pin25 & 26 used.

code:

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim period As Int
Dim TimerLoop As Timer

Dim btnSend As Button
Dim btnSetUp As Button
Dim Label1 As Label
Dim Label10 As Label
Dim Label3 As Label
Dim Label4 As Label
Dim Label5 As Label
Dim Label6 As Label
Dim Label7 As Label
Dim Label8 As Label
Dim Label9 As Label
Dim rbtn_loop As RadioButton
Dim rbtn_Single As RadioButton
Dim spn_TWIRate As Spinner
Dim spn_Twimode As Spinner
Dim spn_Addbit As Spinner
Dim txt_Readbytelength As EditText
Dim txt_Writebytelength As EditText
Dim spn_Period As Spinner
Dim txtRX As EditText
Dim txtAddress As EditText

Dim PeriodMap As Map
Dim p_uart As Panel
Dim lbStatus As Label

Dim YOYO As IOIO
Dim led As DigitalOutput
Dim go As Boolean
Dim TPeriod As Int
Dim looped As Boolean
Dim LedFlag As Boolean

Dim TWI As TwiMaster
Dim chk_SMBUS As CheckBox
Dim smBUS As Boolean
Dim TWIMODE As Int
Dim TWIRATE
Dim WriteByteLength As Int
Dim ReadByteLength As Int
Dim tenbitadd As Boolean
Dim TWIaddress As Int
'Dim TWI As TwiMaster

End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("aI2C")
activity.Title="IOIO I2C TEST READ DS1307"
If FirstTime Then
activity.AddMenuItem("UART","aUART")
activity.AddMenuItem("I2C","aI2C")
activity.AddMenuItem("SPI","aSPI")
activity.AddMenuItem("IO","aIO")
activity.AddMenuItem("ADC","aADC")
SetSpinner
'default mode0,DA=4, CL=5, rate=100KH)
spn_Twimode.SelectedIndex=2
spn_TWIRate.SelectedIndex=0
spn_Period.SelectedIndex=4
spn_Addbit.SelectedIndex=0
txt_WriteByteLength.text=1
txt_ReadByteLength.text=7
txtAddress.Text="104"
TimerLoop.Initialize("TimerLoop",1000)

go=False
looped=False
rbtn_Single.Checked=True

YOYO.Initialize
YOYO.WaitForConnect()
led = YOYO.OpenDigitalOutput(0,led.OP_NORMAL ,True) ' Enable LED_PIN for output
getSetUPValue
TWI=yoypenTwiMaster(2,Twi.RATE_100KHz,False)
Dim i As Int
Dim wBuffer(2) As Byte
Dim rBuffer(7) As Byte
Dim Rs() As Boolean
Dim suc As Boolean
Dim tmp As String
For i=1 To 5
wBuffer(0)=0
If twi.IsInitialized=True Then
result=TWI.WriteRead(0x68,False,wbuffer,1,rBuffer,0)
result=TWI.WriteRead(0x68,False,wbuffer,0,rBuffer,7)
If result=True Then
lbStatus.Text="Read " & 7 & " bytes. @ " & DateTime.Time(DateTime.Now)
txtRX.Text= Bit.ToHexString(rbuffer(6)) & "/" & _ 'sec
Bit.ToHexString(rbuffer(5)) & "/" & _ 'min
Bit.ToHexString(rbuffer(4)) & " " & _ 'hour
Bit.ToHexString(rbuffer(2)) & ":" & _ 'day
Bit.ToHexString(rbuffer(1)) & ":" & _ 'month
Bit.ToHexString(rbuffer(0)) 'year
End If
Else
Msgbox("NOT ready","")
End If
waitms(1000)
Next

End If

End Sub

Project will be posted later.

Best,

Eric
 
Upvote 0

ytai

New Member
I noticed there's a bit confusion about the versioning system. Let me clarify:
All firmware to date is backward-compatible. Meaning that it'll work with older versions of the Android libraries, saving you the need to rebuild all your apps if you upgrade the firmware. It is not, however, forward-compatible. So any app built with a new version of the library will require upgrading the firmware.
The "supported platforms" column on the IOIO Downloads page refers to supported boards and bootloader combinations, not to library versions, so the term "lie" in this context is a bit harsh
One last note, because of the sudden and unexpected death of Codaset, I had to quickly port everything to Github, resulting in some of the links being broken for some time. This should have been fixed by now, and all downloads should work. Sorry for the inconvenience.

Ytai
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Nice to hear from you - and thanks for designing and supporting IOIO.
The "supported platforms" column on the IOIO Downloads page refers to supported boards and bootloader combinations, not to library versions, so the term "lie" in this context is a bit harsh
Apologies, it looked to me that (say) "IOIO0300" was an IOIOlib version and "IOIO0003 "was the matching firmware version as that is what IOIOlib does an explicit check for using IOIOimpl.REQUIRED_INTERFACE_ID. It seems you are also using the same "IOIO0003" to refer to a board/bootloader version or am I still confused?
 
Upvote 0

ytai

New Member
The versioning system works roughly as follows:
A version identifier is a 4 chars "authority" + 4 chars "version". I'm using authority "IOIO", but the thought is that different people can use different authorities, thus avoiding compatibility problems (e.g. the SparkFun boards are versioned with authority "SPRK").
Then, there are several parts of the system that are versioned: the hardware, the bootloader implementation, the bootloader-app interface ("BLAPI"), the app-android interface, the firmware implementation version, IOIOLib implementation version, etc. The version numbers for different components may or may not overlap. IOIOLib version IOIO0302 will not necessarily correspond to firmware version IOIO0302. I did, however, try to make some sense with the major version numbers, but that's just how it makes sense to me, and the version numbers are not generally intended for human interpretation. The table on the Downloads page should tell you which versions go with which.
I'm not trying to say anything in favor or against this system, just to describe how it works.
What's really missing is some deeper explanation along these lines to be present in the Wiki, with a complete listing of version numbers used so far and their meaning. That's something that I haven't gotten around to doing unfortunately. Right now, I've only been managing this list on a private spreadsheet.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
TThe version numbers for different components may or may not overlap.
Understood thanks. I am (was! - now retired ) accustomed to systems where every component, software or hardware was uniquely versioned/part numbered/issue numbered so I made an unwarranted assumption that it was so in this case.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…