Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
gpio_ardrone.c File Reference

ardrone GPIO driver More...

#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include "mcu_periph/gpio.h"
+ Include dependency graph for gpio_ardrone.c:

Go to the source code of this file.

Data Structures

struct  gpio_data
 
struct  gpio_direction
 

Macros

#define GPIO_MAGIC   'p'
 
#define GPIO_DIRECTION   _IOW(GPIO_MAGIC, 0, struct gpio_direction)
 
#define GPIO_READ   _IOWR(GPIO_MAGIC, 1, struct gpio_data)
 
#define GPIO_WRITE   _IOW(GPIO_MAGIC, 2, struct gpio_data)
 

Enumerations

enum  gpio_mode { GPIO_INPUT = 0 , GPIO_OUTPUT_LOW , GPIO_OUTPUT_HIGH }
 

Functions

void gpio_set (uint32_t port, uint16_t pin)
 Set a gpio output to high level. More...
 
void gpio_clear (uint32_t port, uint16_t pin)
 Clear a gpio output to low level. More...
 
void gpio_setup_input (uint32_t port, uint16_t pin)
 Setup one or more pins of the given GPIO port as inputs. More...
 
void gpio_setup_output (uint32_t port, uint16_t pin)
 Setup one or more pins of the given GPIO port as outputs. More...
 
uint16_t gpio_get (uint32_t port, uint16_t pin)
 Read a gpio value. More...
 

Variables

int gpiofp = 0
 

Detailed Description

ardrone GPIO driver

Definition in file gpio_ardrone.c.


Data Structure Documentation

◆ gpio_data

struct gpio_data

Definition at line 37 of file gpio_ardrone.c.

Data Fields
int pin
int value

◆ gpio_direction

struct gpio_direction

Definition at line 48 of file gpio_ardrone.c.

Data Fields
enum gpio_mode mode
int pin

Macro Definition Documentation

◆ GPIO_DIRECTION

#define GPIO_DIRECTION   _IOW(GPIO_MAGIC, 0, struct gpio_direction)

Definition at line 32 of file gpio_ardrone.c.

◆ GPIO_MAGIC

#define GPIO_MAGIC   'p'

Definition at line 31 of file gpio_ardrone.c.

◆ GPIO_READ

#define GPIO_READ   _IOWR(GPIO_MAGIC, 1, struct gpio_data)

Definition at line 33 of file gpio_ardrone.c.

◆ GPIO_WRITE

#define GPIO_WRITE   _IOW(GPIO_MAGIC, 2, struct gpio_data)

Definition at line 34 of file gpio_ardrone.c.

Enumeration Type Documentation

◆ gpio_mode

enum gpio_mode
Enumerator
GPIO_INPUT 

Pin configured for input.

GPIO_OUTPUT_LOW 

Pin configured for output with low level.

GPIO_OUTPUT_HIGH 

Pin configured for output with high level.

Definition at line 42 of file gpio_ardrone.c.

Function Documentation

◆ gpio_clear()

void gpio_clear ( uint32_t  port,
uint16_t  pin 
)

Clear a gpio output to low level.

Definition at line 70 of file gpio_ardrone.c.

References GPIO_WRITE, gpiofp, gpio_data::pin, and gpio_data::value.

◆ gpio_get()

uint16_t gpio_get ( uint32_t  port,
uint16_t  pin 
)

Read a gpio value.

Definition at line 120 of file gpio_ardrone.c.

References GPIO_READ, gpiofp, gpio_data::pin, and gpio_data::value.

◆ gpio_set()

void gpio_set ( uint32_t  port,
uint16_t  pin 
)

Set a gpio output to high level.

Definition at line 54 of file gpio_ardrone.c.

References GPIO_WRITE, gpiofp, gpio_data::pin, and gpio_data::value.

◆ gpio_setup_input()

void gpio_setup_input ( uint32_t  port,
uint16_t  gpios 
)

Setup one or more pins of the given GPIO port as inputs.

Parameters
[in]port
[in]gpiosIf multiple pins are to be changed, use logical OR '|' to separate them.

Definition at line 86 of file gpio_ardrone.c.

References dir, GPIO_DIRECTION, GPIO_INPUT, gpiofp, and gpio_direction::pin.

◆ gpio_setup_output()

void gpio_setup_output ( uint32_t  port,
uint16_t  gpios 
)

Setup one or more pins of the given GPIO port as outputs.

Parameters
[in]port
[in]gpiosIf multiple pins are to be changed, use logical OR '|' to separate them.

Definition at line 102 of file gpio_ardrone.c.

Variable Documentation

◆ gpiofp

int gpiofp = 0

Definition at line 35 of file gpio_ardrone.c.

Referenced by gpio_clear(), gpio_get(), gpio_set(), and gpio_setup_input().