VSF Documented
Data Structures | Macros | Typedefs | Enumerations | Functions
vsf_template_gpio.h File Reference
#include "./vsf_template_hal_driver.h"
#include "hal/arch/vsf_arch.h"

Go to the source code of this file.

Data Structures

struct  vsf_gpio_exti_irq_cfg_t
 
struct  vsf_gpio_cfg_t
 gpio channel configuration More...
 
struct  vsf_gpio_port_cfg_pin_t
 
struct  vsf_gpio_port_cfg_pins_t
 
struct  vsf_gpio_capability_t
 
struct  vsf_gpio_op_t
 
struct  vsf_gpio_t
 

Macros

#define VSF_GPIO_CFG_MULTI_CLASS   ENABLED
 
#define vsf_io_pin_mask_t   uint32_t
 
#define VSF_GPIO_CFG_PIN_COUNT   32
 
#define VSF_GPIO_CFG_PIN_MASK   0xFFFFFFFF
 
#define VSF_GPIO_CFG_PREFIX   vsf
 
#define VSF_GPIO_CFG_REIMPLEMENT_TYPE_MODE   DISABLED
 
#define VSF_GPIO_CFG_FUNCTION_RENAME   ENABLED
 
#define VSF_GPIO_CFG_REIMPLEMENT_TYPE_CFG   DISABLED
 
#define VSF_GPIO_CFG_REIMPLEMENT_TYPE_CAPABILITY   DISABLED
 
#define VSF_GPIO_CFG_INHERT_HAL_CAPABILITY   ENABLED
 
#define vsf_gpio_pin_mask_t   uint32_t
 
#define __VSF_GPIO_PORT_PIN_NUM(__PIN_NUM, __PORT_NUM)    VSF_P ## __PORT_NUM ## __PIN_NUM = ((VSF_PORT ##__PORT_NUM) << 8) | __PIN_NUM,
 
#define VSF_GPIO_APIS(__prefix_name)
 
#define __VSF_HAL_TEMPLATE_API   VSF_HAL_TEMPLATE_API_FP
 
#define __vsf_gpio_t   VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_t)
 
#define vsf_gpio_capability(__GPIO)   VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_capability) ((__vsf_gpio_t *)(__GPIO))
 
#define vsf_gpio_port_config_pins(__GPIO, ...)   VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_port_config_pins) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)
 
#define vsf_gpio_set_direction(__GPIO, ...)   VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_set_direction) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)
 
#define vsf_gpio_get_direction(__GPIO, ...)   VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_get_direction) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)
 
#define vsf_gpio_set_input(__GPIO, ...)   VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_set_input) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)
 
#define vsf_gpio_set_output(__GPIO, ...)   VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_set_output) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)
 
#define vsf_gpio_switch_direction(__GPIO, ...)   VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_switch_direction) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)
 
#define vsf_gpio_read(__GPIO)   VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_read) ((__vsf_gpio_t *)(__GPIO))
 
#define vsf_gpio_write(__GPIO, ...)   VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_write) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)
 
#define vsf_gpio_set(__GPIO, ...)   VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_set) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)
 
#define vsf_gpio_clear(__GPIO, ...)   VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_clear) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)
 
#define vsf_gpio_output_and_set(__GPIO, ...)   VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_output_and_set) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)
 
#define vsf_gpio_output_and_clear(__GPIO, ...)   VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_output_and_clear) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)
 
#define vsf_gpio_toggle(__GPIO, ...)   VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_toggle) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)
 
#define vsf_gpio_exti_irq_config(__GPIO, ...)   VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_exti_irq_config) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)
 
#define vsf_gpio_exti_irq_enable(__GPIO, ...)   VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_exti_irq_enable) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)
 
#define vsf_gpio_exti_irq_disable(__GPIO, ...)   VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_exti_irq_disable) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)
 
#define vsf_gpio_exti_irq_pin_config(__GPIO, ...)   VSF_MCONNECT(vsf_exti_gpio, _exti_irq_pin_config) ((vsf_exti_gpio_t *)(__GPIO), ##__VA_ARGS__)
 

Typedefs

typedef enum vsf_gpio_mode_t vsf_gpio_mode_t
 Predefined VSF GPIO modes that can be reimplemented in specific hal drivers.
 
