• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Converting C to Oshonsoft

Status
Not open for further replies.

camerart

Active Member
Hi,
I'm trying to translate some code from C to Oshonsoft, and I'm a bit stuck!

Here is the code below for a PIC controlled radio module SX1278. If it's understandable, how would this be written in Oshonsoft please?
Camerart.

Variables;
SIZE
X
LENGTH
DATA

FROM SX1278 DATA SHEET
Reading the SX1278 RxNbBytes Register gives the number of bytes received so far = SIZE
Reading the FIFO is receiving the DATA

Writing the PayLoadLength sets number in the Register
Write FIFO DATA Transmit FIFO DATA until x = LENGTH

CODE:

size = ReadSPI(GetRxNbBytes())
while (x < size)
SPIRead(GetFifo())
x = x+1

WriteSPI(SetPayloadLength(length))
while (x < length) {
WriteSPI(SetFifo(data[ x ]))
x = x+1
 
Last edited:

Ian Rogers

User Extraordinaire
Forum Supporter
Most Helpful Member
That isn't C... That is basic... Or someone is rubbish at C... C must have ';' at the end of each statement..

Its more like a cross between the two....

In Oshonsoft ( after setting the SPI definitions )

SPICSON
SPISEND rxnbytesADDR
SPIRECIEVE rxnbytes
SPISEND fifoADDR
for i = 0 to rxnbytes-1
SPIRECIEVE data(i)
next i
SPICSOFF

Something like this UNTESTED!!!!!
 

camerart

Active Member
That isn't C... That is basic... Or someone is rubbish at C... C must have ';' at the end of each statement..

Its more like a cross between the two....

In Oshonsoft ( after setting the SPI definitions )

SPICSON
SPISEND rxnbytesADDR
SPIRECIEVE rxnbytes
SPISEND fifoADDR
for i = 0 to rxnbytes-1
SPIRECIEVE data(i)
next i
SPICSOFF

Something like this UNTESTED!!!!!
Hi I,
You're correct, that it's rubbish C. I wrote it from C notes, and I can't speak C:), but you appear to have understood it.

I before E except after C ;)

Thank you, C.
 

camerart

Active Member
Hi,
I spoke too soon! It is just too difficult, because there are too many differences between the code I'm transferring and Ian's code, and it would be better if it was in two sections, as there is a fair bit that goes on between them.
Also it would be better if it had the same variables please.
C.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top