PicoWAN SDK Documentation
Enumerations | Functions
gpio.h File Reference

GPIO driver. More...

#include <stdint.h>
#include <arch.h>

Go to the source code of this file.

Enumerations

enum  gpio_pin_mode_t {
  GPIO_PMODE_INPUT, GPIO_PMODE_OUTPUT, GPIO_PMODE_ANALOG,
  GPIO_PMODE_ALT_FUNC
}
 
enum  gpio_output_mode_t { GPIO_OMODE_OPEN_DRAIN, GPIO_OMODE_PUSH_PULL }
 
enum  gpio_pupd_t { GPIO_PUPD_NONE, GPIO_PUPD_UP, GPIO_PUPD_DOWN }
 
enum  gpio_output_speed_t {
  GPIO_OSPEED_LOW, GPIO_OSPEED_MED, GPIO_OSPEED_HIGH,
  GPIO_OSPEED_VHIGH
}
 
enum  gpio_irq_mode_t {
  GPIO_IRQ_MODE_NONE, GPIO_IRQ_MODE_FALLING, GPIO_IRQ_MODE_RISING,
  GPIO_IRQ_MODE_BOTH
}
 

Functions

void gpio_cfg_pin (gpio_port_t port, uint8_t pin, gpio_pin_mode_t mode, gpio_output_mode_t omode, gpio_pupd_t pull, gpio_output_speed_t speed, uint8_t alt)
 Configures the behavior of a particular pin. More...
 
void gpio_set_pin (gpio_port_t port, uint8_t pin, uint8_t state)
 Sets the state of a particular pin configured in output mode. More...
 
void gpio_toggle_pin (gpio_port_t port, uint8_t pin)
 Toggles the state of a particular pin configured in output mode. More...
 
uint8_t gpio_get_pin (gpio_port_t port, uint8_t pin)
 Gets the state of a particular pin. More...
 
void gpio_config_irq (gpio_port_t port, uint8_t pin, gpio_irq_mode_t mode)
 Configures the IRQ mode of a pin. More...
 

Detailed Description

GPIO driver.

Copyright (c) 2018, Archos S.A. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND AND EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARCHOS S.A. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

void gpio_cfg_pin ( gpio_port_t  port,
uint8_t  pin,
gpio_pin_mode_t  mode,
gpio_output_mode_t  omode,
gpio_pupd_t  pull,
gpio_output_speed_t  speed,
uint8_t  alt 
)

Configures the behavior of a particular pin.

Parameters
portThe port of the pin (GPIO_PORT_A, GPIO_PORT_B, ...).
pinThe number of the pin.
modeThe mode of the pin. This can be GPIO_PMODE_INPUT for input, GPIO_PMODE_OUTPUT for output, GPIO_PMODE_ALT_FUNC for alternate-function, or GPIO_PMODE_ANALOG for analog.
typeThe type of the pin. This can be GPIO_OMODE_PUSH_PULL for push-pull or GPIO_OMODE_OPEN_DRAIN for open-drain.
pullThe internal pull-up/down of the pin. This can be GPIO_PUPD_UP, GPIO_PUPD_DOWN or GPIO_PUPD_NONE.
speedThe speed of the pin. This can be GPIO_OSPEED_LOW, GPIO_OSPEED_MED, GPIO_OSPEED_HIGH, or GPIO_OSPEED_VHIGH.
altThe alternate function number of the pin (used only if if its mode is GPIO_PMODE_ALT_FUNC).
void gpio_config_irq ( gpio_port_t  port,
uint8_t  pin,
gpio_irq_mode_t  mode 
)

Configures the IRQ mode of a pin.

Parameters
portThe port of the pin (GPIO_PORT_A, GPIO_PORT_B, ...).
pinThe number of the pin.
modeThe IRQ mode of the pin. This can be GPIO_IRQ_MODE_NONE, GPIO_IRQ_MODE_FALLING, GPIO_IRQ_MODE_RISING or GPIO_IRQ_MODE_BOTH.
uint8_t gpio_get_pin ( gpio_port_t  port,
uint8_t  pin 
)

Gets the state of a particular pin.

Parameters
portThe port of the pin (GPIO_PORT_A, GPIO_PORT_B, ...).
pinThe number of the pin.
Return values
uint8_t1 for High, 0 for Low.
void gpio_set_pin ( gpio_port_t  port,
uint8_t  pin,
uint8_t  state 
)

Sets the state of a particular pin configured in output mode.

Parameters
portThe port of the pin (GPIO_PORT_A, GPIO_PORT_B, ...).
pinThe number of the pin.
stateThe new state of the pin (1 for High, 0 for Low).
void gpio_toggle_pin ( gpio_port_t  port,
uint8_t  pin 
)

Toggles the state of a particular pin configured in output mode.

Parameters
portThe port of the pin (GPIO_PORT_A, GPIO_PORT_B, ...).
pinThe number of the pin.