sdk

package
v0.0.4 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: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NUM_CORES              = 2
	NUM_DMA_CHANNELS       = 12
	NUM_DMA_TIMERS         = 4
	NUM_IRQS               = 32
	NUM_PIOS               = 2
	NUM_PIO_STATE_MACHINES = 4
	NUM_PWM_SLICES         = 8
	NUM_SPIN_LOCKS         = 32
	NUM_UARTS              = 2
	NUM_I2CS               = 2
	NUM_SPIS               = 2
	NUM_TIMERS             = 4
	NUM_ADC_CHANNELS       = 5
	NUM_BANK0_GPIOS        = 30
	NUM_QSPI_GPIOS         = 6
	PIO_INSTRUCTION_COUNT  = 32
	XOSC_MHZ               = 12
)
View Source
const (
	ADC_BANK0_GPIOS_MIN = 26
	ADC_BANK0_GPIOS_MAX = 29
)
View Source
const (
	GPIO_DIR_IN  = 0
	GPIO_DIR_OUT = 1
)

Variables

This section is empty.

Functions

func ADC_fifo_drain

func ADC_fifo_drain()

Drain the ADC FIFO

Will wait for any conversion to complete then drain the FIFO, discarding any results

func ADC_fifo_get

func ADC_fifo_get() uint16

Get ADC result from FIFO

Pops the latest result from the ADC FIFO.

func ADC_fifo_get_blocking

func ADC_fifo_get_blocking() uint16

Wait for the ADC FIFO to have data.

Blocks until data is present in the FIFO

func ADC_fifo_get_level

func ADC_fifo_get_level() uint8

Get number of entries in the ADC FIFO

The ADC FIFO is 4 entries long. This function will return how many samples are currently present.

func ADC_fifo_is_empty

func ADC_fifo_is_empty() bool

Check FIFO empty state

func ADC_fifo_setup

func ADC_fifo_setup(en, dreq_en bool, dreq_thresh uint16, err_in_fifo, byte_shift bool)

Setup the ADC FIFO

FIFO is 4 samples long, if a conversion is completed and the FIFO is full, the result is dropped

func ADC_get_selected_input

func ADC_get_selected_input() uint32

Get the currently selected ADC input channel

func ADC_gpio_init

func ADC_gpio_init(pin GPIO_pin)

Initialise the gpio for use as an ADC pin

func ADC_gpio_to_input

func ADC_gpio_to_input(pin GPIO_pin) (uint32, bool)

Determine the ADC input that is attached to the specified GPIO

func ADC_init

func ADC_init()

Initialise the ADC

func ADC_irq_set_enabled

func ADC_irq_set_enabled(enabled bool)

Enable/Disable ADC interrupts.

func ADC_is_ready

func ADC_is_ready() bool

Return ready status for ADC

func ADC_read

func ADC_read() uint16

Perform a single conversion

func ADC_run

func ADC_run(run bool)

Enable or disable free-running sampling mode

func ADC_select_input

func ADC_select_input(ch uint32)

ADC input select

Select an ADC input. 0...3 are GPIOs 26...29 respectively. Input 4 is the onboard temperature sensor.

func ADC_set_round_robin

func ADC_set_round_robin(input_mask uint32)

Round Robin sampling selector

This function sets which inputs are to be run through in round robin mode. Value between 0 and 0x1f (bit 0 to bit 4 for GPIO 26 to 29 and temperature sensor input respectively) Write a value of 0 to disable round robin sampling.

func ADC_set_temp_sensor_enabled

func ADC_set_temp_sensor_enabled(enable bool)

Enable the onboard temperature sensor

func ADC_temperature_input

func ADC_temperature_input() uint32

Return temperature input

func GPIO_acknowledge_irq

func GPIO_acknowledge_irq(pin GPIO_pin, events GPIO_irq_level)

func GPIO_clr_mask

func GPIO_clr_mask(mask uint32)

Drive low every GPIO appearing in mask

func GPIO_deinit

func GPIO_deinit(pin GPIO_pin)

Resets a GPIO back to the NULL function, i.e. disables it.

func GPIO_disable_pulls

func GPIO_disable_pulls(pin GPIO_pin)

Set specified GPIO to be floating

func GPIO_get

func GPIO_get(pin GPIO_pin) bool

