Quote:
Originally Posted by agraham
Version 1.4 now posted corrects the method signature for OpenSpiMaster which I totally screwed up originally by being careless.
|
hello agraham,
I tested the SPI with an EEPROM - AT25AA320. and the code:
If FirstTime=True Then
activity.AddMenuItem("UART","aUART")
activity.AddMenuItem("I2C","aI2C")
activity.AddMenuItem("SPI","aSPI")
activity.AddMenuItem("IO","aIO")
activity.AddMenuItem("ADC","aADC")
activity.AddMenuItem("WiFi","aWiFi")
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
Dim spi As SpiMaster
Dim slavepins() As Int
slavepins = Array As Int(6, 7, 10)
Dim slavemodes() As Object
slavemodes = Array As Object( spi.OP_NORMAL, spi.OP_NORMAL, spi.OP_NORMAL)
spi=YOYO.OpenSpiMaster(3, spi.IP_PULL_UP, 4, spi.OP_NORMAL, 5, spi.OP_NORMAL, slavepins, slavemodes, spi.RATE_125K, False, 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
suc=True
Do While (suc=True)
wBuffer(0)=0x05
If Spi.IsInitialized=True Then
spi.WriteRead(0,wBuffer,1,2,rBuffer,1)
lbStatus.Text="Read " & 1 & " bytes. @ " & DateTime.Time(DateTime.Now)
txtRX.Text=rbuffer(0)' Bit.ToHexString(rbuffer(0))
Else
Msgbox("NOT ready","")
End If
waitms(1000)
Loop
End If
*****************
the results were:
1. compilier was good with no error.
2. connected to IOIO with pins: 3,4,5,6, MISO,MOSI,CLK,CS. and data read.
3. send 0x05 to read eeprom's register byte and return should be 0x8C, but it showed "-116", negative? so strange.
4. confirmed the signal with LogicPort and is OK.see attached file
5. need to know how to convert -116 to 0x8C = 140 (256+(-116))=140, but how does it happen with a byte array?
thank you for your quick fix on lib. did you buy apple?