Граф коммитов

603 коммитов

Автор SHA1 Сообщение Дата
Ron Evans
ee5d562050
examples: add color mood lamp that shows using GPIO, PWM, ADC, and I2C all at the same time on an Arduino
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-09-29 23:18:31 +02:00
Ayke van Laethem
802350f8da
main: helpful error message for flash cmd without -target 2018-09-29 22:39:44 +02:00
Ayke van Laethem
b6db84e916
main: use GOPATH from the environment
Be more compatible with the Go toolchain by setting GOPATH in the same
way. This makes it possible to flash and run examples from the standard
GOPATH instead of only from the source tree.
2018-09-29 22:30:45 +02:00
Ayke van Laethem
5bf058a0a6
nrf: fix off-by-one in modulo of runtime.ticks
This code:
    foo & 0xffffff
Is equivalent to this code:
    foo % 0x1000000
However, to drop the high 8 bits, this calculation was used:
    foo % 0xffffff
This is far more expensive (and incorrect), as it needs an actual modulo
operation which increases code size and probably reduces speed on a
Cortex-M4 and needs library functions for a Cortex-M0 increasing code
size by a much bigger amount.
2018-09-29 16:21:17 +02:00
Ayke van Laethem
c1a833c7cc
main: add basic float tests 2018-09-29 00:12:23 +02:00
Ayke van Laethem
717262c0a6
main: add coroutine/sleep tests 2018-09-29 00:11:58 +02:00
Ayke van Laethem
318567f398
ir: fix nil pointer dereference in IsVolatile 2018-09-29 00:11:05 +02:00
Ayke van Laethem
8d170d3bd2
all: change special type __volatile to pragma //go:volatile
This is one step towards removing unnecessary special casts in most
cases. It is also part of removing as much magic as possible from the
compiler (the pragma is explicit, the special name is not).
2018-09-28 13:17:03 +02:00
Ayke van Laethem
0e813c4cb7
main: add -no-debug flag to avoid DWARF debug info 2018-09-25 20:17:46 +02:00
Ayke van Laethem
69f2cec045
avr: fix build for Arduino
I'm afraid I broke this while merging the I2S changes...
2018-09-25 14:32:02 +02:00
Ayke van Laethem
8f661d25a9
main_test: fix error logging of test 2018-09-25 14:25:38 +02:00
Ayke van Laethem
4731f2f787
testdata: add better tests for struct expanding 2018-09-25 14:24:44 +02:00
Ron Evans
12fb4f3f91
avr: i2c implementation with BlinkM example
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2018-09-25 14:00:01 +02:00
Ayke van Laethem
d190bfccf6
Makefile: add 'make test' that runs go test 2018-09-25 13:49:03 +02:00
Ayke van Laethem
13cb7d6503
avr: add interrupt support
Interrupts are supported using a special //go:interrupt pragma.
For example:

