Table of contents

Module pico/highlevel

sleep_until

Description: Wait until after the given timestamp to return.

Parameters:

  • target absolute_time_t - The time after which to return.

Back to Top


sleep_us

Description: Wait for the given number of microseconds before returning.

Parameters:

  • us number - The number of microseconds to sleep.

Back to Top


sleep_ms

Description: Wait for the given number of milliseconds before returning.

Parameters:

  • ms number - The number of milliseconds to sleep.

Back to Top


best_effort_wfe_or_timeout

Description: Helper method for blocking on a timeout.

Parameters:

  • timeout_timestamp absolute_time_t - The timeout time.

Returns: boolean - True if the target time is reached, false otherwise .

Back to Top


Module pico/hardware

adc_init

Description: Initialise the ADC HW.

Back to Top


adc_gpio_init

Description: Initialise the gpio for use as an ADC pin.

Parameters:

  • gpio number - The GPIO number to use. Allowable GPIO numbers are 26 to 29 inclusive.

Back to Top


adc_select_input

Description: ADC input select.

Parameters:

  • input number - Input to select.

Back to Top


adc_get_selected_input

Description: Get the currently selected ADC input channel.

Returns: number - The currently selected input channel. 0…3 are GPIOs 26…29 respectively. Input 4 is the onboard temperature sensor. .

Back to Top


adc_set_round_robin

Description: Round Robin sampling selector.

Parameters:

  • input_mask number - A bit pattern indicating which of the 5 inputs are to be sampled. Write a value of 0 to disable round robin sampling.

Back to Top


adc_set_temp_sensor_enabled

Description: Enable the onboard temperature sensor.

Parameters:

  • enable boolean - Set true to power on the onboard temperature sensor, false to power off.

Back to Top


adc_read

Description: Perform a single conversion.

Returns: number - Result of the conversion. .

Back to Top


adc_run

Description: Enable or disable free-running sampling mode.

Parameters:

  • run boolean - False to disable, true to enable free running conversion mode.

Back to Top


adc_set_clkdiv

Description: Set the ADC Clock divisor.

Parameters:

  • clkdiv number - If non-zero, conversion will be started at intervals rather than back to back.

Back to Top


adc_fifo_setup

Description: Setup the ADC FIFO.

Parameters:

  • en boolean - Enables write each conversion result to the FIFO.
  • dreq_en boolean - Enable DMA requests when FIFO contains data.
  • dreq_thresh number - Threshold for DMA requests/FIFO IRQ if enabled.
  • err_in_fifo boolean - If enabled, bit 15 of the FIFO contains error flag for each sample.
  • byte_shift boolean - Shift FIFO contents to be one byte in size (for byte DMA) - enables DMA to byte buffers.

Back to Top


adc_fifo_is_empty

Description: Check FIFO empty state.

Returns: boolean - Returns true if the FIFO is empty .

Back to Top


adc_fifo_get_level

Description: Get number of entries in the ADC FIFO.

Back to Top


adc_fifo_get

Description: Get ADC result from FIFO.

Back to Top


adc_fifo_get_blocking

Description: Wait for the ADC FIFO to have data.

Back to Top


adc_fifo_drain

Description: Drain the ADC FIFO.

Back to Top


adc_irq_set_enabled

Description: Enable/Disable ADC interrupts.

Parameters:

  • enabled boolean - Set to true to enable the ADC interrupts, false to disable.

Back to Top


clocks_init

Description: Initialise the clock hardware.

Back to Top


clock_configure

Description: Configure the specified clock.

Parameters:

  • clk_index number - The clock to configure.
  • src number - The main clock source, can be 0.
  • auxsrc number - The auxiliary clock source, which depends on which clock is being set. Can be 0.
  • src_freq number - Frequency of the input clock source.
  • freq number - Requested frequency.

Back to Top


clock_stop

Description: Stop the specified clock.

Parameters:

  • clk_index number - The clock to stop.

Back to Top


clock_get_hz

Description: Get the current frequency of the specified clock.

Parameters:

  • clk_index number - Clock.

Returns: number - Clock frequency in Hz .

Back to Top


frequency_count_khz

Description: Measure a clocks frequency using the Frequency counter.

Parameters:

  • src number - __

Back to Top


clock_set_reported_hz

Description: Set the "current frequency" of the clock as reported by clock_get_hz without actually changing the clock.

Parameters:

  • clk_index number - __
  • hz number - __

