Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/nrf52xxx/adc/make resolution changeable #4697

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,8 @@ endif
@$(MD5SUM) test.hex
$(TINYGO) build -size short -o test.hex -target=tiny2350 examples/blinky1
@$(MD5SUM) test.hex
$(TINYGO) build -size short -o test.hex -target=waveshare-rp2040-tiny examples/echo
@$(MD5SUM) test.hex
# test pwm
$(TINYGO) build -size short -o test.hex -target=itsybitsy-m0 examples/pwm
@$(MD5SUM) test.hex
Expand Down
2 changes: 1 addition & 1 deletion builder/sizes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestBinarySize(t *testing.T) {
// microcontrollers
{"hifive1b", "examples/echo", 4600, 280, 0, 2268},
{"microbit", "examples/serial", 2908, 388, 8, 2272},
{"wioterminal", "examples/pininterrupt", 6140, 1484, 116, 6824},
{"wioterminal", "examples/pininterrupt", 7286, 1486, 116, 6912},

// TODO: also check wasm. Right now this is difficult, because
// wasm binaries are run through wasm-opt and therefore the
Expand Down
10 changes: 5 additions & 5 deletions builder/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ func parseLLDErrors(text string) error {

// Check for undefined symbols.
// This can happen in some cases like with CGo and //go:linkname tricker.
if matches := regexp.MustCompile(`^ld.lld: error: undefined symbol: (.*)\n`).FindStringSubmatch(message); matches != nil {
symbolName := matches[1]
if matches := regexp.MustCompile(`^ld.lld(-[0-9]+)?: error: undefined symbol: (.*)\n`).FindStringSubmatch(message); matches != nil {
symbolName := matches[2]
for _, line := range strings.Split(message, "\n") {
matches := regexp.MustCompile(`referenced by .* \(((.*):([0-9]+))\)`).FindStringSubmatch(line)
if matches != nil {
Expand All @@ -134,9 +134,9 @@ func parseLLDErrors(text string) error {
}

// Check for flash/RAM overflow.
if matches := regexp.MustCompile(`^ld.lld: error: section '(.*?)' will not fit in region '(.*?)': overflowed by ([0-9]+) bytes$`).FindStringSubmatch(message); matches != nil {
region := matches[2]
n, err := strconv.ParseUint(matches[3], 10, 64)
if matches := regexp.MustCompile(`^ld.lld(-[0-9]+)?: error: section '(.*?)' will not fit in region '(.*?)': overflowed by ([0-9]+) bytes$`).FindStringSubmatch(message); matches != nil {
region := matches[3]
n, err := strconv.ParseUint(matches[4], 10, 64)
if err != nil {
// Should not happen at all (unless it overflows an uint64 for some reason).
continue
Expand Down
2 changes: 1 addition & 1 deletion goenv/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

// Version of TinyGo.
// Update this value before release of new version of software.
const version = "0.35.0"
const version = "0.36.0-dev"

// Return TinyGo version, either in the form 0.30.0 or as a development version
// (like 0.30.0-dev-abcd012).
Expand Down
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1062,9 +1062,8 @@ func findFATMounts(options *compileopts.Options) ([]mountPoint, error) {
return points, nil
case "windows":
// Obtain a list of all currently mounted volumes.
cmd := executeCommand(options, "wmic",
"PATH", "Win32_LogicalDisk",
"get", "DeviceID,VolumeName,FileSystem,DriveType")
cmd := executeCommand(options, "powershell", "-c",
"Get-CimInstance -ClassName Win32_LogicalDisk | Select-Object DeviceID, DriveType, FileSystem, VolumeName")
var out bytes.Buffer
cmd.Stdout = &out
err := cmd.Run()
Expand Down
8 changes: 7 additions & 1 deletion src/crypto/tls/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,13 @@ type Dialer struct {
//
// The returned Conn, if any, will always be of type *Conn.
func (d *Dialer) DialContext(ctx context.Context, network, addr string) (net.Conn, error) {
return nil, errors.New("tls:DialContext not implemented")
switch network {
case "tcp", "tcp4":
default:
return nil, fmt.Errorf("Network %s not supported", network)
}

return net.DialTLS(addr)
}

// LoadX509KeyPair reads and parses a public/private key pair from a pair
Expand Down
11 changes: 10 additions & 1 deletion src/examples/pininterrupt/pininterrupt.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
// This example demonstrates how to use pin change interrupts.
//
// This is only an example and should not be copied directly in any serious
// circuit, because it lacks an important feature: debouncing.
// circuit, because it only naively implements an important feature: debouncing.
// See: https://en.wikipedia.org/wiki/Switch#Contact_bounce

import (
Expand All @@ -15,6 +15,8 @@ const (
led = machine.LED
)

var lastPress time.Time

func main() {

// Configure the LED, defaulting to on (usually setting the pin to low will
Expand All @@ -29,6 +31,13 @@ func main() {

// Set an interrupt on this pin.
err := button.SetInterrupt(buttonPinChange, func(machine.Pin) {

// Ignore events that are too close to the last registered press (debouncing)
if time.Since(lastPress) < 100*time.Millisecond {
return
}
lastPress = time.Now()

led.Set(!led.Get())
})
if err != nil {
Expand Down
43 changes: 43 additions & 0 deletions src/internal/task/mutex-cooperative.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package task

type Mutex struct {
locked bool
blocked Stack
}

func (m *Mutex) Lock() {
if m.locked {
// Push self onto stack of blocked tasks, and wait to be resumed.
m.blocked.Push(Current())
Pause()
return
}

m.locked = true
}

func (m *Mutex) Unlock() {
if !m.locked {
panic("sync: unlock of unlocked Mutex")
}

// Wake up a blocked task, if applicable.
if t := m.blocked.Pop(); t != nil {
scheduleTask(t)
} else {
m.locked = false
}
}

// TryLock tries to lock m and reports whether it succeeded.
//
// Note that while correct uses of TryLock do exist, they are rare,
// and use of TryLock is often a sign of a deeper problem
// in a particular use of mutexes.
func (m *Mutex) TryLock() bool {
if m.locked {
return false
}
m.Lock()
return true
}
Empty file modified src/internal/wasi/cli/v0.2.0/command/command.wit
100755 → 100644
Empty file.
Empty file modified src/internal/wasi/cli/v0.2.0/environment/environment.wasm.go
100755 → 100644
Empty file.
Empty file modified src/internal/wasi/cli/v0.2.0/exit/exit.wasm.go
100755 → 100644
Empty file.
Empty file modified src/internal/wasi/cli/v0.2.0/run/run.wasm.go
100755 → 100644
Empty file.
Empty file modified src/internal/wasi/cli/v0.2.0/stderr/stderr.wasm.go
100755 → 100644
Empty file.
Empty file modified src/internal/wasi/cli/v0.2.0/stdin/stdin.wasm.go
100755 → 100644
Empty file.
Empty file modified src/internal/wasi/cli/v0.2.0/stdout/stdout.wasm.go
100755 → 100644
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified src/internal/wasi/clocks/v0.2.0/wall-clock/wallclock.wasm.go
100755 → 100644
Empty file.
Empty file modified src/internal/wasi/filesystem/v0.2.0/preopens/preopens.wasm.go
100755 → 100644
Empty file.
Empty file modified src/internal/wasi/filesystem/v0.2.0/types/types.wasm.go
100755 → 100644
Empty file.
Empty file modified src/internal/wasi/io/v0.2.0/error/ioerror.wasm.go
100755 → 100644
Empty file.
Empty file modified src/internal/wasi/io/v0.2.0/poll/poll.wasm.go
100755 → 100644
Empty file.
Empty file modified src/internal/wasi/io/v0.2.0/streams/streams.wasm.go
100755 → 100644
Empty file.
Empty file.
Empty file modified src/internal/wasi/random/v0.2.0/insecure/insecure.wasm.go
100755 → 100644
Empty file.
Empty file modified src/internal/wasi/random/v0.2.0/random/random.wasm.go
100755 → 100644
Empty file.
Empty file.
Empty file.
Empty file modified src/internal/wasi/sockets/v0.2.0/network/network.wasm.go
100755 → 100644
Empty file.
Empty file.
Empty file modified src/internal/wasi/sockets/v0.2.0/tcp/tcp.wasm.go
100755 → 100644
Empty file.
Empty file.
Empty file modified src/internal/wasi/sockets/v0.2.0/udp/udp.wasm.go
100755 → 100644
Empty file.
121 changes: 121 additions & 0 deletions src/machine/board_waveshare_rp2040_tiny.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
//go:build waveshare_rp2040_tiny

// This file contains the pin mappings for the Waveshare RP2040-Tiny boards.
//
// Waveshare RP2040-Tiny is a microcontroller using the Raspberry Pi RP2040 chip.
//
// - https://www.waveshare.com/wiki/RP2040-Tiny
package machine

// Digital Pins
const (
GP0 Pin = GPIO0
GP1 Pin = GPIO1
GP2 Pin = GPIO2
GP3 Pin = GPIO3
GP4 Pin = GPIO4
GP5 Pin = GPIO5
GP6 Pin = GPIO6
GP7 Pin = GPIO7
GP8 Pin = GPIO8
GP9 Pin = GPIO9
GP10 Pin = GPIO10
GP11 Pin = GPIO11
GP12 Pin = GPIO12
GP13 Pin = GPIO13
GP14 Pin = GPIO14
GP15 Pin = GPIO15
GP16 Pin = GPIO16
GP17 Pin = NoPin
GP18 Pin = NoPin
GP19 Pin = NoPin
GP20 Pin = NoPin
GP21 Pin = NoPin
GP22 Pin = NoPin
GP23 Pin = NoPin
GP24 Pin = GPIO24
GP25 Pin = GPIO25
GP26 Pin = GPIO26
GP27 Pin = GPIO27
GP28 Pin = GPIO28
GP29 Pin = GPIO29
)

// Analog pins
const (
A0 Pin = GP26
A1 Pin = GP27
A2 Pin = GP28
A3 Pin = GP29
)

// Onboard LEDs
const (
LED = GP16
WS2812 = GP16
)

// I2C pins
const (
I2C0_SDA_PIN Pin = GP0
I2C0_SCL_PIN Pin = GP1
I2C1_SDA_PIN Pin = GP2
I2C1_SCL_PIN Pin = GP3

// default I2C0
I2C_SDA_PIN Pin = I2C0_SDA_PIN
I2C_SCL_PIN Pin = I2C0_SCL_PIN
)

// SPI pins
const (
SPI0_RX_PIN Pin = GP0
SPI0_CSN_PIN Pin = GP1
SPI0_SCK_PIN Pin = GP2
SPI0_TX_PIN Pin = GP3
SPI0_SDO_PIN Pin = SPI0_TX_PIN
SPI0_SDI_PIN Pin = SPI0_RX_PIN

SPI1_RX_PIN Pin = GP8
SPI1_CSN_PIN Pin = GP9
SPI1_SCK_PIN Pin = GP10
SPI1_TX_PIN Pin = GP11
SPI1_SDO_PIN Pin = SPI1_TX_PIN
SPI1_SDI_PIN Pin = SPI1_RX_PIN

// default SPI0
SPI_RX_PIN Pin = SPI0_RX_PIN
SPI_CSN_PIN Pin = SPI0_CSN_PIN
SPI_SCK_PIN Pin = SPI0_SCK_PIN
SPI_TX_PIN Pin = SPI0_TX_PIN
SPI_SDO_PIN Pin = SPI0_TX_PIN
SPI_SDI_PIN Pin = SPI0_RX_PIN
)

// Onboard crystal oscillator frequency, in MHz.
const (
xoscFreq = 12 // MHz
)

// UART pins
const (
UART0_TX_PIN = GP0
UART0_RX_PIN = GP1
UART1_TX_PIN = GP8
UART1_RX_PIN = GP9

// default UART0
UART_TX_PIN = UART0_TX_PIN
UART_RX_PIN = UART0_RX_PIN
)

// USB CDC identifiers
const (
usb_STRING_PRODUCT = "RP2040-Tiny"
usb_STRING_MANUFACTURER = "Waveshare"
)

var (
usb_VID uint16 = 0x2e8a
usb_PID uint16 = 0x0003
)
4 changes: 2 additions & 2 deletions src/machine/machine_nrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ func (i2c *I2C) signalStop() error {

var rngStarted = false

// GetRNG returns 32 bits of non-deterministic random data based on internal thermal noise.
// getRNG returns 32 bits of non-deterministic random data based on internal thermal noise.
// According to Nordic's documentation, the random output is suitable for cryptographic purposes.
func GetRNG() (ret uint32, err error) {
func getRNG() (ret uint32, err error) {
// There's no apparent way to check the status of the RNG peripheral's task, so simply start it
// to avoid deadlocking while waiting for output.
if !rngStarted {
Expand Down
Loading
Loading