tinygo-org / tinygo

Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.
https://tinygo.org
Other
15.33k stars 905 forks source link

Arduino Mega 2560's SPI MISO/MOSI Flipped #1737

Closed soypat closed 3 years ago

soypat commented 3 years ago

The lines in question. sdi and sdo seem to be flipped.

It would seem that the correct way of arranging SPI0 according to arduino's documentation would be the following

// SPI configuration
var SPI0 = SPI{
    spcr: avr.SPCR,
    spdr: avr.SPDR,
    spsr: avr.SPSR,
    sck:  PB1,
    sdi:  PB2,
    sdo:  PB3,
    cs:   PB0}

I've tested both ways, the second one seems to actually work.

soypat commented 3 years ago

If someone can get around to testing the Arduino Mega that'd be great. I couldn't get the SPI to work for the life of me.

soypat commented 3 years ago

I have gotten around to testing the Arduino Mega's SPI with the MCP3008 library.

The following setup worked for me:

deadprogram commented 3 years ago

We try to follow the guidelines of the Open Source Hardware Association regarding naming of pins in the SPI interface.

Please see: https://www.oshwa.org/a-resolution-to-redefine-spi-signal-names/

Thank you!