Back to Top


clocks_enable_resus

Description: Enable the resus function. Restarts clk_sys if it is accidentally stopped.

Parameters:

  • resus_callback resus_callback_t - A function pointer provided by the user to call if a resus event happens.

Back to Top


clock_gpio_init_int_frac

Description: Output an optionally divided clock to the specified gpio pin.

Parameters:

  • gpio number - The GPIO pin to output the clock to. Valid GPIOs are: 21, 23, 24, 25. These GPIOs are connected to the GPOUT0-3 clock generators.
  • src number - The source clock. See the register field CLOCKS_CLK_GPOUT0_CTRL_AUXSRC for a full list. The list is the same for each GPOUT clock generator.
  • div_int number - The integer part of the value to divide the source clock by. This is useful to not overwhelm the GPIO pin with a fast clock. this is in range of 1..2^24-1.
  • div_frac number - The fractional part of the value to divide the source clock by. This is in range of 0..255 (/256).

Back to Top


clock_gpio_init

Description: Output an optionally divided clock to the specified gpio pin.

Parameters:

  • gpio number - The GPIO pin to output the clock to. Valid GPIOs are: 21, 23, 24, 25. These GPIOs are connected to the GPOUT0-3 clock generators.
  • src number - The source clock. See the register field CLOCKS_CLK_GPOUT0_CTRL_AUXSRC for a full list. The list is the same for each GPOUT clock generator.
  • div number - The float amount to divide the source clock by. This is useful to not overwhelm the GPIO pin with a fast clock.

Back to Top


clock_configure_gpin

Description: Configure a clock to come from a gpio input.

Parameters:

  • clk_index number - The clock to configure.
  • gpio number - The GPIO pin to run the clock from. Valid GPIOs are: 20 and 22.
  • src_freq number - Frequency of the input clock source.
  • freq number - Requested frequency.

Back to Top


gpio_set_function

Description: Select GPIO function.

Parameters:

  • gpio number - GPIO number.
  • fn number - Which GPIO function select to use from list gpio_function.

Back to Top


gpio_get_function

Description: Determine current GPIO function.

Parameters:

  • gpio number - GPIO number.

Returns: number - Which GPIO function is currently selected from list gpio_function .

Back to Top


gpio_set_pulls

Description: Select up and down pulls on specific GPIO.

Parameters:

  • gpio number - GPIO number.
  • up boolean - If true set a pull up on the GPIO.
  • down boolean - If true set a pull down on the GPIO.

Back to Top


gpio_pull_up

Description: Set specified GPIO to be pulled up.

Parameters:

  • gpio number - GPIO number.

Back to Top


gpio_is_pulled_up

Description: Determine if the specified GPIO is pulled up.

Parameters:

  • gpio number - GPIO number.

Returns: boolean - True if the GPIO is pulled up .

Back to Top


gpio_pull_down

Description: Set specified GPIO to be pulled down.

Parameters:

  • gpio number - GPIO number.

Back to Top


gpio_is_pulled_down

Description: Determine if the specified GPIO is pulled down.

Parameters:

  • gpio number - GPIO number.

Returns: boolean - True if the GPIO is pulled down .

Back to Top


gpio_disable_pulls

Description: Disable pulls on specified GPIO.

Parameters:

  • gpio number - GPIO number.

Back to Top


gpio_set_irqover

Description: Set GPIO IRQ override.

Parameters:

  • gpio number - GPIO number.
  • value number - See gpio_override.

Back to Top


gpio_set_outover

Description: Set GPIO output override.

Parameters:

  • gpio number - GPIO number.
  • value number - See gpio_override.

Back to Top


gpio_set_inover

Description: Select GPIO input override.

Parameters:

  • gpio number - GPIO number.
  • value number - See gpio_override.

Back to Top


gpio_set_oeover

Description: Select GPIO output enable override.

Parameters:

  • gpio number - GPIO number.
  • value number - See gpio_override.

Back to Top


gpio_set_input_enabled

Description: Enable GPIO input.

Parameters:

  • gpio number - GPIO number.
  • enabled boolean - True to enable input on specified GPIO.

Back to Top


gpio_set_input_hysteresis_enabled

Description: Enable/disable GPIO input hysteresis (Schmitt trigger).

Parameters:

  • gpio number - GPIO number.
  • enabled boolean - True to enable input hysteresis on specified GPIO.

Back to Top


gpio_is_input_hysteresis_enabled

Description: Determine whether input hysteresis is enabled on a specified GPIO.

Parameters:

  • gpio number - GPIO number.

Back to Top


gpio_set_slew_rate

Description: Set slew rate for a specified GPIO.

Parameters:

  • gpio number - GPIO number.
  • slew number - GPIO output slew rate.

Back to Top


gpio_get_slew_rate

Description: Determine current slew rate for a specified GPIO.

Parameters:

  • gpio number - GPIO number.

Returns: number - Current slew rate of that GPIO .

Back to Top


gpio_set_drive_strength

Description: Set drive strength for a specified GPIO.

Parameters:

  • gpio number - GPIO number.
  • drive number - GPIO output drive strength.

Back to Top


gpio_get_drive_strength

Description: Determine current slew rate for a specified GPIO.

Parameters:

  • gpio number - GPIO number.

Returns: number - Current drive strength of that GPIO .

Back to Top


gpio_set_irq_enabled

Description: Enable or disable specific interrupt events for specified GPIO.

Parameters:

  • gpio number - GPIO number.
  • event_mask number - Which events will cause an interrupt.
  • enabled boolean - Enable or disable flag.

Back to Top


gpio_set_irq_callback

Description: Set the generic callback used for GPIO IRQ events for the current core.

Parameters:

  • callback gpio_irq_callback_t - Default user function to call on GPIO irq. Note only one of these can be set per processor.

Back to Top


gpio_set_irq_enabled_with_callback

Description: Convenience function which performs multiple GPIO IRQ related initializations.

Parameters:

  • gpio number - GPIO number.
  • event_mask number - Which events will cause an interrupt. See gpio_irq_level for details.
  • enabled boolean - Enable or disable flag.
  • callback gpio_irq_callback_t - User function to call on GPIO irq. if NULL, the callback is removed.

Back to Top


gpio_set_dormant_irq_enabled

Description: Enable dormant wake up interrupt for specified GPIO and events.

Parameters:

  • gpio number - GPIO number.
  • event_mask number - Which events will cause an interrupt. See gpio_irq_level for details.
  • enabled boolean - Enable/disable flag.

Back to Top


gpio_get_irq_event_mask

Description: Return the current interrupt status (pending events) for the given GPIO.

Parameters:

  • gpio number - GPIO number.

Returns: number - Bitmask of events that are currently pending for the GPIO. See gpio_irq_level for details. .

Back to Top


gpio_acknowledge_irq

Description: Acknowledge a GPIO interrupt for the specified events on the calling core.

Parameters:

  • gpio number - GPIO number.
  • event_mask number - Bitmask of events to clear. See gpio_irq_level for details.

Back to Top


gpio_init

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

Parameters:

  • gpio number - GPIO number.

Back to Top


gpio_deinit

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

Parameters:

  • gpio number - GPIO number.

Back to Top


gpio_init_mask

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

Parameters:

  • gpio_mask number - Mask with 1 bit per GPIO number to initialize.

Back to Top


gpio_get

Description: Get state of a single specified GPIO.

Parameters:

  • gpio number - GPIO number.

Returns: boolean - Current state of the GPIO. 0 for low, non-zero for high .

Back to Top


gpio_get_all

Description: Get raw value of all GPIOs.

Returns: number - Bitmask of raw GPIO values, as bits 0-29 .

Back to Top


gpio_set_mask

Description: Drive high every GPIO appearing in mask.

Parameters:

  • mask number - Bitmask of GPIO values to set, as bits 0-29.

Back to Top


gpio_clr_mask

Description: Drive low every GPIO appearing in mask.

Parameters:

  • mask number - Bitmask of GPIO values to clear, as bits 0-29.

Back to Top


gpio_xor_mask

Description: Toggle every GPIO appearing in mask.

Parameters:

  • mask number - Bitmask of GPIO values to toggle, as bits 0-29.

Back to Top


gpio_put_masked

Description: Drive GPIO high/low depending on parameters.

Parameters:

  • mask number - Bitmask of GPIO values to change, as bits 0-29.
  • value number - Value to set.

Back to Top


gpio_put_all

Description: Drive all pins simultaneously.

Parameters:

  • value number - Bitmask of GPIO values to change, as bits 0-29.

Back to Top


gpio_put

Description: Drive a single GPIO high/low.

Parameters:

  • gpio number - GPIO number.
  • value boolean - If false clear the GPIO, otherwise set it.

Back to Top