typedef struct vsf_gpio_t vsf_gpio_t
 Pre-declaration of GPIO structures.
 
typedef void vsf_gpio_exti_isr_handler_t(void *target_ptr, vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask)
 External interrupt callback function for gpio.
 
typedef struct vsf_gpio_exti_irq_cfg_t vsf_gpio_exti_irq_cfg_t
 
typedef struct vsf_gpio_cfg_t vsf_gpio_cfg_t
 gpio channel configuration
 
typedef struct vsf_gpio_port_cfg_pin_t vsf_gpio_port_cfg_pin_t
 
typedef struct vsf_gpio_port_cfg_pins_t vsf_gpio_port_cfg_pins_t
 
typedef struct vsf_gpio_capability_t vsf_gpio_capability_t
 
typedef struct vsf_gpio_op_t vsf_gpio_op_t
 

Enumerations

enum  vsf_gpio_mode_t {
  VSF_GPIO_INPUT = (0 << 0) ,
  VSF_GPIO_ANALOG = (1 << 0) ,
  VSF_GPIO_OUTPUT_PUSH_PULL = (2 << 0) ,
  VSF_GPIO_OUTPUT_OPEN_DRAIN = (3 << 0) ,
  VSF_GPIO_EXTI = (4 << 0) ,
  VSF_GPIO_AF = (5 << 0) ,
  VSF_GPIO_NO_PULL_UP_DOWN = (0 << 4) ,
  VSF_GPIO_PULL_UP = (1 << 4) ,
  VSF_GPIO_PULL_DOWN = (2 << 4) ,
  VSF_GPIO_EXTI_MODE_NONE = (0 << 6) ,
  VSF_GPIO_EXTI_MODE_LOW_LEVEL = (1 << 6) ,
  VSF_GPIO_EXTI_MODE_HIGH_LEVEL = (2 << 6) ,
  VSF_GPIO_EXTI_MODE_RISING = (3 << 6) ,
  VSF_GPIO_EXTI_MODE_FALLING = (4 << 6) ,
  VSF_GPIO_EXTI_MODE_RISING_FALLING = (5 << 6)
}
 Predefined VSF GPIO modes that can be reimplemented in specific hal drivers. More...
 
enum  {
  VSF_GPIO_FLOATING = VSF_GPIO_NO_PULL_UP_DOWN ,
  VSF_GPIO_MODE_MASK ,
  VSF_GPIO_PULL_UP_DOWN_MASK ,
  VSF_GPIO_EXTI_MODE_MASK ,
  VSF_GPIO_MODE_ALL_BITS_MASK
}
 

Functions

vsf_err_t vsf_gpio_port_config_pins (vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask, vsf_gpio_cfg_t *cfg)
 Configure one or more pins of the gpio instance.
 
void vsf_gpio_set_direction (vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask, vsf_gpio_pin_mask_t direction_mask)
 ‍**
 
vsf_gpio_pin_mask_t vsf_gpio_get_direction (vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask)
 Get the orientation of one or more pins of the gpio instance.
 
void vsf_gpio_set_input (vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask)
 Set the direction of one or more pins of the gpio instance to input.
 
void vsf_gpio_set_output (vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask)
 Set the direction of one or more pins of the gpio instance to output.
 
void vsf_gpio_switch_direction (vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask)
 Toggle the orientation of one or more pins of a gpio instance.
 
vsf_gpio_pin_mask_t vsf_gpio_read (vsf_gpio_t *gpio_ptr)
 Read the values of all pins of the gpio instance.
 
void vsf_gpio_write (vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask, vsf_gpio_pin_mask_t value)
 set the value of one or more of the gpio instances
 
void vsf_gpio_set (vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask)
 Set the value of one or more pins of the gpio instance to high.
 
void vsf_gpio_clear (vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask)
 Set the value of one or more pins of the gpio instance to low.
 
void vsf_gpio_toggle (vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask)
 Toggle the value of one or more pins of the gpio instance.
 
void vsf_gpio_output_and_set (vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask)
 Set the direction of one or more pins of the gpio instance to output high.
 
