SDK4.0
This document shows Ameba SDK 4.0 APIs
GPIO

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
objgpio object define in application software.
directionthis 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
objgpio object define in application software.
pinPinName according to pinmux spec.
Return values
none
void gpio_mode ( gpio_t *  obj,
PinMode  mode 
)

Set GPIO mode.

Parameters
objgpio object define in application software.
modethis 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
objgpio object define in application software.
Return values
1pin state is high
0pin state is low
uint32_t gpio_set ( PinName  pin)

Set the given pin as GPIO.

Parameters
pinPinName 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
objgpio object define in application software.
valuespecifies 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