Standard IO and reading from external peripherals

I noticed when reading RTOS docs there is a Standard IO functions that allow read\write full bytes from GPIOs and other useful peripherals which is really great.
I wonder if anyone experimented with those and what speeds I can achieve via reading\writing to f.ex HSGPIO. Imagine writing parallel to multiple GPIOs with high frequencies - you can create protocols like MIPI or HDMI.

Pin states can be written or read via gpiohs output_val & input_val registers.
K210 gpiohs is actually one 32-bit parallel IO and all 32 pins are read/written at once in one cycle.
When reading/writing individual pins the appropriate bit is just masked and shifted…

Here is the example low level code for writting a single pin:

volatile gpiohs_t* const gpiohs = (volatile gpiohs_t*)GPIOHS_BASE_ADDR;

void set_pin(int32_t pin, int value)
{
    uint32_t org = (*gpiohs->output_val.u32) & ~(1 << pin);
    *gpiohs->output_val.u32 = org | (value & (1 << pin));
}

output_val & input_val registers are defined as gpiohs_u32_t

/**
 * @brief       GPIO bits multi access union
 */
typedef union _gpiohs_u32
{
    /* 32x1 bit mode */
    uint32_t u32[1];
    /* 16x2 bit mode */
    uint16_t u16[2];
    /* 8x4 bit mode */
    uint8_t u8[4];
    /* 1 bit mode */
    gpiohs_bits_t bits;
} __attribute__((packed, aligned(4))) gpiohs_u32_t;

and can be accessed as 32-bit, 16-bit, 8-bit or 1-bit values, so very flexible parallel IO is possible.
You just have to configure the used pins the right way using fpioa functions.

K210 gpiohs interface is extremelly flexible and this is just a part of what you can do with it.

If you optimize your code you can set the pin value(s) at speeds higher than 100 MHz.
You can even use DMA to set the pin values at even higher speed (from SRAM buffer) …

That’s nice code loboris, thanks. We should write that function in risc-v asm too)
I am able to compile esp code for esp8285 using latest ESP8266-RTOS_SDK for the onboard wifi chip of K210. Just was thinking what would be the best way to send on esp end and receive on Kendryte end the databits from network. ESP8266 has 80MHz SPI if I remember but maybe there is a faster way