Azure Sphere MT3620 M4 API Reference Manual
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Function

This section provides Fixed APIs(defined as Common Interface) to fully control the MediaTek GPIO HW. More...

Overview

This section provides Fixed APIs(defined as Common Interface) to fully control the MediaTek GPIO HW.

Functions

int mtk_mhal_gpio_get_input (struct mtk_pinctrl_controller *pctl, u32 pin, mhal_gpio_data *pvalue)
 This function is used to get input data of the target GPIO. More...
 
int mtk_mhal_gpio_set_output (struct mtk_pinctrl_controller *pctl, u32 pin, u32 out_val)
 This function is used to set output data of the target GPIO. More...
 
int mtk_mhal_gpio_get_output (struct mtk_pinctrl_controller *pctl, u32 pin, mhal_gpio_data *pvalue)
 This function is used to get output data of the target GPIO. More...
 
int mtk_mhal_gpio_set_direction (struct mtk_pinctrl_controller *pctl, u32 pin, u32 dir)
 This function is used to set the direction of the target GPIO. More...
 
int mtk_mhal_gpio_get_direction (struct mtk_pinctrl_controller *pctl, u32 pin, mhal_gpio_direction *pvalue)
 This function is used to get the direction of the target GPIO. More...
 
int mtk_mhal_gpio_set_pullen_pullsel (struct mtk_pinctrl_controller *pctl, u32 pin, bool enable, bool isup)
 This function is used to set the target GPIO to pull-up/pull-down state. More...
 
int mtk_mhal_gpio_pmx_set_mode (struct mtk_pinctrl_controller *pctl, u32 pin, u32 mode)
 This function is used to configure pinmux of the target GPIO. More...
 
int mtk_mhal_gpio_pmx_get_mode (struct mtk_pinctrl_controller *pctl, u32 pin, u32 *pvalue)
 This function is used to get the configuration pinmux of the target GPIO. More...
 

Function Documentation

int mtk_mhal_gpio_get_input ( struct mtk_pinctrl_controller pctl,
u32  pin,
mhal_gpio_data pvalue 
)

This function is used to get input data of the target GPIO.

Usage: OS-HAL driver should call it in GPIO get-input value function.

Parameters
[in]pctl: GPIO Pinctrl controller used with the device.
[in]pin: Specifies the pin number to operate.(0~93)
[out]*pvalue: 0 means input low, 1 means input high.
Returns
To indicate that whether this function call is successful or not.
If the return value is -EINVAL, it means that a wrong parameter(except for pin number) is given, and the parameter must be verified.
If the return value is -EPIN, it means that a wrong pin number is given, and the parameter must be verified.
If the return value is -ERROR, it means failure.
If the return value is 0, it means success.
int mtk_mhal_gpio_set_output ( struct mtk_pinctrl_controller pctl,
u32  pin,
u32  out_val 
)

This function is used to set output data of the target GPIO.

Usage: OS-HAL driver should call it in GPIO set-output value function.

Parameters
[in]pctl: GPIO Pinctrl controller used with the device.
[in]pin: Specifies the pin number to operate.(0~93)
[in]out_val: Represents output data of the target GPIO.
0, output low.
1, output high.
Returns
To indicate that whether this function call is successful or not.
If the return value is -EINVAL, it means that a wrong parameter(except for pin number) is given, and the parameter must be verified.
If the return value is -EPIN, it means that a wrong pin number is given, and the parameter must be verified.
If the return value is -ERROR, it means failure.
If the return value is 0, it means success.
int mtk_mhal_gpio_get_output ( struct mtk_pinctrl_controller pctl,
u32  pin,
mhal_gpio_data pvalue 
)

This function is used to get output data of the target GPIO.

Usage: OS-HAL driver should call it in GPIO get-output value function.

Parameters
[in]pctl: GPIO Pinctrl controller used with the device.
[in]pin: Specifies the pin number to operate.(0~93)
[out]*pvalue: 0 means output low, 1 means output high.
Returns
To indicate that whether this function call is successful or not.
If the return value is -EINVAL, it means that a wrong parameter(except for pin number) is given, and the parameter must be verified.
If the return value is -EPIN, it means that a wrong pin number is given, and the parameter must be verified.
If the return value is -ERROR, it means failure.
If the return value is 0, it means success.
int mtk_mhal_gpio_set_direction ( struct mtk_pinctrl_controller pctl,
u32  pin,
u32  dir 
)