void vsf_gpio_output_and_clear (vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask)
 Set the direction of one or more pins of the gpio instance to output low.
 
vsf_gpio_capability_t vsf_gpio_capability (vsf_gpio_t *gpio_ptr)
 Get the capability of gpio instance.
 
vsf_err_t vsf_gpio_exti_irq_config (vsf_gpio_t *gpio_ptr, vsf_gpio_exti_irq_cfg_t *cfg_ptr)
 Configure external interrupt of the gpio instance.
 
vsf_err_t vsf_gpio_exti_irq_enable (vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask)
 Enable interrupt of one or more pins.
 
vsf_err_t vsf_gpio_exti_irq_disable (vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask)
 Disable interrupt of one or more pins.
 

Macro Definition Documentation

◆ VSF_GPIO_CFG_MULTI_CLASS

#define VSF_GPIO_CFG_MULTI_CLASS   ENABLED

◆ vsf_io_pin_mask_t

#define vsf_io_pin_mask_t   uint32_t

◆ VSF_GPIO_CFG_PIN_COUNT

#define VSF_GPIO_CFG_PIN_COUNT   32

◆ VSF_GPIO_CFG_PIN_MASK

#define VSF_GPIO_CFG_PIN_MASK   0xFFFFFFFF

◆ VSF_GPIO_CFG_PREFIX

#define VSF_GPIO_CFG_PREFIX   vsf

VSF_GPIO_CFG_PREFIX is used to set the actual API call when calling the vsf_gpio_*(). For example, if you configure VSF_GPIO_CFG_PREFIX to be vsf_hw, then call vsf_gpio_set_output(), which is actually vsf_hw_gpio_set_output()

If we want the call to vsf_gpio_set_output in xxxx.c to actually call vsf_example_gpio_set_output, then it can be configured in front of the .c:

#undef VSF_GPIO_CFG_PREFIX
#define VSF_GPIO_CFG_PREFIX vsf_example

◆ VSF_GPIO_CFG_REIMPLEMENT_TYPE_MODE

#define VSF_GPIO_CFG_REIMPLEMENT_TYPE_MODE   DISABLED

◆ VSF_GPIO_CFG_FUNCTION_RENAME

#define VSF_GPIO_CFG_FUNCTION_RENAME   ENABLED

◆ VSF_GPIO_CFG_REIMPLEMENT_TYPE_CFG

#define VSF_GPIO_CFG_REIMPLEMENT_TYPE_CFG   DISABLED

Redefine struct vsf_gpio_cfg_t. The vsf_gpio_exti_isr_handler_t type also needs to be redefined For compatibility, members should not be deleted when struct vsf_gpio_cfg_t redefining.

◆ VSF_GPIO_CFG_REIMPLEMENT_TYPE_CAPABILITY

#define VSF_GPIO_CFG_REIMPLEMENT_TYPE_CAPABILITY   DISABLED

Redefine struct vsf_gpio_capability_t. For compatibility, members should not be deleted when struct vsf_gpio_capability_t redefining.

◆ VSF_GPIO_CFG_INHERT_HAL_CAPABILITY

#define VSF_GPIO_CFG_INHERT_HAL_CAPABILITY   ENABLED

◆ vsf_gpio_pin_mask_t

#define vsf_gpio_pin_mask_t   uint32_t

◆ __VSF_GPIO_PORT_PIN_NUM

#define __VSF_GPIO_PORT_PIN_NUM (   __PIN_NUM,
  __PORT_NUM 
)     VSF_P ## __PORT_NUM ## __PIN_NUM = ((VSF_PORT ##__PORT_NUM) << 8) | __PIN_NUM,

◆ VSF_GPIO_APIS