//go:interrupt INT0_vect
func handleINT0() {
    // do something here
}
2018-09-25 13:47:20 +02:00
Ayke van Laethem
dc88948f55
Makefile: go fmt testdata/*.go 2018-09-25 13:45:50 +02:00
Ayke van Laethem
174b6333f8
compiler: fix expanding zero-length structs 2018-09-25 13:45:04 +02:00
Ayke van Laethem
d8f0ddf3fa
main: add tests
Add testing infrastructure and one initial test (for
src/runtime/print.go). More tests to be added later.
2018-09-24 17:24:58 +02:00
Ayke van Laethem
ed227b8fd3
all: fix errors reported by go vet 2018-09-24 17:22:59 +02:00
Ayke van Laethem
a2eaaa42a0
main: optimize 'tinygo run'
Apparently -Oz without inliner is the fastest, probably because it
removes code that would otherwise need to be emitted.

TODO: does this mean that the ExecutionEngine compiles the module before
running it? Can we control this?
2018-09-24 16:22:09 +02:00
Ayke van Laethem
c9ae72a105
all: allow -O0 optimization level 2018-09-24 16:17:42 +02:00
Ayke van Laethem
6191d4e1ac
compiler: rename .Parse() to .Compiler()
The fact it was called Parse() is more of a historical accident, as the
compiler started out using the Go AST directly instead of Go SSA.
2018-09-24 15:55:38 +02:00
Ayke van Laethem
1b229a8f8b
compiler: support compiling individual .go files
For example:

    tinygo run ./src/examples/test/test.go
2018-09-24 15:46:30 +02:00
Ayke van Laethem
a561e9a9ac
ir: move adding packages from the compiler 2018-09-24 15:46:30 +02:00
Ayke van Laethem
9df04a2170
compiler: fix panic on import errors
I think this is a problem in the loader package - it doesn't seem to
return errors for missing packages.
2018-09-24 15:46:30 +02:00
Ayke van Laethem
8a468786df
compiler: use config struct for options 2018-09-24 15:46:05 +02:00
Ayke van Laethem
ddd4a39cb8
avr: fix default handler in interrupt vector
Apparently the target of a weak symbol must be defined in the same file
as where it is used as a weak symbol.

https://www.avrfreaks.net/forum/using-weak-custom-vector-table#comment-745922
2018-09-24 13:03:21 +02:00
Ayke van Laethem
fd6dda5e4f
main: run the compiler from any path 2018-09-24 12:25:33 +02:00
Ayke van Laethem
453450f40d
ir: sort function pragmas 2018-09-23 23:30:13 +02:00
Ayke van Laethem
3076ad470e
tools/gen-device-svd: fix script filename in output 2018-09-23 20:50:44 +02:00
Ayke van Laethem
b09f7a5e6c
avr: make linker script generic 2018-09-23 20:50:12 +02:00
Ayke van Laethem
b9638315d2
avr: automatically generate interrupt vectors 2018-09-23 20:37:22 +02:00
Ayke van Laethem
3850530c88
docs/installation: fix LLVM hyperlink 2018-09-23 17:21:49 +02:00
Ayke van Laethem
3e1a60351d
docs/internals: fix hyperlink 2018-09-23 17:20:24 +02:00
Ayke van Laethem
7c597c910f
README: move installation instructions to docs 2018-09-23 17:15:52 +02:00
Ayke van Laethem
4868823dad
README: add docs badge 2018-09-23 17:13:26 +02:00
Ayke van Laethem
c9a2b3f417
docs: remove "Indices and tables" 2018-09-23 17:05:32 +02:00
Ayke van Laethem
f7f33a1163
docs: add initial documentation 2018-09-23 16:46:57 +02:00
Ayke van Laethem
2938437efc
compiler: make string data unnamed addresses
This ensures LLVM can merge identical strings, and thus reduces code
size in some cases.
2018-09-23 03:03:40 +02:00
Ayke van Laethem
7cea40bcb5
compiler: small cleanup in call handling code 2018-09-23 03:01:10 +02:00
Ayke van Laethem
fdfa810060
compiler: expand small structs
Use fields of small structs (3 or less fields when flattened
recursively) directly as parameter values.

Advantages:
  * Code size is slightly reduced, both on unix and nrf.
  * AVR can finally deal with struct parameters - at least the small
    ones. examples/test now compiles. A real fix for struct parameters
    should go into upstream LLVM, but this is a nice win.

fixes #20
2018-09-23 02:39:05 +02:00
Ayke van Laethem
a86739d235
Makefile: add new packages to tgo dependencies 2018-09-23 01:17:46 +02:00
Ayke van Laethem
b2cbfa78ca
compiler: refactor compiler into separate package 2018-09-22 20:32:28 +02:00
Ayke van Laethem
b75a02e66d
compiler: refactor IR parts into separate package 2018-09-22 20:32:07 +02:00
Ayke van Laethem
473e71b573
compiler: implement range over a string 2018-09-22 19:19:53 +02:00
Ayke van Laethem
18b5ab290c
compiler: recognize untyped strings as strings 2018-09-22 19:18:09 +02:00
Ayke van Laethem
c8587c7d1e
Makefile: go fmt more packages 2018-09-22 17:44:42 +02:00
Ayke van Laethem
4d5b5241ec
all: avoid _Msk fields when not necessary 2018-09-22 17:42:44 +02:00
Ayke van Laethem
eadec6f766
tools/gen-device-svd: avoid _Msk for single-bit fields 2018-09-22 17:42:05 +02:00
Ayke van Laethem
3bba26ce5b
machine/bluepill: create definitions for all pins 2018-09-22 15:47:16 +02:00