Get state of a single specified GPIO

func GPIO_get_all

func GPIO_get_all() uint32

Get state of all GPIO pins

func GPIO_get_dir

func GPIO_get_dir(pin GPIO_pin) uint8

Get a specific GPIO direction

func GPIO_get_out_level

func GPIO_get_out_level(pin GPIO_pin) bool

Determine whether a GPIO is currently driven high or low

func GPIO_get_output_enabled

func GPIO_get_output_enabled(pin GPIO_pin) bool

Get GPIO output enabled state

func GPIO_init

func GPIO_init(pin GPIO_pin)

Initialise a GPIO for (enabled I/O and set func to GPIO_FUNC_SIO)

func GPIO_init_mask

func GPIO_init_mask(mask uint32)

Initialise multiple GPIOs (enabled I/O and set func to GPIO_FUNC_SIO)

func GPIO_is_dir_out

func GPIO_is_dir_out(pin GPIO_pin) bool

Check if a specific GPIO direction is OUT

func GPIO_is_input_hysteresis_enabled

func GPIO_is_input_hysteresis_enabled(pin GPIO_pin) bool

Determine whether input hysteresis is enabled on a specified GPIO

func GPIO_is_pulled_down

func GPIO_is_pulled_down(pin GPIO_pin) bool

Determine if the specified GPIO is pulled down

func GPIO_is_pulled_up

func GPIO_is_pulled_up(pin GPIO_pin) bool

Determine if the specified GPIO is pulled up

func GPIO_pull_down

func GPIO_pull_down(pin GPIO_pin)

Set specified GPIO to be pulled down

func GPIO_pull_up

func GPIO_pull_up(pin GPIO_pin)

Set specified GPIO to be pulled up

func GPIO_put

func GPIO_put(pin GPIO_pin, value bool)

Drive a single GPIO high/low

func GPIO_set_dir

func GPIO_set_dir(pin GPIO_pin, dir uint8)

Set a single GPIO direction

func GPIO_set_dir_all_bits

func GPIO_set_dir_all_bits(values uint32)

Set direction of all pins simultaneously

func GPIO_set_dir_in_masked

func GPIO_set_dir_in_masked(mask uint32)

Set a number of GPIOs to input

func GPIO_set_dir_masked

func GPIO_set_dir_masked(mask, value uint32)

Set multiple GPIO directions

func GPIO_set_dir_out_masked

func GPIO_set_dir_out_masked(mask uint32)

Set a number of GPIOs to output

func GPIO_set_drive_strength

func GPIO_set_drive_strength(pin GPIO_pin, drive GPIO_drive_strength)

Set drive strength for a specified GPIO

func GPIO_set_function

func GPIO_set_function(pin GPIO_pin, fn GPIO_function)

Select function for this GPIO, and ensure input/output are enabled at the pad. This also clears the input/output/irq override bits

func GPIO_set_inover

func GPIO_set_inover(pin GPIO_pin, value GPIO_override)

Set GPIO input override

func GPIO_set_input_enabled

func GPIO_set_input_enabled(pin GPIO_pin, enabled bool)

Enable GPIO input

func GPIO_set_input_hysteresis_enabled

func GPIO_set_input_hysteresis_enabled(pin GPIO_pin, enabled bool)

Enable/disable GPIO input hysteresis (Schmitt trigger)

func GPIO_set_irq_enabled

func GPIO_set_irq_enabled(pin GPIO_pin, events GPIO_irq_level, enabled bool)

func GPIO_set_irqover

func GPIO_set_irqover(pin GPIO_pin, value GPIO_override)

Set GPIO IRQ override

func GPIO_set_mask

func GPIO_set_mask(mask uint32)

Drive high every GPIO appearing in mask

func GPIO_set_oeover

func GPIO_set_oeover(pin GPIO_pin, value GPIO_override)

Set GPIO output enable override

func GPIO_set_outover

func GPIO_set_outover(pin GPIO_pin, value GPIO_override)

Set GPIO output override

func GPIO_set_output_enabled

func GPIO_set_output_enabled(pin GPIO_pin, enabled bool)

Set or clear GPIO output enabled

func GPIO_set_pulls

func GPIO_set_pulls(pin GPIO_pin, up, down bool)

Select up and down pulls on specific GPIO

func GPIO_set_slew_rate