#define VSF_GPIO_APIS (   __prefix_name)
Value:
__VSF_HAL_TEMPLATE_API(__prefix_name, vsf_gpio_capability_t, gpio, capability, VSF_MCONNECT(__prefix_name, _gpio_t) *gpio_ptr) \
__VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, gpio, port_config_pins, VSF_MCONNECT(__prefix_name, _gpio_t) *gpio_ptr, vsf_gpio_pin_mask_t pin_mask, vsf_gpio_cfg_t * cfg_ptr) \
__VSF_HAL_TEMPLATE_API(__prefix_name, void, gpio, set_direction, VSF_MCONNECT(__prefix_name, _gpio_t) *gpio_ptr, vsf_gpio_pin_mask_t pin_mask, vsf_gpio_pin_mask_t direction_mask) \
__VSF_HAL_TEMPLATE_API(__prefix_name, vsf_gpio_pin_mask_t, gpio, get_direction, VSF_MCONNECT(__prefix_name, _gpio_t) *gpio_ptr, vsf_gpio_pin_mask_t pin_mask) \
__VSF_HAL_TEMPLATE_API(__prefix_name, void, gpio, set_input, VSF_MCONNECT(__prefix_name, _gpio_t) *gpio_ptr, vsf_gpio_pin_mask_t pin_mask) \
__VSF_HAL_TEMPLATE_API(__prefix_name, void, gpio, set_output, VSF_MCONNECT(__prefix_name, _gpio_t) *gpio_ptr, vsf_gpio_pin_mask_t pin_mask) \
__VSF_HAL_TEMPLATE_API(__prefix_name, void, gpio, switch_direction, VSF_MCONNECT(__prefix_name, _gpio_t) *gpio_ptr, vsf_gpio_pin_mask_t pin_mask) \
__VSF_HAL_TEMPLATE_API(__prefix_name, vsf_gpio_pin_mask_t, gpio, read, VSF_MCONNECT(__prefix_name, _gpio_t) *gpio_ptr) \
__VSF_HAL_TEMPLATE_API(__prefix_name, void, gpio, write, VSF_MCONNECT(__prefix_name, _gpio_t) *gpio_ptr, vsf_gpio_pin_mask_t pin_mask, vsf_gpio_pin_mask_t value) \
__VSF_HAL_TEMPLATE_API(__prefix_name, void, gpio, set, VSF_MCONNECT(__prefix_name, _gpio_t) *gpio_ptr, vsf_gpio_pin_mask_t pin_mask) \
__VSF_HAL_TEMPLATE_API(__prefix_name, void, gpio, clear, VSF_MCONNECT(__prefix_name, _gpio_t) *gpio_ptr, vsf_gpio_pin_mask_t pin_mask) \
__VSF_HAL_TEMPLATE_API(__prefix_name, void, gpio, toggle, VSF_MCONNECT(__prefix_name, _gpio_t) *gpio_ptr, vsf_gpio_pin_mask_t pin_mask) \
__VSF_HAL_TEMPLATE_API(__prefix_name, void, gpio, output_and_set, VSF_MCONNECT(__prefix_name, _gpio_t) *gpio_ptr, vsf_gpio_pin_mask_t pin_mask) \
__VSF_HAL_TEMPLATE_API(__prefix_name, void, gpio, output_and_clear, VSF_MCONNECT(__prefix_name, _gpio_t) *gpio_ptr, vsf_gpio_pin_mask_t pin_mask) \
__VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, gpio, exti_irq_config, VSF_MCONNECT(__prefix_name, _gpio_t) *gpio_ptr, vsf_gpio_exti_irq_cfg_t *irq_cfg_ptr) \
__VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, gpio, exti_irq_enable, VSF_MCONNECT(__prefix_name, _gpio_t) *gpio_ptr, vsf_gpio_pin_mask_t pin_mask) \
__VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, gpio, exti_irq_disable, VSF_MCONNECT(__prefix_name, _gpio_t) *gpio_ptr, vsf_gpio_pin_mask_t pin_mask)
vsf_err_t
Definition __type.h:42
struct VSF_MCONNECT(VSF_FLASH_CFG_IMP_PREFIX, _flash_t)
Definition flash.c:53
__le16 capability
Definition ieee80211.h:134
Definition vsf_template_gpio.h:422
gpio channel configuration
Definition vsf_template_gpio.h:394
Definition vsf_template_gpio.h:387
#define read
Definition unistd.h:122
#define write
Definition unistd.h:123
vk_av_control_value_t value
Definition vsf_audio.h:171
#define __VSF_HAL_TEMPLATE_API
Definition vsf_template_gpio.h:457
#define vsf_gpio_pin_mask_t
Definition vsf_template_gpio.h:187

