VSF Documented
|
Data Structures | |
struct | vsf_hw_gpio_t |
Macros | |
#define | VSF_GPIO_CFG_IMP_PREFIX vsf_hw |
#define | VSF_GPIO_CFG_IMP_UPCASE_PREFIX VSF_HW |
#define | VSF_GPIO_CFG_REIMPLEMENT_API_SET_INPUT ENABLED |
#define | VSF_GPIO_CFG_REIMPLEMENT_API_SET_OUTPUT ENABLED |
#define | VSF_GPIO_CFG_REIMPLEMENT_API_SWITCH_DIRECTION ENABLED |
#define | VSF_GPIO_CFG_REIMPLEMENT_API_SET ENABLED |
#define | VSF_GPIO_CFG_REIMPLEMENT_API_CLEAR ENABLED |
#define | VSF_HAL_CFG_GPIO_PROTECT_LEVEL interrupt |
#define | vsf_hw_gpio_protect vsf_protect(VSF_HAL_CFG_GPIO_PROTECT_LEVEL) |
#define | vsf_hw_gpio_unprotect vsf_unprotect(VSF_HAL_CFG_GPIO_PROTECT_LEVEL) |
#define | VSF_HW_IO_CFG_MULTI_CLASS VSF_IO_CFG_MULTI_CLASS |
#define | __gpio_is_output(__mode) ((__mode) > 0) |
#define | VSF_GPIO_CFG_IMP_LV0(__IDX, __HAL_OP) |
Typedefs | |
typedef struct vsf_hw_gpio_t | vsf_hw_gpio_t |
#define VSF_GPIO_CFG_IMP_PREFIX vsf_hw |
#define VSF_GPIO_CFG_IMP_UPCASE_PREFIX VSF_HW |
#define VSF_GPIO_CFG_REIMPLEMENT_API_SET_INPUT ENABLED |
#define VSF_GPIO_CFG_REIMPLEMENT_API_SET_OUTPUT ENABLED |
#define VSF_GPIO_CFG_REIMPLEMENT_API_SWITCH_DIRECTION ENABLED |
#define VSF_GPIO_CFG_REIMPLEMENT_API_SET ENABLED |
#define VSF_GPIO_CFG_REIMPLEMENT_API_CLEAR ENABLED |
#define VSF_HAL_CFG_GPIO_PROTECT_LEVEL interrupt |
#define vsf_hw_gpio_protect vsf_protect(VSF_HAL_CFG_GPIO_PROTECT_LEVEL) |
#define vsf_hw_gpio_unprotect vsf_unprotect(VSF_HAL_CFG_GPIO_PROTECT_LEVEL) |
#define VSF_HW_IO_CFG_MULTI_CLASS VSF_IO_CFG_MULTI_CLASS |
#define __gpio_is_output | ( | __mode | ) | ((__mode) > 0) |
#define VSF_GPIO_CFG_IMP_LV0 | ( | __IDX, | |
__HAL_OP | |||
) |
typedef struct vsf_hw_gpio_t vsf_hw_gpio_t |
void vsf_hw_gpio_config_pin | ( | vsf_hw_gpio_t * | pthis, |
vsf_gpio_pin_mask_t | pin_mask, | ||
uint32_t | feature | ||
) |
void vsf_hw_gpio_set_direction | ( | vsf_hw_gpio_t * | pthis, |
vsf_gpio_pin_mask_t | pin_mask, | ||
vsf_gpio_pin_mask_t | direction_mask | ||
) |
vsf_gpio_pin_mask_t vsf_hw_gpio_get_direction | ( | vsf_hw_gpio_t * | pthis, |
vsf_gpio_pin_mask_t | pin_mask | ||
) |
void vsf_hw_gpio_set_input | ( | vsf_hw_gpio_t * | pthis, |
vsf_gpio_pin_mask_t | pin_mask | ||
) |
void vsf_hw_gpio_set_output | ( | vsf_hw_gpio_t * | pthis, |
vsf_gpio_pin_mask_t | pin_mask | ||
) |
void vsf_hw_gpio_switch_direction | ( | vsf_hw_gpio_t * | pthis, |
vsf_gpio_pin_mask_t | pin_mask | ||
) |
vsf_gpio_pin_mask_t vsf_hw_gpio_read | ( | vsf_hw_gpio_t * | pthis | ) |
void vsf_hw_gpio_write | ( | vsf_hw_gpio_t * | pthis, |
vsf_gpio_pin_mask_t | pin_mask, | ||
vsf_gpio_pin_mask_t | value | ||
) |
void vsf_hw_gpio_set | ( | vsf_hw_gpio_t * | pthis, |
vsf_gpio_pin_mask_t | pin_mask | ||
) |
void vsf_hw_gpio_clear | ( | vsf_hw_gpio_t * | pthis, |
vsf_gpio_pin_mask_t | pin_mask | ||
) |
void vsf_hw_gpio_toggle | ( | vsf_hw_gpio_t * | pthis, |
vsf_gpio_pin_mask_t | pin_mask | ||
) |
vsf_err_t vsf_hw_gpio_config | ( | vsf_io_cfg_t * | cfg, |
uint_fast8_t | count | ||
) |
gpio batch configuration an implementation example:
static bool vsf_hw_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 ! |