SDK4.0 This document shows Ameba SDK 4.0 APIs

- Main Page
- Modules
- Data Structures
- Files

GPIO
Ameba SDK » HAL

gpio functions More...

## Ameba Common
void | gpio_init (gpio_t *obj, PinName pin)
| Initializes the GPIO device, include mode/direction/pull control registers. More...
uint32_t | gpio_set (PinName pin)
| Set the given pin as GPIO. More...
void | gpio_mode (gpio_t *obj, PinMode mode)
| Set GPIO mode. More...
void | gpio_dir (gpio_t *obj, PinDirection direction)
| Set GPIO direction. More...
void | gpio_write (gpio_t *obj, int value)
| Sets value to the selected output port pin. More...
int | gpio_read (gpio_t *obj)
| Reads the specified gpio port pin. More...

## Detailed Description

gpio functions

## Function Documentation

void gpio_dir | ( | gpio_t * | obj,
|  | PinDirection | direction
| ) |  |

Set GPIO direction.

Parameters

  obj | gpio object define in application software.
  direction | this parameter can be one of the following values: PIN_INPUT: this pin is input PIN_OUTPUT: this pin is output

Return values

  none |

void gpio_init | ( | gpio_t * | obj,
|  | PinName | pin
| ) |  |

Initializes the GPIO device, include mode/direction/pull control registers.

Parameters

  obj | gpio object define in application software.
  pin | PinName according to pinmux spec.

Return values

  none |

void gpio_mode | ( | gpio_t * | obj,
|  | PinMode | mode
| ) |  |

Set GPIO mode.

Parameters

  obj | gpio object define in application software.
  mode | this parameter can be one of the following values: PullNone: HighZ, user can input high or low use this pin OpenDrain(is OpenDrain output): no pull + OUT + GPIO[gpio_bit] = 0 PullDown: pull down PullUp: pull up

Return values

  none |

int gpio_read | ( | gpio_t * | obj | ) |

Reads the specified gpio port pin.

Parameters

  obj | gpio object define in application software.

Return values

  1 | pin state is high
  0 | pin state is low

uint32_t gpio_set | ( | PinName | pin | ) |

Set the given pin as GPIO.

Parameters

  pin | PinName according to pinmux spec.

Return values

  | The given pin with GPIO function

void gpio_write | ( | gpio_t * | obj,
|  | int | value
| ) |  |

Sets value to the selected output port pin.

Parameters

  obj | gpio object define in application software.
  value | specifies the value to be written to the selected pin This parameter can be one of the following values: 0: Pin state set to low 1: Pin state set to high

Return values

  none |