pico

package module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

README

go-pico

This repository contains a tinygo implementation of the Raspberry Pi Pico (RP2040) Microcontroller and everything else you need in order to start developing golang on the RP2040 with tinygo. The support for some SDK features are missing on tinygo, so this is an alternative.

For dependencies and installation, please see INSTALLATION.md.

Versions

This repository currently tracks the following versions:

Contributing & Distribution

This repository is currently in development and subject to change.

Please do file feature requests and bugs here.

The license is Apache 2 so feel free to redistribute. Redistributions in either source code or binary form must reproduce the copyright notice, and please link back to this repository for more information:

RP2040 SDK for tinygo

https://github.com/djthorpe/go-pico/

Copyright (c) 2022, David Thorpe, All rights reserved.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ADC added in v0.0.4

type ADC struct {
	// contains filtered or unexported fields
}

func (*ADC) Get added in v0.0.4

func (a *ADC) Get() uint16

Get returns the raw ADC value, which is the first 12 bits

func (*ADC) GetTemperature added in v0.0.4

func (a *ADC) GetTemperature() float32

Return temperature ReadTemperature does a one-shot sample of the internal temperature sensor and returns a celsius reading.

Only works on the channel. Other channels will return 0

func (*ADC) GetVoltage added in v0.0.4

func (a *ADC) GetVoltage(vref float32) float32

Return voltage given the value of the reference voltage

type Mode

type Mode uint8
const (
	ModeOutput Mode = iota
	ModeInput
	ModeInputPulldown
	ModeInputPullup
	ModeUART
	ModePWM
	ModeI2C
	ModeSPI
	ModeOff
)

type PWM added in v0.0.4

type PWM struct {
	// contains filtered or unexported fields
}

func (*PWM) Counter added in v0.0.4

func (p *PWM) Counter() uint16

Get counter value

func (*PWM) Dec added in v0.0.4

func (p *PWM) Dec()

Decrement counter

func (*PWM) Enabled added in v0.0.4

func (p *PWM) Enabled() bool

func (*PWM) Get added in v0.0.4

func (p *PWM) Get(pin Pin) uint16

Get level

func (*PWM) Inc added in v0.0.4

func (p *PWM) Inc()

Increment counter

func (*PWM) Set added in v0.0.4

func (p *PWM) Set(pin Pin, level uint16)

Set level

func (*PWM) SetCounter added in v0.0.4

func (p *PWM) SetCounter(value uint16)

Set counter value

func (*PWM) SetEnabled added in v0.0.4

func (p *PWM) SetEnabled(enabled bool)

func (*PWM) SetInterrupt added in v0.0.4

func (p *PWM) SetInterrupt(handler PWM_callback_t)

Set interrupt handler

If called with nil then handler is disabled

func (*PWM) SetWrap added in v0.0.4

func (p *PWM) SetWrap(wrap uint16)

Set wrapping value

func (*PWM) Wrap added in v0.0.4

func (p *PWM) Wrap() uint16

Get wrapping value

type PWM_callback_t added in v0.0.4

type PWM_callback_t func(pwm *PWM)

type Pin

type Pin uint

func (Pin) ADC

func (p Pin) ADC() *ADC

Get ADC for pin

func (Pin) Get

func (p Pin) Get() bool

Get pin state

func (Pin) Mode

func (p Pin) Mode() Mode

Get pin mode

func (Pin) PWM

func (p Pin) PWM() *PWM

Get PWM for pin

func (Pin) Set

func (p Pin) Set(value bool)

Set pin state

func (Pin) SetInterrupt

func (p Pin) SetInterrupt(callback Pin_callback_t)

Set pin interrupt

func (Pin) SetMode

func (p Pin) SetMode(mode Mode) error

Set pin mode

type Pin_callback_t

type Pin_callback_t func(Pin)

type State

type State uint8
const (
	StateLow State = (1 << iota)
	StateHigh
	StateFall
	StateRise
	StateNone State = 0
	StateMax        = StateRise
)

Directories

Path Synopsis
cmd
pkg
math32
Package math32 provides basic constants and mathematical functions for float32 types.
Package math32 provides basic constants and mathematical functions for float32 types.
sdk
spi

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL