Table of contents
- Module pico/highlevel
- Module pico/hardware
- adc_init
- adc_gpio_init
- adc_select_input
- adc_get_selected_input
- adc_set_round_robin
- adc_set_temp_sensor_enabled
- adc_read
- adc_run
- adc_set_clkdiv
- adc_fifo_setup
- adc_fifo_is_empty
- adc_fifo_get_level
- adc_fifo_get
- adc_fifo_get_blocking
- adc_fifo_drain
- adc_irq_set_enabled
- clocks_init
- clock_configure
- clock_stop
- clock_get_hz
- frequency_count_khz
- clock_set_reported_hz
- clocks_enable_resus
- clock_gpio_init_int_frac
- clock_gpio_init
- clock_configure_gpin
- gpio_set_function
- gpio_get_function
- gpio_set_pulls
- gpio_pull_up
- gpio_is_pulled_up
- gpio_pull_down
- gpio_is_pulled_down
- gpio_disable_pulls
- gpio_set_irqover
- gpio_set_outover
- gpio_set_inover
- gpio_set_oeover
- gpio_set_input_enabled
- gpio_set_input_hysteresis_enabled
- gpio_is_input_hysteresis_enabled
- gpio_set_slew_rate
- gpio_get_slew_rate
- gpio_set_drive_strength
- gpio_get_drive_strength
- gpio_set_irq_enabled
- gpio_set_irq_callback
- gpio_set_irq_enabled_with_callback
- gpio_set_dormant_irq_enabled
- gpio_get_irq_event_mask
- gpio_acknowledge_irq
- gpio_init
- gpio_deinit
- gpio_init_mask
- gpio_get
- gpio_get_all
- gpio_set_mask
- gpio_clr_mask
- gpio_xor_mask
- gpio_put_masked
- gpio_put_all
- gpio_put
- gpio_get_out_level
- gpio_set_dir_out_masked
- gpio_set_dir_in_masked
- gpio_set_dir_masked
- gpio_set_dir_all_bits
- gpio_set_dir
- gpio_is_dir_out
- gpio_get_dir
- time_us_32
- time_us_64
- busy_wait_us_32
- busy_wait_us
- busy_wait_ms
- busy_wait_until
- time_reached
- hardware_alarm_claim
- hardware_alarm_claim_unused
- hardware_alarm_unclaim
- hardware_alarm_is_claimed
- hardware_alarm_set_callback
- hardware_alarm_set_target
- hardware_alarm_cancel
- hardware_alarm_force_irq
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.
sleep_us
Description: Wait for the given number of microseconds before returning.
Parameters:
- us
number
- The number of microseconds to sleep.
sleep_ms
Description: Wait for the given number of milliseconds before returning.
Parameters:
- ms
number
- The number of milliseconds to sleep.
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 .
Module pico/hardware
adc_init
Description: Initialise the ADC HW.
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.
adc_select_input
Description: ADC input select.
Parameters:
- input
number
- Input to select.
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. .
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.
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.
adc_read
Description: Perform a single conversion.
Returns: number
- Result of the conversion. .
adc_run
Description: Enable or disable free-running sampling mode.
Parameters:
- run
boolean
- False to disable, true to enable free running conversion mode.
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.
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.
adc_fifo_is_empty
Description: Check FIFO empty state.
Returns: boolean
- Returns true if the FIFO is empty .
adc_fifo_get_level
Description: Get number of entries in the ADC FIFO.
adc_fifo_get
Description: Get ADC result from FIFO.
adc_fifo_get_blocking
Description: Wait for the ADC FIFO to have data.
adc_fifo_drain
Description: Drain the ADC FIFO.
adc_irq_set_enabled
Description: Enable/Disable ADC interrupts.
Parameters:
- enabled
boolean
- Set to true to enable the ADC interrupts, false to disable.
clocks_init
Description: Initialise the clock hardware.
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.
clock_stop
Description: Stop the specified clock.
Parameters:
- clk_index
number
- The clock to stop.
clock_get_hz
Description: Get the current frequency of the specified clock.
Parameters:
- clk_index
number
- Clock.
Returns: number
- Clock frequency in Hz .
frequency_count_khz
Description: Measure a clocks frequency using the Frequency counter.
Parameters:
- src
number
- __
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
- __
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.
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).
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.
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.
gpio_set_function
Description: Select GPIO function.
Parameters:
- gpio
number
- GPIO number. - fn
number
- Which GPIO function select to use from list gpio_function.
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 .
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.
gpio_pull_up
Description: Set specified GPIO to be pulled up.
Parameters:
- gpio
number
- GPIO number.
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 .
gpio_pull_down
Description: Set specified GPIO to be pulled down.
Parameters:
- gpio
number
- GPIO number.
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 .
gpio_disable_pulls
Description: Disable pulls on specified GPIO.
Parameters:
- gpio
number
- GPIO number.
gpio_set_irqover
Description: Set GPIO IRQ override.
Parameters:
- gpio
number
- GPIO number. - value
number
- See gpio_override.
gpio_set_outover
Description: Set GPIO output override.
Parameters:
- gpio
number
- GPIO number. - value
number
- See gpio_override.
gpio_set_inover
Description: Select GPIO input override.
Parameters:
- gpio
number
- GPIO number. - value
number
- See gpio_override.
gpio_set_oeover
Description: Select GPIO output enable override.
Parameters:
- gpio
number
- GPIO number. - value
number
- See gpio_override.
gpio_set_input_enabled
Description: Enable GPIO input.
Parameters:
- gpio
number
- GPIO number. - enabled
boolean
- True to enable input on specified GPIO.
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.
gpio_is_input_hysteresis_enabled
Description: Determine whether input hysteresis is enabled on a specified GPIO.
Parameters:
- gpio
number
- GPIO number.
gpio_set_slew_rate
Description: Set slew rate for a specified GPIO.
Parameters:
- gpio
number
- GPIO number. - slew
number
- GPIO output slew rate.
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 .
gpio_set_drive_strength
Description: Set drive strength for a specified GPIO.
Parameters:
- gpio
number
- GPIO number. - drive
number
- GPIO output drive strength.
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 .
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.
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.
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.
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.
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. .
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.
gpio_init
Description: Initialise a GPIO for (enabled I/O and set func to GPIO_FUNC_SIO).
Parameters:
- gpio
number
- GPIO number.
gpio_deinit
Description: Resets a GPIO back to the NULL function, i.e. disables it.
Parameters:
- gpio
number
- GPIO number.
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.
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 .
gpio_get_all
Description: Get raw value of all GPIOs.
Returns: number
- Bitmask of raw GPIO values, as bits 0-29 .
gpio_set_mask
Description: Drive high every GPIO appearing in mask.
Parameters:
- mask
number
- Bitmask of GPIO values to set, as bits 0-29.
gpio_clr_mask
Description: Drive low every GPIO appearing in mask.
Parameters:
- mask
number
- Bitmask of GPIO values to clear, as bits 0-29.
gpio_xor_mask
Description: Toggle every GPIO appearing in mask.
Parameters:
- mask
number
- Bitmask of GPIO values to toggle, as bits 0-29.
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.
gpio_put_all
Description: Drive all pins simultaneously.
Parameters:
- value
number
- Bitmask of GPIO values to change, as bits 0-29.
gpio_put
Description: Drive a single GPIO high/low.
Parameters:
- gpio
number
- GPIO number. - value
boolean
- If false clear the GPIO, otherwise set it.
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. .
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.
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.
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.
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.
gpio_set_dir
Description: Set a single GPIO direction.
Parameters:
- gpio
number
- GPIO number. - out
boolean
- True for out, false for in.
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 .
gpio_get_dir
Description: Get a specific GPIO direction.
Parameters:
- gpio
number
- GPIO number.
Returns: number
- 1 for out, 0 for in .
time_us_32
Description: Return a 32 bit timestamp value in microseconds.
Returns: number
- The 32 bit timestamp .
time_us_64
Description: Return the current 64 bit timestamp value in microseconds.
Returns: number
- The 64 bit timestamp.
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.
busy_wait_us
Description: Busy wait wasting cycles for the given (64 bit) number of microseconds.
Parameters:
- delay_us
number
- Delay amount in microseconds.
busy_wait_ms
Description: Busy wait wasting cycles for the given number of milliseconds.
Parameters:
- delay_ms
number
- Delay amount in milliseconds.
busy_wait_until
Description: Busy wait wasting cycles until after the specified timestamp.
Parameters:
- t
number
- Absolute time to wait until.
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 .
hardware_alarm_claim
Description: Cooperatively claim the use of this hardware alarm_num.
Parameters:
- alarm_num
number
- The hardware alarm to claim.
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 .
hardware_alarm_unclaim
Description: Cooperatively release the claim on use of this hardware alarm_num.
Parameters:
- alarm_num
number
- The hardware alarm to unclaim.
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 .
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.
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 .
hardware_alarm_cancel
Description: Cancel an existing target (if any) for a given hardware_alarm.
Parameters:
- alarm_num
number
- The hardware alarm number.
hardware_alarm_force_irq
Description: Force and IRQ for a specific hardware alarm.
Parameters:
- alarm_num
number
- The hardware alarm number.