tinygo-org / tinygo

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

Constants, Functions etc. from "machine/board_*" @IDE (Goland) #1358

Closed hbroer closed 4 years ago

hbroer commented 4 years ago

Hi,

I checked out TinyGo yesterday and noticed a problem that all constants from the machine/board* files are not available. I am using the Feather M0 so it's a samd21 chip. How can I enable that the Pin constants for example are available in my IDE?

This is an error in Goland, but it works when building it:

machine.Pin(machine.PA16)

This works with Goland and the build:

machine.Pin(16)
aykevl commented 4 years ago

Hi @hbroer, this is not yet fully supported but some people have had success with this setup: https://tinygo.org/ide-integration/

hbroer commented 4 years ago

Hi,

yea I found that. It only works for the generic functions, constants etc. in machine like machine.Pin, but not for the device specific objects like machine.PA16.

I am not sure if this even can be fixed by TiniGo because of its nature, or if that has to be added as a feature by Jetbrains to their IDE. If so I would open a Issue there but first I wanted to ask here. ;)

aykevl commented 4 years ago

What the documentation doesn't cover is how you can set the right build tags. TinyGo uses a lot of build tags to select the right board/chip, which you can find with tinygo info <target> such as tinygo info arduino-nano.

hbroer commented 4 years ago

I have no problem to build it, but my IDE complains about that for example machine.PA16 does not exist. And I have no intellisense for the device/board specific objects. I found the PA16 only by looking into the sources and was surprised that machine.PA16 did build. The IDE only finds machine_generic.go and machine.go. The IDE is not aware of machine_atsamd21.go.

Like I said I am not sure if this can even fixed by TinyGo, or if I have to open a issue @ Jetbrains to ask to support TinyGo.

Btw great work dude, this is an awesome project with great potential to take over the world ;)

sago35 commented 4 years ago

The following should help you

hbroer commented 4 years ago

@sago35 oh thank you so much. That's new, I have the old version still open in another browser tab :D I will test it tomorrow and give feedback. 👍

Edit: just realized it is a pull request. I will comment there if it works or not.

hbroer commented 4 years ago

I got it to work with the help of the updated integration page mentioned by @sago35 and added how I did on windows 10 with Jetbrains Goland here: https://github.com/tinygo-org/tinygo-site/pull/107#issuecomment-687781692