This function is used to set the direction of the target GPIO.

Usage: OS-HAL driver should call it in GPIO set-direction function.

Parameters
[in]pctl: GPIO Pinctrl controller used with the device.
[in]pin: Specifies the pin number to set.(0~93)
[in]dir: Specified the direction of target GPIO,
0, input.
1, output.
Returns
To indicate that whether this function call is successful or not.
If the return value is -EINVAL, it means that a wrong parameter(except for pin number) is given, and the parameter must be verified.
If the return value is -EPIN, it means that a wrong pin number is given, and the parameter must be verified.
If the return value is -ERROR, it means failure.
If the return value is 0, it means success.
int mtk_mhal_gpio_get_direction ( struct mtk_pinctrl_controller pctl,
u32  pin,
mhal_gpio_direction pvalue 
)

This function is used to get the direction of the target GPIO.

Usage: OS-HAL driver should call it in GPIO get-direction function.

Parameters
[in]pctl: GPIO Pinctrl controller used with the device.
[in]pin: Specifies the pin number to operate.(0~93)
[out]*pvalue: 0 means input, 1 means output.
Returns
To indicate that whether this function call is successful or not.
If the return value is -EINVAL, it means that a wrong parameter(except for pin number) is given, and the parameter must be verified.
If the return value is -EPIN, it means that a wrong pin number is given, and the parameter must be verified.
If the return value is -ERROR, it means failure.
If the return value is 0, it means success.
int mtk_mhal_gpio_set_pullen_pullsel ( struct mtk_pinctrl_controller pctl,
u32  pin,
bool  enable,
bool  isup 
)

This function is used to set the target GPIO to pull-up/pull-down state.

Usage: OS-HAL driver should call it when setting GPIO pull-up/pull-down state.

Parameters
[in]pctl: GPIO Pinctrl controller used with the device.
[in]pin: Specifies the pin number to set.(0~93)
[in]enable: Specifies the pin pullen enable or disable. True means pullen enable; false means pullen disable.
[in]isup: Specifies the pin pullsel up or down. True means pullsel up; false means pullsel down.
Returns
To indicate that whether this function call is successful or not.
If the return value is -EINVAL, it means that a wrong parameter(except for pin number) is given, and the parameter must be verified.
If the return value is -EPIN, it means that a wrong pin number is given, and the parameter must be verified.
If the return value is -ERROR, it means failure.
If the return value is 0, it means success.
int mtk_mhal_gpio_pmx_set_mode ( struct mtk_pinctrl_controller pctl,
u32  pin,
u32  mode 
)

This function is used to configure pinmux of the target GPIO.

Usage: OS-HAL driver should call it in GPIO pinmux function to set multifunction mode. Pinmux represents Pin Multiplexor which connects the pin and the onboard peripherals, so the pin will operate in a specific mode once this pin is programmed to a peripheral's function.

Parameters
[in]pctl: GPIO Pinctrl controller used with the device.
[in]pin: Specifies the pin number to configure.(0~93)
[in]mode: Specifies the function for the pin.(0~7)
Returns
To indicate that whether this function call is successful or not.
If the return value is -EPIN, it means that a wrong parameter(except for pin number) is given, and the parameter must be verified.
If the return value is -EINVALFUNC, it means that a wrong pinmux function is given, and the parameter must be verified.
If the return value is -ERROR, it means failure.
If the return value is 0, it means success.
int mtk_mhal_gpio_pmx_get_mode ( struct mtk_pinctrl_controller pctl,
u32  pin,
u32 *  pvalue 
)

This function is used to get the configuration pinmux of the target GPIO.

Usage: OS-HAL driver should call it in GPIO pinmux function to get multifunction mode. Pinmux represents Pin Multiplexor which connects the pin and the onboard peripherals, so the pin will operate in a specific mode once this pin is programmed to a peripheral's function.

Parameters
[in]pctl: GPIO Pinctrl controller used with the device.
[in]pin: Specifies pin number to configure.(0~93)
[out]*pvalue: Specifies multifunction value.(0~7)
Returns
To indicate that whether this function call is successful or not.
If the return value is -EINVAL, it means that a wrong parameter(except for pin number) is given, and the parameter must be verified.
If the return value is -EPIN, it means that a wrong pin number is given, and the parameter must be verified.
If the return value is -ERROR, it means failure.
If the return value is 0, it means success.