VSF Documented
|
Data Structures | |
struct | w600_gpio_reg_t |
Macros | |
#define | VSF_HAL_CFG_GPIO_PROTECT_LEVEL interrupt |
#define | vsf_gpio_protect vsf_protect(VSF_HAL_CFG_GPIO_PROTECT_LEVEL) |
#define | vsf_gpio_unprotect vsf_unprotect(VSF_HAL_CFG_GPIO_PROTECT_LEVEL) |
Typedefs | |
typedef struct w600_gpio_reg_t | w600_gpio_reg_t |
Functions | |
void | vsf_gpio_port_config_pins (vsf_gpio_t *pthis, vsf_gpio_cfg_t *cfg_ptr) |
void | vsf_gpio_set_direction (vsf_gpio_t *pthis, vsf_gpio_pin_mask_t pin_mask, vsf_gpio_pin_mask_t direction_mask) |
** | |
uint_fast32_t | vsf_gpio_get_direction (vsf_gpio_t *pthis, 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 *pthis, 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 *pthis, 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 *pthis, vsf_gpio_pin_mask_t pin_mask) |
Toggle the orientation of one or more pins of a gpio instance. | |
uint_fast32_t | vsf_hal_gpio_read (vsf_gpio_t *pthis) |
void | vsf_gpio_write (vsf_gpio_t *pthis, 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 *pthis, 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 *pthis, 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 *pthis, vsf_gpio_pin_mask_t pin_mask) |
Toggle the value of one or more pins of the gpio instance. | |
vsf_err_t | vsf_gpio_config (vsf_io_cfg_t *cfg, uint_fast8_t count) |
gpio batch configuration an implementation example: | |
#define VSF_HAL_CFG_GPIO_PROTECT_LEVEL interrupt |
#define vsf_gpio_protect vsf_protect(VSF_HAL_CFG_GPIO_PROTECT_LEVEL) |
#define vsf_gpio_unprotect vsf_unprotect(VSF_HAL_CFG_GPIO_PROTECT_LEVEL) |
typedef struct w600_gpio_reg_t w600_gpio_reg_t |
void vsf_gpio_port_config_pins | ( | vsf_gpio_t * | pthis, |
vsf_gpio_cfg_t * | cfg_ptr | ||
) |
void vsf_gpio_set_direction | ( | vsf_gpio_t * | gpio_ptr, |
vsf_gpio_pin_mask_t | pin_mask, | ||
vsf_gpio_pin_mask_t | direction_mask | ||
) |
**
**
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 |
uint_fast32_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.
[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 |
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.
[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 |
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.
[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 |
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.
[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 |
uint_fast32_t vsf_hal_gpio_read | ( | vsf_gpio_t * | pthis | ) |
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
[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 |
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.
[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 |
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.
[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 |
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.
[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 |
vsf_err_t vsf_gpio_config | ( | vsf_io_cfg_t * | cfg, |
uint_fast8_t | count | ||
) |
gpio batch configuration an implementation example:
static bool vsf_gpio_config( vsf_io_cfg_t *cfg_ptr, uint_fast8_t count ) { bool result = true; if (NULL == cfg_ptr || 0 == count) { return false; }
! io configure do { uint_fast8_t pin_index = cfg_ptr->pin_index; //!< get pin index number uint32_t function = cfg_ptr->function; //!< get pin function selection
! get pin feature and make sure pin-input is enabled by default ! this is an example to enable some feature to be default. uint_fast8_t feature = cfg_ptr->feature ^ IOCTRL_PIN_IE_MSK;
! set pin feature: this is the most optimal solution GSP_IOCTRL.PIN[pin_index].Value = feature;
! but if we are not lucky enough, we can only use the following way if (feature & VSF_IO_PULL_UP) { IOCTRL_ENABLE_PULL_UP(pin_index); } else { IOCTRL_DISABLE_PULL_UP } if (feature & VSF_IO_HIGH_DRV) { IOCTRL_ENABLE_HIGH_DRIVER_STRENGH(pin_index); } else { IOCTRL_DISABLE_HIGH_DRIVER_STRENGH(pin_index); } ...
! I know this is ugly, but some times, the two methods aforementioned ! can be combined. So you should fully use the 32 bit of the ! cfg_ptr->feature
! set pin function selection IOCTRL_FUNCTION_SELECT(pin_index, function);
cfg_ptr++; //!< next one... } while(--count); return result;
}
!
cfg | the pointer points to configuration array ! |
count | the count of configurations in the array ! |