func GPIO_set_slew_rate(pin GPIO_pin, slew GPIO_slew_rate)

Set slew rate for a specified GPIO

func GPIO_xor_mask

func GPIO_xor_mask(mask uint32)

Toggle every GPIO appearing in mask

func I2C_deinit

func I2C_deinit(inst uint32)

Disable the I2C HW block

func I2C_gpio_to_inst

func I2C_gpio_to_inst(sda, scl GPIO_pin) (uint32, bool)

Determine the I2C instance that is attached to the specified GPIO pins for SDA and SCL

func I2C_init

func I2C_init(inst, baudrate uint32) uint32

Initialise the I2C HW block

func I2C_reserved_addr

func I2C_reserved_addr(addr uint8) bool

Addresses of the form 000 0xxx or 111 1xxx are reserved. No slave should have these addresses.

func I2C_reset

func I2C_reset(inst uint32)

Reset I2C block

func I2C_set_baudrate

func I2C_set_baudrate(inst, baudrate uint32) uint32

Set I2C baudrate

func I2C_set_slave_mode

func I2C_set_slave_mode(inst uint32, slave bool, addr uint8)

Set I2C port to slave mode

func I2C_unreset

func I2C_unreset(inst uint32)

Unreset I2C block

func PWM_advance_count

func PWM_advance_count(slice_num uint32)

Advance PWM count and wait until advanced

func PWM_clear_irq

func PWM_clear_irq(slice_num uint32)

Clear a single PWM channel interrupt

func PWM_clear_irq_mask

func PWM_clear_irq_mask(slice_mask uint32)

Clear multiple PWM interrupts

func PWM_config_set_clkdiv

func PWM_config_set_clkdiv(c *PWM_config, div float32)

Set PWM clock divider in a PWM configuration

If the divide mode is free-running, the PWM counter runs at clk_sys / div. Otherwise, the divider reduces the rate of events seen on the B pin input (level or edge) before passing them on to the PWM counter.

func PWM_config_set_clkdiv_int

func PWM_config_set_clkdiv_int(c *PWM_config, div uint32)

Set PWM clock divider in a PWM configuration

If the divide mode is free-running, the PWM counter runs at clk_sys / div. Otherwise, the divider reduces the rate of events seen on the B pin input (level or edge) before passing them on to the PWM counter.

func PWM_config_set_clkdiv_int_frac

func PWM_config_set_clkdiv_int_frac(c *PWM_config, integer, fract uint8)

Set PWM clock divider in a PWM configuration using an 8:4 fractional value

If the divide mode is free-running, the PWM counter runs at clk_sys / div. Otherwise, the divider reduces the rate of events seen on the B pin input (level or edge) before passing them on to the PWM counter.

func PWM_config_set_clkdiv_mode

func PWM_config_set_clkdiv_mode(c *PWM_config, mode PWM_clkdiv_mode)

Set PWM counting mode in a PWM configuration

Configure which event gates the operation of the fractional divider. The default is always-on (free-running PWM). Can also be configured to count on high level, rising edge or falling edge of the B pin input.

func PWM_config_set_output_polarity

func PWM_config_set_output_polarity(c *PWM_config, a, b bool)

Set output polarity in a PWM configuration

Set a or b to true to inverse the polarity of the output on channel a or b.

func PWM_config_set_phase_correct

func PWM_config_set_phase_correct(c *PWM_config, phase_correct bool)

Set phase correction in a PWM configuration

Setting phase control to true means that instead of wrapping back to zero when the wrap point is reached, the PWM starts counting back down. The output frequency is halved when phase-correct mode is enabled.

func PWM_config_set_wrap

func PWM_config_set_wrap(c *PWM_config, wrap uint16)

Set PWM counter wrap value in a PWM configuration

Set the highest value the counter will reach before returning to 0. Also known as TOP.

func PWM_force_irq

func PWM_force_irq(slice_num uint32)

Force PWM interrupt

func PWM_get_chan_level

func PWM_get_chan_level(slice_num uint32, ch PWM_chan) uint16

Get the current PWM counter compare value for one channel

func PWM_get_counter

func PWM_get_counter(slice_num uint32) uint16

Get PWM counter

func PWM_get_gpio_level

func PWM_get_gpio_level(pin GPIO_pin) uint16