◆ __VSF_HAL_TEMPLATE_API

#define __VSF_HAL_TEMPLATE_API   VSF_HAL_TEMPLATE_API_FP

◆ __vsf_gpio_t

#define __vsf_gpio_t   VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_t)

◆ vsf_gpio_capability

#define vsf_gpio_capability (   __GPIO)    VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_capability) ((__vsf_gpio_t *)(__GPIO))

◆ vsf_gpio_port_config_pins

#define vsf_gpio_port_config_pins (   __GPIO,
  ... 
)    VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_port_config_pins) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)

◆ vsf_gpio_set_direction

#define vsf_gpio_set_direction (   __GPIO,
  ... 
)    VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_set_direction) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)

◆ vsf_gpio_get_direction

#define vsf_gpio_get_direction (   __GPIO,
  ... 
)    VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_get_direction) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)

◆ vsf_gpio_set_input

#define vsf_gpio_set_input (   __GPIO,
  ... 
)    VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_set_input) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)

◆ vsf_gpio_set_output

#define vsf_gpio_set_output (   __GPIO,
  ... 
)    VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_set_output) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)

◆ vsf_gpio_switch_direction

#define vsf_gpio_switch_direction (   __GPIO,
  ... 
)    VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_switch_direction) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)

◆ vsf_gpio_read

#define vsf_gpio_read (   __GPIO)    VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_read) ((__vsf_gpio_t *)(__GPIO))

◆ vsf_gpio_write

#define vsf_gpio_write (   __GPIO,
  ... 
)    VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_write) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)

◆ vsf_gpio_set

#define vsf_gpio_set (   __GPIO,
  ... 
)    VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_set) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)

◆ vsf_gpio_clear

#define vsf_gpio_clear (   __GPIO,
  ... 
)    VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_clear) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)

◆ vsf_gpio_output_and_set

#define vsf_gpio_output_and_set (   __GPIO,
  ... 
)    VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_output_and_set) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)

◆ vsf_gpio_output_and_clear

#define vsf_gpio_output_and_clear (   __GPIO,
  ... 
)    VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_output_and_clear) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)

◆ vsf_gpio_toggle

#define vsf_gpio_toggle (   __GPIO,
  ... 
)    VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_toggle) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)

◆ vsf_gpio_exti_irq_config

#define vsf_gpio_exti_irq_config (   __GPIO,
  ... 
)    VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_exti_irq_config) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)

◆ vsf_gpio_exti_irq_enable

#define vsf_gpio_exti_irq_enable (   __GPIO,
  ... 
)    VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_exti_irq_enable) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)

◆ vsf_gpio_exti_irq_disable

