tabemann / zeptoforth

A not-so-small Forth for Cortex-M

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sending a buffer over SPI without discarding the result ?

max22- opened this issue · comments

Hi,
i am trying to port some C code to forth, to read some data from a MCP3008 digital to analog converter.
i need to send 3 bytes, and receive 3. i managed to do it using >spi and spi>, but is there any faster way to do it ?
unfortunately buffer>spi discards the result, and spi>buffer uses a constant filler byte (i need to send 3 different bytes).
thanks
Maxime

Are you using the RP2040? Because if you are there is the word buffer>spi-raw-dma ( buffer bytes dma1 dma0 spi -- last-data ). Note that for this word you need to provide your own DMA channels (which can be dynamically allocated with dma-pool::allocate-dma), and it only reports back the last unit of data received.

Travis

Unfortunately i need the last 2 bytes of data :(

i think in the release this word is not present, if i am right ?
i've cloned the repo and built it from source, to try this word, but when i send setup_full_usb.fs i get this error :
\ Iterate executing an xt over a byte array : citer ( ??? addr count xt -- ??? ) ( xt: ??? c -- ??? ) { xt } over + { addr end-addr } begin addr end-addr u< while addr c@ xt execute 1 +to addr repeat unable to parse: addr at Line 70 in File ./src/common/forth/lambda.fs

ok thank you !

for the error, i have run "make", copied the uf2 on the board (a xiao rp2040), then with e4thcom i've run
#include src/rp2040_big/forth/setup_<type>.fs
as mentioned in the readme.
maybe i've done something wrong ?

ok now this time it works !
i'll try look at the code to see if i can create a new word that suits to my needs !
thanks !