mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-08 22:01:42 +00:00
60 lines
1.3 KiB
C
60 lines
1.3 KiB
C
/*
|
|
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include "riscv/csr.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*fast gpio*/
|
|
#define CSR_GPIO_OEN_USER 0x803
|
|
#define CSR_GPIO_IN_USER 0x804
|
|
#define CSR_GPIO_OUT_USER 0x805
|
|
|
|
/*!< The dedicated GPIO (a.k.a. fast GPIO) is featured by some customized CPU instructions, which is always enabled */
|
|
#define DEDIC_GPIO_CPU_LL_PERIPH_ALWAYS_ENABLE 1
|
|
|
|
__attribute__((always_inline))
|
|
static inline void dedic_gpio_cpu_ll_enable_output(uint32_t mask)
|
|
{
|
|
RV_WRITE_CSR(CSR_GPIO_OEN_USER, mask);
|
|
}
|
|
|
|
__attribute__((always_inline))
|
|
static inline void dedic_gpio_cpu_ll_write_all(uint32_t value)
|
|
{
|
|
RV_WRITE_CSR(CSR_GPIO_OUT_USER, value);
|
|
}
|
|
|
|
__attribute__((always_inline))
|
|
static inline uint32_t dedic_gpio_cpu_ll_read_in(void)
|
|
{
|
|
uint32_t value = RV_READ_CSR(CSR_GPIO_IN_USER);
|
|
return value;
|
|
}
|
|
|
|
__attribute__((always_inline))
|
|
static inline uint32_t dedic_gpio_cpu_ll_read_out(void)
|
|
{
|
|
uint32_t value = RV_READ_CSR(CSR_GPIO_OUT_USER);
|
|
return value;
|
|
}
|
|
|
|
__attribute__((always_inline))
|
|
static inline void dedic_gpio_cpu_ll_write_mask(uint32_t mask, uint32_t value)
|
|
{
|
|
RV_SET_CSR(CSR_GPIO_OUT_USER, mask & value);
|
|
RV_CLEAR_CSR(CSR_GPIO_OUT_USER, mask & ~(value));
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|