#define vsf_gpio_exti_irq_disable (   __GPIO,
  ... 
)    VSF_MCONNECT(VSF_GPIO_CFG_PREFIX, _gpio_exti_irq_disable) ((__vsf_gpio_t *)(__GPIO), ##__VA_ARGS__)

◆ vsf_gpio_exti_irq_pin_config

#define vsf_gpio_exti_irq_pin_config (   __GPIO,
  ... 
)    VSF_MCONNECT(vsf_exti_gpio, _exti_irq_pin_config) ((vsf_exti_gpio_t *)(__GPIO), ##__VA_ARGS__)

Typedef Documentation

◆ vsf_gpio_mode_t

Predefined VSF GPIO modes that can be reimplemented in specific hal drivers.

Even if the hardware doesn't support these features, these modes must be implemented: If the IO supports more modes, such as the alternative output push-pull and the alternative open-drain output, We can implement it in the hardware driver. However, VSF_GPIO_AF mode must be retained. If we add a new mode in the hardware driver, then we also need to define the macro VSF_GPIO_MODE_MASK, whose value is the OR of the value of all modes.

Optional features require one or more enumeration options and a macro with the same name to determine if they are supported at runtime. If the feature supports more than one option, it is recommended to provide the corresponding MASK option, so that the user can switch to different modes at runtime.

Consider the code above. the vsf_io_mode_t provided when the user calls the vsf_io_cfg() API may omit many options. So we require that some of the options should have a value of 0. Including:

  • VSF_GPIO_NO_PULL_UP_DOWN
  • VSF_GPIO_INTERRUPT_DISABLED The values of the optional feature options should also be considered for the default values.

◆ vsf_gpio_t

typedef struct vsf_gpio_t vsf_gpio_t

Pre-declaration of GPIO structures.

◆ vsf_gpio_exti_isr_handler_t

typedef void vsf_gpio_exti_isr_handler_t(void *target_ptr, vsf_gpio_t *gpio_ptr, vsf_gpio_pin_mask_t pin_mask)

External interrupt callback function for gpio.

◆ vsf_gpio_exti_irq_cfg_t

Configure external interrupts for the entire GPIO port, not the specific pins.

◆ vsf_gpio_cfg_t

gpio channel configuration

◆ vsf_gpio_port_cfg_pin_t

◆ vsf_gpio_port_cfg_pins_t

◆ vsf_gpio_capability_t

◆ vsf_gpio_op_t

typedef struct vsf_gpio_op_t vsf_gpio_op_t

Enumeration Type Documentation

◆ vsf_gpio_mode_t

Predefined VSF GPIO modes that can be reimplemented in specific hal drivers.

Even if the hardware doesn't support these features, these modes must be implemented: If the IO supports more modes, such as the alternative output push-pull and the alternative open-drain output, We can implement it in the hardware driver. However, VSF_GPIO_AF mode must be retained. If we add a new mode in the hardware driver, then we also need to define the macro VSF_GPIO_MODE_MASK, whose value is the OR of the value of all modes.

Optional features require one or more enumeration options and a macro with the same name to determine if they are supported at runtime. If the feature supports more than one option, it is recommended to provide the corresponding MASK option, so that the user can switch to different modes at runtime.

Consider the code above. the vsf_io_mode_t provided when the user calls the vsf_io_cfg() API may omit many options. So we require that some of the options should have a value of 0. Including:

  • VSF_GPIO_NO_PULL_UP_DOWN
  • VSF_GPIO_INTERRUPT_DISABLED The values of the optional feature options should also be considered for the default values.
Enumerator
VSF_GPIO_INPUT 

Set the GPIO sa the general-purpose input state. It should select GPIO for the alternative function It is independent of the pull-up, pull-down, and float configurations.

VSF_GPIO_ANALOG 

Set the IO as analog IO, including analog input and analog output. It should select analog or GPIO as an alternative function and set to input direction

VSF_GPIO_OUTPUT_PUSH_PULL 

Set GPIO sa general-purpose IO push-pull output It should select GPIO for the alternative function

VSF_GPIO_OUTPUT_OPEN_DRAIN 

Set GPIO as general-purpose IO open drain output It should select GPIO for the alternative function

VSF_GPIO_EXTI 

Set GPIO as external interrupt IO.

VSF_GPIO_AF 

Set GPIO to Alternative Function.

VSF_GPIO_NO_PULL_UP_DOWN 
VSF_GPIO_PULL_UP 
VSF_GPIO_PULL_DOWN 
VSF_GPIO_EXTI_MODE_NONE 
VSF_GPIO_EXTI_MODE_LOW_LEVEL 
VSF_GPIO_EXTI_MODE_HIGH_LEVEL 
VSF_GPIO_EXTI_MODE_RISING 
VSF_GPIO_EXTI_MODE_FALLING 
VSF_GPIO_EXTI_MODE_RISING_FALLING 

◆ anonymous enum

anonymous enum
Enumerator
VSF_GPIO_FLOATING 
VSF_GPIO_MODE_MASK 
VSF_GPIO_PULL_UP_DOWN_MASK 
VSF_GPIO_EXTI_MODE_MASK 
VSF_GPIO_MODE_ALL_BITS_MASK 

Function Documentation

◆ vsf_gpio_port_config_pins()

vsf_err_t vsf_gpio_port_config_pins ( vsf_gpio_t gpio_ptr,
vsf_gpio_pin_mask_t  pin_mask,
vsf_gpio_cfg_t cfg 
)
extern

Configure one or more pins of the gpio instance.

Parameters
[in]gpio_ptra pointer to structure vsf_gpio_t
[in]pin_maskpin mask, each pin corresponds to one bit, the value of this bit 1 means configuration is required
[in]cfga pointer to structure vsf_gpio_cfg_t
Returns
vsf_err_t: VSF_ERR_NONE if GPIO Configuration Successful, or a negative error code

◆ vsf_gpio_set_direction()

void vsf_gpio_set_direction ( vsf_gpio_t gpio_ptr,
vsf_gpio_pin_mask_t  pin_mask,
vsf_gpio_pin_mask_t  direction_mask 
)
extern

‍**

‍**

Set the orientation of one or more pins of the gpio instance

Parameters
[in]gpio_ptra pointer to structure vsf_gpio_t
[in]direction_maskdirection mask, 1 for output, 0 for input
[in]pin_maskpin mask, each pin corresponds to one bit, the value of this bit 1 means configuration is required

◆ vsf_gpio_get_direction()

vsf_gpio_pin_mask_t vsf_gpio_get_direction ( vsf_gpio_t gpio_ptr,
vsf_gpio_pin_mask_t  pin_mask 
)
extern

Get the orientation of one or more pins of the gpio instance.

Parameters
[in]gpio_ptra pointer to structure vsf_gpio_t
[in]pin_maskpin mask, each pin corresponds to one bit, the value of this bit 1 means configuration is required
Returns
vsf_gpio_pin_mask_t: The value of all pin_mask directions, 1 for output, 0 for input

◆ vsf_gpio_set_input()

void vsf_gpio_set_input ( vsf_gpio_t gpio_ptr,
vsf_gpio_pin_mask_t  pin_mask 
)
extern

Set the direction of one or more pins of the gpio instance to input.

Parameters
[in]gpio_ptra pointer to structure vsf_gpio_t
[in]Pinmask, each pin corresponds to one bit, the value of the bit 1 indicates the need to set to input

◆ vsf_gpio_set_output()

void vsf_gpio_set_output ( vsf_gpio_t gpio_ptr,
vsf_gpio_pin_mask_t  pin_mask 
)
extern

Set the direction of one or more pins of the gpio instance to output.

Parameters
[in]gpio_ptra pointer to structure vsf_gpio_t
[in]Pinmask, each pin corresponds to one bit, the value of the bit 1 indicates the need to set to output

◆ vsf_gpio_switch_direction()

void vsf_gpio_switch_direction ( vsf_gpio_t gpio_ptr,
vsf_gpio_pin_mask_t  pin_mask 
)
extern

Toggle the orientation of one or more pins of a gpio instance.

Parameters
[in]gpio_ptra pointer to structure vsf_gpio_t
[in]Pinmask, each pin corresponds to one bit, the value of the bit 1 indicates the need to set to output

◆ vsf_gpio_read()

vsf_gpio_pin_mask_t vsf_gpio_read ( vsf_gpio_t gpio_ptr)
extern

Read the values of all pins of the gpio instance.

Parameters
[in]gpio_ptra pointer to structure vsf_gpio_t
Returns
vsf_gpio_pin_mask_t: Value of all pins, 1 for output, 0 for input

◆ vsf_gpio_write()

void vsf_gpio_write ( vsf_gpio_t gpio_ptr,
vsf_gpio_pin_mask_t  pin_mask,
vsf_gpio_pin_mask_t  value 
)
extern

set the value of one or more of the gpio instances

Parameters
[in]gpio_ptrpointer to the structure vsf_gpio_t, refer to vsf_gpio_t
[in]valuevalue of the pin, each pin corresponds to a bit, 1 means high, 0 means high
[in]pin_maskpin mask, each pin corresponds to one bit, 1 means the bit needs to be written, 0 means the bit does not need to be updated

◆ vsf_gpio_set()

void vsf_gpio_set ( vsf_gpio_t gpio_ptr,
vsf_gpio_pin_mask_t  pin_mask 
)
extern

Set the value of one or more pins of the gpio instance to high.

Parameters
[in]gpio_ptrpointer to the structure vsf_gpio_t, refer to vsf_gpio_t
[in]pin_maskpin mask, each pin corresponds to one bit, 1 means the bit needs to be written, 0 means the bit does not need to be updated

◆ vsf_gpio_clear()

void vsf_gpio_clear ( vsf_gpio_t gpio_ptr,
vsf_gpio_pin_mask_t  pin_mask 
)
extern

Set the value of one or more pins of the gpio instance to low.

Parameters
[in]gpio_ptrpointer to the structure vsf_gpio_t, refer to vsf_gpio_t
[in]pin_maskpin mask, each pin corresponds to one bit, 1 means the bit needs to be written, 0 means the bit does not need to be updated

◆ vsf_gpio_toggle()

void vsf_gpio_toggle ( vsf_gpio_t gpio_ptr,
vsf_gpio_pin_mask_t  pin_mask 
)
extern

Toggle the value of one or more pins of the gpio instance.

Parameters
[in]gpio_ptrpointer to the structure vsf_gpio_t, refer to vsf_gpio_t
[in]pin_maskpin mask, each pin corresponds to one bit, 1 means the bit needs to be written, 0 means the bit does not need to be updated

◆ vsf_gpio_output_and_set()

void vsf_gpio_output_and_set ( vsf_gpio_t gpio_ptr,
vsf_gpio_pin_mask_t  pin_mask 
)
extern

Set the direction of one or more pins of the gpio instance to output high.

Parameters
[in]gpio_ptrpointer to the structure vsf_gpio_t, refer to vsf_gpio_t
[in]pin_maskpin mask, each pin corresponds to one bit, 1 means the bit needs to be written, 0 means the bit does not need to be updated
Note
This API can be used when modifying the IO direction to output and set to high in order to avoid possible pulses. Note that it is not supported by all hardware. You can get if this mode is supported with vsf_gpio_capability() (is_support_output_and_set)

◆ vsf_gpio_output_and_clear()

void vsf_gpio_output_and_clear ( vsf_gpio_t gpio_ptr,
vsf_gpio_pin_mask_t  pin_mask 
)
extern

Set the direction of one or more pins of the gpio instance to output low.

Parameters
[in]gpio_ptrpointer to the structure vsf_gpio_t, refer to vsf_gpio_t
[in]pin_maskpin mask, each pin corresponds to one bit, 1 means the bit needs to be written, 0 means the bit does not need to be updated
Note
This API can be used when modifying the IO direction to output and set to low in order to avoid possible pulses. Note that it is not supported by all hardware. You can get if this mode is supported with vsf_gpio_capability() (is_support_output_and_set)

◆ vsf_gpio_capability()

vsf_gpio_capability_t vsf_gpio_capability ( vsf_gpio_t gpio_ptr)
extern

Get the capability of gpio instance.

Parameters
[in]gpio_ptrpointer to the structure vsf_gpio_t, refer to vsf_gpio_t

◆ vsf_gpio_exti_irq_config()

vsf_err_t vsf_gpio_exti_irq_config ( vsf_gpio_t gpio_ptr,
vsf_gpio_exti_irq_cfg_t cfg_ptr 
)
extern

Configure external interrupt of the gpio instance.

Parameters
[in]gpio_ptra pointer to structure vsf_gpio_t
[in]cfga pointer to structure vsf_gpio_exti_irq_cfg_t

◆ vsf_gpio_exti_irq_enable()

vsf_err_t vsf_gpio_exti_irq_enable ( vsf_gpio_t gpio_ptr,
vsf_gpio_pin_mask_t  pin_mask 
)
extern

Enable interrupt of one or more pins.

Parameters
[in]gpio_ptra pointer to structure vsf_gpio_t
[in]pin_maskpin mask, each pin corresponds to one bit, 1 means the bit
[in]priopriority of the interrupt or vsf_arch_prio_invalid for disable
Note
For some devices, prio parameter maybe shared between pins on the gpio.
All pending interrupts should be cleared before interrupts are enabled.

◆ vsf_gpio_exti_irq_disable()

vsf_err_t vsf_gpio_exti_irq_disable ( vsf_gpio_t gpio_ptr,
vsf_gpio_pin_mask_t  pin_mask 
)
extern

Disable interrupt of one or more pins.

Parameters
[in]gpio_ptra pointer to structure vsf_gpio_t
[in]pin_maskpin mask, each pin corresponds to one bit, 1 means the bit
Note
For some devices, prio parameter maybe shared between pins on the gpio.