VSF Documented
Data Structures | Macros | Typedefs | Functions
io_lv0.c File Reference
#include "../common.h"
#include "./io.h"

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:
 

Macro Definition Documentation

◆ VSF_HAL_CFG_GPIO_PROTECT_LEVEL

#define VSF_HAL_CFG_GPIO_PROTECT_LEVEL   interrupt

◆ vsf_gpio_protect

#define vsf_gpio_protect   vsf_protect(VSF_HAL_CFG_GPIO_PROTECT_LEVEL)

◆ vsf_gpio_unprotect

#define vsf_gpio_unprotect   vsf_unprotect(VSF_HAL_CFG_GPIO_PROTECT_LEVEL)

Typedef Documentation

◆ w600_gpio_reg_t

Function Documentation

◆ vsf_gpio_port_config_pins()

void vsf_gpio_port_config_pins ( vsf_gpio_t pthis,
vsf_gpio_cfg_t cfg_ptr 
)

◆ 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 
)

‍**

‍**

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()

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.

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 
)

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 
)

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 
)

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_hal_gpio_read()

uint_fast32_t vsf_hal_gpio_read ( vsf_gpio_t pthis)

◆ 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 
)

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 
)

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 
)

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 
)

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_config()

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;

}

!

Parameters
cfgthe pointer points to configuration array !
countthe count of configurations in the array !
Returns
configuration result