AliOS Things API HAL SOC GPIO Guide - Shaofa/AliOS-Things-Certification-Manual GitHub Wiki

API INDEX


1-hal_gpio_init

int32_t hal_gpio_init(gpio_dev_t *gpio)
  • Description

    Initialises a GPIO pin

  • Parameters

    IN/OUT NAME DESC
    [in] gpio the gpio device which should be initialised
  • Returns

    0 : on success, EIO : if an error occurred with any step

2-hal_gpio_output_high

int32_t hal_gpio_output_high(gpio_dev_t *gpio)
  • Description

    Sets an output GPIO pin high

  • Parameters

    IN/OUT NAME DESC
    [in] gpio the gpio pin which should be set high
  • Returns

    0 : on success, EIO : if an error occurred with any step

3-hal_gpio_output_low

int32_t hal_gpio_output_low(gpio_dev_t *gpio)
  • Description

    Sets an output GPIO pin low

  • Parameters

    IN/OUT NAME DESC
    [in] gpio the gpio pin which should be set low
  • Returns

    0 : on success, EIO : if an error occurred with any step

4-hal_gpio_output_toggle

int32_t hal_gpio_output_toggle(gpio_dev_t *gpio)
  • Description

    Trigger an output GPIO pin's output. Using this function on a gpio pin which is set to input mode is undefined.

  • Parameters

    IN/OUT NAME DESC
    [in] gpio the gpio pin which should be set low
  • Returns

    0 : on success, EIO : if an error occurred with any step

5-hal_gpio_input_get

int8_t hal_gpio_input_get(gpio_dev_t *gpio, uint32_t *value)
  • Description

    Get the state of an input GPIO pin. Using this function on a gpio pin which is set to output mode will return an undefined value.

  • Parameters

    IN/OUT NAME DESC
    [in] gpio the gpio pin which should be read
    [in] value gpio value
  • Returns

    0 : on success, EIO : if an error occurred with any step

6-hal_gpio_enable_irq

int32_t hal_gpio_enable_irq(gpio_dev_t *gpio, gpio_irq_trigger_t trigger,
                            gpio_irq_handler_t handler, void *arg)
  • Description

    Enables an interrupt trigger for an input GPIO pin. Using this function on a gpio pin which is set to output mode is undefined.

  • Parameters

    IN/OUT NAME DESC
    [in] gpio the gpio pin which will provide the interrupt trigger
    [in] trigger the type of trigger (rising/falling edge)
    [in] handler a function pointer to the interrupt handler
    [in] arg an argument that will be passed to the interrupt handle
  • Returns

    0 : on success, EIO : if an error occurred with any step

7-hal_gpio_disable_irq

int32_t hal_gpio_disable_irq(gpio_dev_t *gpio)
  • Description

    Disables an interrupt trigger for an input GPIO pin. Using this function on a gpio pin which has not been set up using @ref hal_gpio_input_irq_enable is undefined.

  • Parameters

    IN/OUT NAME DESC
    [in] gpio the gpio pin which provided the interrupt trigge
  • Returns

    0 : on success, EIO : if an error occurred with any step

8-hal_gpio_clear_irq

int32_t hal_gpio_clear_irq(gpio_dev_t *gpio)
  • Description

    Disables an interrupt trigger for an input GPIO pin. Using this function on a gpio pin which has not been set up using @ref hal_gpio_input_irq_enable is undefined.

  • Parameters

    IN/OUT NAME DESC
    [in] gpio the gpio pin which provided the interrupt trigge
  • Returns

    0 : on success, EIO : if an error occurred with any step

9-hal_gpio_finalize

int32_t hal_gpio_finalize(gpio_dev_t *gpio)
  • Description

    Set a GPIO pin in default state.

  • Parameters

    IN/OUT NAME DESC
    [in] gpio the gpio pin which should be deinitialised
  • Returns

    0 : on success, EIO : if an error occurred with any step

⚠️ **GitHub.com Fallback** ⚠️