gpio_get_out_level

Description: Determine whether a GPIO is currently driven high or low.

Parameters:

  • gpio number - GPIO number.

Returns: boolean - True if the GPIO output level is high, false if low. .

Back to Top


gpio_set_dir_out_masked

Description: Set a number of GPIOs to output.

Parameters:

  • mask number - Bitmask of GPIO to set to output, as bits 0-29.

Back to Top


gpio_set_dir_in_masked

Description: Set a number of GPIOs to input.

Parameters:

  • mask number - Bitmask of GPIO to set to input, as bits 0-29.

Back to Top


gpio_set_dir_masked

Description: Set multiple GPIO directions.

Parameters:

  • mask number - Bitmask of GPIO to set to input, as bits 0-29.
  • value number - Values to set.

Back to Top


gpio_set_dir_all_bits

Description: Set direction of all pins simultaneously.

Parameters:

  • values number - Individual settings for each gpio; for GPIO N, bit N is 1 for out, 0 for in.

Back to Top


gpio_set_dir

Description: Set a single GPIO direction.

Parameters:

  • gpio number - GPIO number.
  • out boolean - True for out, false for in.

Back to Top


gpio_is_dir_out

Description: Check if a specific GPIO direction is OUT.

Parameters:

  • gpio number - GPIO number.

Returns: boolean - True if the direction for the pin is OUT .

Back to Top


gpio_get_dir

Description: Get a specific GPIO direction.

Parameters:

  • gpio number - GPIO number.

Returns: number - 1 for out, 0 for in .

Back to Top


time_us_32

Description: Return a 32 bit timestamp value in microseconds.

Returns: number - The 32 bit timestamp .

Back to Top


time_us_64

Description: Return the current 64 bit timestamp value in microseconds.

Returns: number - The 64 bit timestamp.

Back to Top


busy_wait_us_32

Description: Busy wait wasting cycles for the given (32 bit) number of microseconds.

Parameters:

  • delay_us number - Delay amount in microseconds.

Back to Top


busy_wait_us

Description: Busy wait wasting cycles for the given (64 bit) number of microseconds.

Parameters:

  • delay_us number - Delay amount in microseconds.

Back to Top


busy_wait_ms

Description: Busy wait wasting cycles for the given number of milliseconds.

Parameters:

  • delay_ms number - Delay amount in milliseconds.

Back to Top


busy_wait_until

Description: Busy wait wasting cycles until after the specified timestamp.

Parameters:

  • t number - Absolute time to wait until.

Back to Top


time_reached

Description: Check if the specified timestamp has been reached.

Parameters:

  • t number - Absolute time to compare against current time.

Returns: boolean - True if it is now after the specified timestamp .

Back to Top


hardware_alarm_claim

Description: Cooperatively claim the use of this hardware alarm_num.

Parameters:

  • alarm_num number - The hardware alarm to claim.

Back to Top


hardware_alarm_claim_unused

Description: Cooperatively claim the use of this hardware alarm_num.

Parameters:

  • required boolean - __

Returns: number - Alarm_num the hardware alarm claimed or -1 if requires was false, and none are available .

Back to Top


hardware_alarm_unclaim

Description: Cooperatively release the claim on use of this hardware alarm_num.

Parameters:

  • alarm_num number - The hardware alarm to unclaim.

Back to Top


hardware_alarm_is_claimed

Description: Determine if a hardware alarm has been claimed.

Parameters:

  • alarm_num number - The hardware alarm number.

Returns: boolean - True if claimed, false otherwise .

Back to Top


hardware_alarm_set_callback

Description: Enable/Disable a callback for a hardware timer on this core.

Parameters:

  • alarm_num number - The hardware alarm number.
  • callback hardware_alarm_callback_t - The callback to install, or NULL to unset.

Back to Top


hardware_alarm_set_target

Description: Set the current target for the specified hardware alarm.

Parameters:

  • alarm_num number - The hardware alarm number.
  • t number - The target timestamp.

Returns: boolean - True if the target was "missed"; i.e. it was in the past, or occurred before a future hardware timeout could be set .

Back to Top


hardware_alarm_cancel

Description: Cancel an existing target (if any) for a given hardware_alarm.

Parameters:

  • alarm_num number - The hardware alarm number.

Back to Top


hardware_alarm_force_irq

Description: Force and IRQ for a specific hardware alarm.

Parameters:

  • alarm_num number - The hardware alarm number.

Back to Top