Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8093

SDK • Re: Does gpio_get_all64() return a single-cycle state?

$
0
0
The code is:

Code:

/*! \brief Get raw value of all GPIOs *  \ingroup hardware_gpio * * \return Bitmask of raw GPIO values */static inline uint64_t gpio_get_all64(void) {#if PICO_USE_GPIO_COPROCESSOR    return gpioc_hilo_in_get();#elif NUM_BANK0_GPIOS <= 32    return sio_hw->gpio_in;#else    return sio_hw->gpio_in | (((uint64_t)sio_hw->gpio_hi_in) << 32u);#endif}
On the RP2350 build, PICO_USE_GPIO_COPROCESSOR is set, so this is called, which is a single cycle/atomic read.

Code:

// Sample 64 GPIOs on the same cycle. Equivalent to:////     return sio_hw->gpio_in | ((uint64_t)sio_hw->gpio_hi_in << 32);__force_inline static uint64_t gpioc_hilo_in_get(void) {    uint32_t hi, lo;    pico_default_asm_volatile ("mrrc p0, #0, %0, %1, c8" : "=r" (lo), "=r" (hi));    return ((uint64_t)hi << 32) | lo;}

Statistics: Posted by jamesh — Mon Mar 24, 2025 11:44 am



Viewing all articles
Browse latest Browse all 8093

Trending Articles