Helper function to get the PWM level for the slice and channel associated with a GPIO

func PWM_get_irq_mask

func PWM_get_irq_mask() uint32

Get PWM interrupt mask, raw

func PWM_get_irq_status_mask

func PWM_get_irq_status_mask() uint32

Get PWM interrupt status, raw

func PWM_get_wrap

func PWM_get_wrap(slice_num uint32) uint16

Get the current PWM counter wrap value

func PWM_gpio_to_slice_num

func PWM_gpio_to_slice_num(pin GPIO_pin) uint32

Determine the PWM slice that is attached to the specified GPIO

func PWM_init

func PWM_init(slice_num uint32, c *PWM_config, start bool)

Initialise a PWM with settings from a configuration object

If start is set the PWM will be started running once configured. If false you will need to start manually using PWM_set_enabled() or PWM_set_mask_enabled()

func PWM_is_enabled

func PWM_is_enabled(slice_num uint32) bool

Determine if PWM is enabled

func PWM_retard_count

func PWM_retard_count(slice_num uint32)

Retard PWM count and wait

func PWM_set_both_levels

func PWM_set_both_levels(slice_num uint32, levela, levelb uint16)

Set PWM counter compare values

func PWM_set_chan_level

func PWM_set_chan_level(slice_num uint32, ch PWM_chan, level uint16)

Set the current PWM counter compare value for one channel

func PWM_set_clkdiv

func PWM_set_clkdiv(slice_num uint32, divider float32)

Set PWM clock divider

func PWM_set_clkdiv_int_frac

func PWM_set_clkdiv_int_frac(slice_num uint32, integer, fract uint8)

Set PWM clock divider using an 8:4 fractional value

func PWM_set_clkdiv_mode

func PWM_set_clkdiv_mode(slice_num uint32, mode PWM_clkdiv_mode)

Set PWM divider mode

func PWM_set_counter

func PWM_set_counter(slice_num uint32, c uint16)

Set PWM counter

func PWM_set_enabled

func PWM_set_enabled(slice_num uint32, enabled bool)

Enable/Disable PWM

func PWM_set_gpio_level

func PWM_set_gpio_level(pin GPIO_pin, level uint16)

Helper function to set the PWM level for the slice and channel associated with a GPIO.

This PWM slice should already have been configured and set running. Also be careful of multiple GPIOs mapping to the same slice and channel (if GPIOs have a difference of 16).

func PWM_set_irq_enabled

func PWM_set_irq_enabled(slice_num uint32, enabled bool)

Enable PWM instance interrupt

func PWM_set_irq_mask_enabled

func PWM_set_irq_mask_enabled(slice_mask uint32, enabled bool)

Enable multiple PWM instance interrupts

func PWM_set_mask_enabled

func PWM_set_mask_enabled(mask uint32)

Enable/Disable multiple PWM slices simultaneously

func PWM_set_output_polarity

func PWM_set_output_polarity(slice_num uint32, a, b bool)

Set PWM output polarity

Set a or b to true to inverse the polarity of the output on channel a or b.

func PWM_set_phase_correct

func PWM_set_phase_correct(slice_num uint32, phase_correct bool)

Set PWM phase correct on/off

Setting phase control to true means that instead of wrapping back to zero when the wrap point is reached, the PWM starts counting back down. The output frequency is halved when phase-correct mode is enabled.

func PWM_set_wrap

func PWM_set_wrap(slice_num uint32, wrap uint16)

Set the current PWM counter wrap value

Types

type GPIO_drive_strength

type GPIO_drive_strength uint8
const (
	GPIO_DRIVE_STRENGTH_2MA  GPIO_drive_strength = 0 ///< 2 mA nominal drive strength
	GPIO_DRIVE_STRENGTH_4MA  GPIO_drive_strength = 1 ///< 4 mA nominal drive strength
	GPIO_DRIVE_STRENGTH_8MA  GPIO_drive_strength = 2 ///< 8 mA nominal drive strength
	GPIO_DRIVE_STRENGTH_12MA GPIO_drive_strength = 3 ///< 12 mA nominal drive strength
)

func GPIO_get_drive_strength

func GPIO_get_drive_strength(pin GPIO_pin) GPIO_drive_strength

Determine current slew rate for a specified GPIO

func (GPIO_drive_strength) String

