VSF Documented
|
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 |
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. | |
#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 |
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:
#define VSF_GPIO_CFG_REIMPLEMENT_TYPE_MODE DISABLED |
#define VSF_GPIO_CFG_FUNCTION_RENAME ENABLED |
#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.
#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.
#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__) |
typedef enum vsf_gpio_mode_t 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:
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 |
Configure external interrupts for the entire GPIO port, not the specific pins.
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 |
enum 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:
anonymous enum |
|
extern |
Configure one or more pins of the gpio instance.
[in] | gpio_ptr | a pointer to structure vsf_gpio_t |
[in] | pin_mask | pin mask, each pin corresponds to one bit, the value of this bit 1 means configuration is required |
[in] | cfg | a pointer to structure vsf_gpio_cfg_t |
|
extern |
**
**
Set the orientation of one or more pins of the gpio instance
[in] | gpio_ptr | a pointer to structure vsf_gpio_t |
[in] | direction_mask | direction mask, 1 for output, 0 for input |
[in] | pin_mask | pin mask, each pin corresponds to one bit, the value of this bit 1 means configuration is required |
|
extern |
Get the orientation of one or more pins of the gpio instance.
[in] | gpio_ptr | a pointer to structure vsf_gpio_t |
[in] | pin_mask | pin mask, each pin corresponds to one bit, the value of this bit 1 means configuration is required |
|
extern |
Set the direction of one or more pins of the gpio instance to input.
[in] | gpio_ptr | a pointer to structure vsf_gpio_t |
[in] | Pin | mask, each pin corresponds to one bit, the value of the bit 1 indicates the need to set to input |
|
extern |
Set the direction of one or more pins of the gpio instance to output.
[in] | gpio_ptr | a pointer to structure vsf_gpio_t |
[in] | Pin | mask, each pin corresponds to one bit, the value of the bit 1 indicates the need to set to output |
|
extern |
Toggle the orientation of one or more pins of a gpio instance.
[in] | gpio_ptr | a pointer to structure vsf_gpio_t |
[in] | Pin | mask, each pin corresponds to one bit, the value of the bit 1 indicates the need to set to output |
|
extern |
Read the values of all pins of the gpio instance.
[in] | gpio_ptr | a pointer to structure vsf_gpio_t |
|
extern |
set the value of one or more of the gpio instances
[in] | gpio_ptr | pointer to the structure vsf_gpio_t, refer to vsf_gpio_t |
[in] | value | value of the pin, each pin corresponds to a bit, 1 means high, 0 means high |
[in] | pin_mask | pin 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 |
|
extern |
Set the value of one or more pins of the gpio instance to high.
[in] | gpio_ptr | pointer to the structure vsf_gpio_t, refer to vsf_gpio_t |
[in] | pin_mask | pin 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 |
|
extern |
Set the value of one or more pins of the gpio instance to low.
[in] | gpio_ptr | pointer to the structure vsf_gpio_t, refer to vsf_gpio_t |
[in] | pin_mask | pin 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 |
|
extern |
Toggle the value of one or more pins of the gpio instance.
[in] | gpio_ptr | pointer to the structure vsf_gpio_t, refer to vsf_gpio_t |
[in] | pin_mask | pin 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 |
|
extern |
Set the direction of one or more pins of the gpio instance to output high.
[in] | gpio_ptr | pointer to the structure vsf_gpio_t, refer to vsf_gpio_t |
[in] | pin_mask | pin 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 |
|
extern |
Set the direction of one or more pins of the gpio instance to output low.
[in] | gpio_ptr | pointer to the structure vsf_gpio_t, refer to vsf_gpio_t |
[in] | pin_mask | pin 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 |
|
extern |
Get the capability of gpio instance.
[in] | gpio_ptr | pointer to the structure vsf_gpio_t, refer to vsf_gpio_t |
|
extern |
Configure external interrupt of the gpio instance.
[in] | gpio_ptr | a pointer to structure vsf_gpio_t |
[in] | cfg | a pointer to structure vsf_gpio_exti_irq_cfg_t |
|
extern |
Enable interrupt of one or more pins.
[in] | gpio_ptr | a pointer to structure vsf_gpio_t |
[in] | pin_mask | pin mask, each pin corresponds to one bit, 1 means the bit |
[in] | prio | priority of the interrupt or vsf_arch_prio_invalid for disable |
|
extern |
Disable interrupt of one or more pins.
[in] | gpio_ptr | a pointer to structure vsf_gpio_t |
[in] | pin_mask | pin mask, each pin corresponds to one bit, 1 means the bit |