func (v GPIO_drive_strength) String() string

type GPIO_function

type GPIO_function uint32
const (
	GPIO_FUNC_XIP  GPIO_function = 0
	GPIO_FUNC_SPI  GPIO_function = 1
	GPIO_FUNC_UART GPIO_function = 2
	GPIO_FUNC_I2C  GPIO_function = 3
	GPIO_FUNC_PWM  GPIO_function = 4
	GPIO_FUNC_SIO  GPIO_function = 5
	GPIO_FUNC_PIO0 GPIO_function = 6
	GPIO_FUNC_PIO1 GPIO_function = 7
	GPIO_FUNC_GPCK GPIO_function = 8
	GPIO_FUNC_USB  GPIO_function = 9
	GPIO_FUNC_NULL GPIO_function = 0x1f
)

func GPIO_get_function

func GPIO_get_function(pin GPIO_pin) GPIO_function

Return current function for this GPIO

func (GPIO_function) String

func (v GPIO_function) String() string

type GPIO_irq_level

type GPIO_irq_level uint8
const (
	GPIO_IRQ_LEVEL_NONE GPIO_irq_level = 0
	GPIO_IRQ_LEVEL_LOW  GPIO_irq_level = 1
	GPIO_IRQ_LEVEL_HIGH GPIO_irq_level = 2
	GPIO_IRQ_EDGE_FALL  GPIO_irq_level = 4
	GPIO_IRQ_EDGE_RISE  GPIO_irq_level = 8
	GPIO_IRQ_LEVEL_MAX  GPIO_irq_level = GPIO_IRQ_EDGE_RISE
)

func (GPIO_irq_level) String

func (v GPIO_irq_level) String() string

type GPIO_override

type GPIO_override uint8
const (
	GPIO_OVERRIDE_NORMAL GPIO_override = 0 // peripheral signal selected via gpio_set_function
	GPIO_OVERRIDE_INVERT GPIO_override = 1 // invert peripheral signal selected via gpio_set_function
	GPIO_OVERRIDE_LOW    GPIO_override = 2 // drive low/disable output
	GPIO_OVERRIDE_HIGH   GPIO_override = 3 // drive high/enable output
)

func (GPIO_override) String

func (v GPIO_override) String() string

type GPIO_pin

type GPIO_pin uint8

func (GPIO_pin) String

func (v GPIO_pin) String() string

type GPIO_slew_rate

type GPIO_slew_rate uint8
const (
	GPIO_SLEW_RATE_SLOW GPIO_slew_rate = 0 // Slew rate limiting enabled
	GPIO_SLEW_RATE_FAST GPIO_slew_rate = 1 // Slew rate limiting disabled
)

func GPIO_get_slew_rate

func GPIO_get_slew_rate(pin GPIO_pin) GPIO_slew_rate

Determine current slew rate for a specified GPIO

func (GPIO_slew_rate) String

func (v GPIO_slew_rate) String() string

type PWM_chan

type PWM_chan uint32
const (
	PWM_CHAN_A PWM_chan = 0
	PWM_CHAN_B PWM_chan = 1
)

func PWM_gpio_to_channel

func PWM_gpio_to_channel(pin GPIO_pin) PWM_chan

Determine the PWM channel that is attached to the specified GPIO

func (PWM_chan) String

func (v PWM_chan) String() string

type PWM_clkdiv_mode

type PWM_clkdiv_mode uint32
const (
	PWM_DIV_FREE_RUNNING PWM_clkdiv_mode = 0 // Free-running counting at rate dictated by fractional divider
	PWM_DIV_B_HIGH       PWM_clkdiv_mode = 1 // Fractional divider is gated by the PWM B pin
	PWM_DIV_B_RISING     PWM_clkdiv_mode = 2 // Fractional divider advances with each rising edge of the PWM B pin
	PWM_DIV_B_FALLING    PWM_clkdiv_mode = 3 // Fractional divider advances with each falling edge of the PWM B pin
)

func (PWM_clkdiv_mode) String

func (v PWM_clkdiv_mode) String() string

type PWM_config

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

func PWM_get_default_config

func PWM_get_default_config() *PWM_config

Get a set of default values for PWM configuration

func (*PWM_config) String

func (v *PWM_config) String() string

Jump to

Keyboard shortcuts

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